Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pcANYWHERE OLE code for VB 19

Status
Not open for further replies.

fwadmin

IS-IT--Management
Jun 23, 2005
6
US
I have a bunch of pcANYWHERE script files written to do various automatic transfers. It seems that Symantec's newer versions of pcANYWHERE no longer support the script files and now use OLE for integration into other applications. The documentation for this completely stinks in that they give no VB examples of invoking transfers.

Anyone out there have any VB code with pcAYNWHERE they can share?

Thanks.
 
Yep, the shell command for VB apparently only runs programs, not associated files.

Here's the solution though:

Declare this at top of form, or in .bas module:
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Then run the host file like this:
ShellExecute Me.hwnd, "Launch", "C:\winnt40\profiles\all users\application data\symantec\pcanywhere\network.bhf", vbNullString, vbNullString, vbNormalFocus

I did try this out, and it works fine.
 
Hi All:

I had been working on something with VB a little while ago and have not been able to programmatically download files from the host. I did however, at one point, test pcanywhere directly to record a script and download a file that way, but that was not with VB. Does anyone know if a script file can be created (for version 10.0) and then run from the VB program, and if so how? I had attempted to create a script file once, but after saving it, I never found it as an individual file. It seems that the actions might have been recorded into the CHF. I don't know. Can anyone help?

mgerbs
 
Hi Everybody,
I want to query a process on a remote machine. Whether a process is started/stopped) on a remote machine. Can I use PCAnywhere to write a script for that.
Can anybody help in that direction?

 
Santor - Thanks for the reply. As I described, I managed to get through it, but it is ugly. Since the pcAnywhere object does not return a useful value as you so candidly point out. I had not picked up on the fact that the xfer does the same thing. That has now been a problem since we deployed. I have found a way to launch awremote from the command line (like I did in the pre-pcAW 10 days) and use the automatic file transfer function in the .CHF to send and receive files. Unfortunately, it does not provide a way to do the executes on the host so we will have to build a scheduled task to do that. Thanks again.
 
nimeshb - I am not aware of anyway to have pcAnywhere check directly. You could probably write a program that would check for the process and write the result to a file. Essentially you would transfer the program to the other computer, execute it, and then transfer the results file back.
 
Hi everyone,
I've a little problem. I wrote a PCany script for the 9 version, but now, with the 10.0 the scrips are not supported. All that i have to do is to verify if the calling pc is really the one I want, maybe checking its netbios name o IP address or something else. I also want to check this parameter with a list saved in the Host pc in order to enable/disable the authorized remote.

Whith previous versions I launch the script at the connection of a caller and then, checking an environment variable, I drop the conection if it is not authorized.
I also log the connect / disconnect events to a Host local file.

Any idea?

Thanks in advance...
Max

 
Hello,

i'm trying to automate the function of right click->Call remote on a PCA 9.2 Host connection. I wrote a VB program using the function HostDataManager.Launch ("C:\WINDOWS\All Users\Dati applicazioni\Symantec\pcAnywhere\Modem.bhf"), ant it is ok. But what i want is not to have the host computer waiting for a call, but make it to call the remote computer. I want to automate the function of right click->Call remote so the telephone call is made by the host.
It is pretty simple but i can't solve this problem...
The manual on the CD of PCA is very essential, and in some parts leaves a lot to be desired....

Thanks.
[pipe]
 
I'm attempting to use a the code given on the first reply to this thread in VB6. It's working if I PCA into the box I'm developing on (setup my PC as a host and remote to it). But if I try to connect to another PC in VB the connection always fails. I can however, manually open the PCA remote file in PCA and it will connect without a hitch all the connections are TCP/IP. HELP!!!
 
AmeriTouch: I've used your program .... It works GREAT !
As I was putting the References in, I noticed 2 AW already listed:
AwFileXferLib = AWxfer.dll
AwXferUI 1.0 = AwXferUI.dll

Do you know anything about these ?

TIA

I'll also give you a star !

 
I get lot of benefit in this forum about pcanywhere automation and it's working well.

But on a special machine (with win xp pro), when I want to send a file (the executable program file himself) the pcanywhere dialog box transfer a big part of the file and then stop before the 100 bytes before the end of the file.

is there any solution to this problem ?

(pcanywhere 10.5.1, build 505 and the main programm is writing with visual basic 6 SP5).
thanks
 
Yup !
The file transfer listed in the top of this tread works, but it need to open the connection itself. Is it true?
Is it possible to start a file xfer using an existing connection? If I comment the line that opens the connection [ oTestApp.awConnect("C:\Documents and Settings\All Users\Application Data\Symantec\pcAnywhere\test.chf") ] I experience an error...

Thanks...
 
With Delphi 5 and PcAnywhere 10, I run this function code. All run OK.

PCAWREM32 := CreateOleObject('Awrem32.Application');
PCAWREM32.awConnect('C:\Documents and Settings\All Users\Datos de programa\Symantec\pcAnywhere\PRUEBA.chf');
PCAWREM32.ConnectionStatus;
PCAWREM32.FileXferFromHost('C:\Envio\*.txt', 'C:\*.txt');

PCAWREM32.ExecuteHostFile('C:\Windows\notepad.exe');

PCAWREM32.awDisconnect;

Nevertheless metodo FileXferFromHost although gives back a True value as if the execution had been correct, does not execute the corresponding command on the Host.
 
Guys,

Finally, after 3 gruelling days :) I got the pcanywhere10.5 code(VB) working on a windows 2000 server heres what it does

it loads the hosts sequentially to be dialed out from a flat file lets say "input.txt"
Dials out to the host, records date time stamp, if it couldnt connect or couldnt find the host or connected to the host successfully.
if it couldnt connect goes back to dial the next host.

if it connects it transfers file to the host and receives files from the host, while recieving files from the host if same files already exist on the remote server then it appends to them. I will be using this to poll data from 100's of POS machines in 3 months :eek:) I am already using 9.2 to do that currently

Disconnects and dials the next one! the code seems to work perfectly thanks to all the discussion here! I got a lot of help if anybody needs the sample code or a portion of it lemme know I should be able to create a generic one in one day and post it here by friday!

thanks Meldric ameritouch and others for gettin me a good start
-Sibasis
 
Yes, great.
Now, after a few days of trials without a fine solution to my problem I ask you all a little help.
I have to verify that the pc calling my host is really th one I want. I don't wanna a user installing PCAny on a different pc and connect to my host.
I've tried to make a file transfer at the start of the connection using a script running in the host side but is not good idea.
All I understand is that the methods of HostDataManager and RemoteDataManager refers to the pc they runs. The only way to check or do something on the remote pc is to use the AWREM32 methods, but as I understood they works only on the side that create the connection. Is it true?

Can anyone of you sugget me an idea?

Thanks!!!
Max
 
Hello sibasis,

I like your suggestion. Please post your code, I am sure many will profit from it.

Thanks
 
here you go lodis,
If anyone has a more optmized way of doin this pls lemme know.
this is very basic and I really just started developing so there might be bugs, If I find some I will update it here.
** Beware of typos ** :eek:) I am really good at makin typos

The best thing to do would be to not to copy the entire code but get the concept, that would work better! for you.

'Author: Sibasis Sahoo – march 2003
'Project: Pcanywhere 10.5 script
'Description: An Example for OLE, Visual Basic 6, Win 2000
'What it does: Connects to a host sequentially from a flat file, transfers files from host to a temporary folder, appends them into the main folder, then dials the next host from the input flat file.

'References I have set in the vb ide:
'Winawsvr
'awrem32
'Microsoft scripting runtime
'awfilexfer 1.0 type library
'awxferui 1.0 type library

' pause function its useful to set a delay so that pcanywhere does not error out
' thanks dankelt, I got this from him
Public Function Pause()
Dim PauseTime, Start, Finish, TotalTime
PauseTime = 10 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
'MsgBox (TotalTime)
End Function
Private Sub Form_Load()

'Declare your variables here
Dim remote As Object
Dim con, cnt As Integer
Dim Host, hostfile, remotefile, HostID As String
Dim WentOK As Boolean
Dim checktrnsfr As Boolean
Dim fso As New FileSystemObject, log As TextStream 'Create Log File
Dim todaydate, todaytime As String
Dim nFile As String


' Check if log file already exists if it dosent create it in append mode, write the header close it.
If Dir$(&quot;c:\temp\my.log&quot;) = &quot;&quot; Then
'MsgBox &quot;The file was not found. Please try again!&quot;
Open &quot;c:\temp\my.log&quot; For Append As #1
Print #1, &quot; ================================================== &quot;
Print #1, Format$(Now, &quot;mm-dd hh:mm:ss&quot;) & &quot; PCAnywhere Scripting Log File &quot;
Print #1, &quot; ================================================== &quot;
Print #1, &quot; &quot;
Print #1, &quot; &quot;
Close #1
End If

'If it already exists open it in append mode
Open &quot;c:\temp\my.log&quot; For Append As #1

'Temporary remote folder where we transfer the files from the host into
'If it dosent exist abort the polling script write into the log file
If fso.FolderExists(&quot;s:\temporaryrecievingfolder&quot;) = False Then
Print #1, Format$(Now, &quot;mm-dd hh:mm:ss&quot;) & &quot;Error! Temp remote Folder missing ...! aborting...&quot;
GoTo endapp:
Else
'MsgBox (&quot;we are ok&quot;) ' for testing purposes only
End If

'Check for the existence of the input file in the polling1 folder which contains teh host names
'If it dosent exist write into log file and abort polling program
If fso.FileExists(&quot;c:\program files\symantec\pcanywhere\polling1\input.txt&quot;) = False Then
Print #1, Format$(Now, &quot;mm-dd hh:mm:ss&quot;) & &quot;Error! Input file missing ...! aborting...&quot;
GoTo endapp:
Else
'MsgBox (&quot;we are ok&quot;) ' for testing purposes only
End If

'If the input file exists open it in read mode
Open &quot;c:\program files\symantec\pcanywhere\polling1\input.txt&quot; For Input As #2

' This is where the application comes to when it wants to dial into the next host
' This happens when the app finishes gettin data from teh 1st host and is ready to get data
' from next host
nexthost:

'If files exist in the temporary remote folder delete them
If fso.FileExists(&quot;S:\temporaryrecievingfolder\*.txt&quot;) = True Then
Kill (&quot;S:\temporaryrecievingfolder\*.txt&quot;)
End If

'read the input file till the end of file
' if the end has been reached end application
If EOF(2) Then
Print #1, &quot;-------------End of input file reached---------------&quot;
GoTo endapp:
End If
' if the end hasnt been reached read the next host from the input file
' the host name will be simply &quot;host1&quot; or something like that in the input file
Line Input #2, Host
'MsgBox (Host) ' for testing purposes only


'Assign the host name to another variable
HostID = Host

'Set the polling folder and add the extension to the host name
'This sets the host name to c:\program files\symantec\pcanywhere\polling1\host1.chf
Host = &quot;c:\program files\symantec\pcanywhere\polling1\&quot; & HostID & &quot;.chf&quot;

'This is a check if the main folder for that host where the files are going to be transferred exists
'If it dosent exist we write to the log and dial the next host
If fso.FolderExists(&quot;s:\mainrecievingfolder\&quot; & HostID&quot;) = False Then
Print #1, &quot; &quot;
Print #1, &quot;Error! Error! Main Remote Recieving Folder dosent exist! for &quot; & HostID
Print #1, &quot; &quot;

GoTo nexthost:
End If
WentOK = True
'MsgBox (Host) ' for testing purposes only

Set remote = CreateObject(&quot;Awrem32.Application&quot;)

'Attempt to connect to the host
WentOK = remote.awConnect(Host)
'MsgBox (WentOK)

Print #1, Format$(Now, &quot;mm-dd hh:mm:ss&quot;) & &quot; Connecting to host &quot; & HostID
'Check the return boolean and branch accordingly
'If remote object not found dial next host
If WentOK = False Then
Print #1, Format$(Now, &quot;mm-dd hh:mm:ss&quot;) & &quot; Couldnt find host &quot; & HostID
Print #1, Format$(Now, &quot;mm-dd hh:mm:ss&quot;) & &quot; Releasing connect thread of &quot; & HostID
Print #1, &quot; &quot;
Set remote = Nothing

'MsgBox (&quot;couldnt find host&quot;)
'WentOK = remote.awDisconnect()
GoTo nexthost:

Else
'Pause
'Check the connection status to the host

con = 0
con = remote.ConnectionStatus

'If it couldnt connect write to the log file and dial next host
If con = -1 Then
'MsgBox (con)
Print #1, Format$(Now, &quot;mm-dd hh:mm:ss&quot;) & &quot; Couldnt connect to host &quot; & HostID
Print #1, Format$(Now, &quot;mm-dd hh:mm:ss&quot;) & &quot; Releasing connect thread of &quot; & HostID
Print #1, &quot; &quot;
Set remote = Nothing
GoTo nexthost:

End If
'MsgBox (con)
'If it could connect start the file transfer write to log
hostfile = &quot;c:\hostcomputer\output\*.txt&quot;
remotefile = &quot;s:\temporaryrecievingfolder\*.txt&quot;
Print #1, Format$(Now, &quot;mm-dd hh:mm:ss&quot;) & &quot; Connected to host &quot; & HostID
'MsgBox (&quot;connected&quot;)
Pause
checktrnsfr = remote.FileXferFromHost(hostfile, remotefile)
Pause
' you can check the file transfer return here I am not doing it
Print #1, Format$(Now, &quot;mm-dd hh:mm:ss&quot;) & &quot; Files transferred from host &quot; & HostID & &quot;'s to temp poll folder.&quot;

'create another text file where we will list all the files transferred
Set log = fso.CreateTextFile(&quot;c:\temp\outputfiles.log&quot;, True)

Dim sNextFile As String


sNextFile = Dir$(&quot;s:\temporaryrecievingfolder\*.txt&quot;)

'MsgBox (sNextFile)
While sNextFile <> &quot;&quot;
nFile = sNextFile
log.WriteLine (nFile)

'MsgBox (sNextFile)
Dim sourcefile As String
Dim destfile As String

' set the temprary recieving folder and the main recieving folder here
' here we will try to check if files already exist in the main recieving folder
' if they exist we shall append to them otherwise we will simply copy the files
sourcefile = &quot;s:\temporaryrecievingfolder\&quot; & nFile
destfile = &quot;s:\mainrecievingfolder\&quot; & HostID & &quot;\&quot; & nFile



If fso.FileExists(&quot;s:\mainrecievingfolder\&quot; & HostID & &quot;\&quot; & nFile) Then
Print #1, Format$(Now, &quot;mm-dd hh:mm:ss&quot;) & &quot; Files found in main recieving folder append mode enabled!&quot;
Open destfile For Append As #99
Open sourcefile For Input As #98
Dim sTemp As String
While Not EOF(98)
Line Input #98, sTemp
Print #99, sTemp
Wend
Close #98
Close #99
Else
'MsgBox (&quot;attempting filecopy&quot;)
' copy the file from the temp recieving folder to the main recieving folder if files not found in main.
Print #1, Format$(Now, &quot;mm-dd hh:mm:ss&quot;) & &quot; Files not found in main recieving folder, append mode bypassed!&quot;
FileCopy sourcefile, destfile
End If


'set the application to read the next file in the temporary recieving folder
sNextFile = Dir$
'MsgBox (sNextFile)
Wend


' If everything successful, disconnect from this host go to the next host to be dialed

WentOK = remote.awDisconnect()
GoTo nexthost:
End If

' this is where the application comes to exit out
endapp:
'Print #1, Format$(Now, &quot;mm-dd hh:mm:ss&quot;) & &quot;------- End of Script-------- &quot;
'Print #1, &quot; &quot;
'Close #1
'MsgBox (&quot;out&quot;)
Set remote = Nothing
End



End Sub

 
Hi Everyone, I'm new to all this but I learn quick. This is my problem. I am running Windows 2000 SP3, PCAnywhere 10.5. I am wanting to use either VB or C+ to create a polling system for my office. I am using Visual Studio.Net. When I try to add AWREM32.tlb and winawsvr.tlb as references I get an ERROR. &quot;Could not create the wrapper assembly for the Active X type library.You may need to register it.&quot; You given me help on everything else through this forum but I havent seen this problem mentioned.

Can anyone help me? I have a week to create a polling program for 8 restaurants.

Appreciatively,

Brian
 
Hi Everyone,

Just some tips if you are using Visual Basic.Net or Visual C+.Net when working with PCAnywhere OLE Automation. I finally got my polling program to work, when I installed Visual Basic 6 on my system. It recognized all the type libraries no problem. I guess these components are to old for .NET . Anyways, If you want to use .NET you must create it in an older version first(like 6.0) then convert it to .NET so as to register the type libraries automatically.
Because there has been some language changes in .NET, all the components will not work properly but at least its a starting point. Hope this helps anyone.
 
I want to pass a parameter to a &quot;.bat&quot; file on the host computer while executing it, this is what I am doing

hostexe = &quot;c:\somefolder\pollmove.bat a&quot;
WentOK = remote.ExecuteHostFile(hostexe)
Pause


WentOK Returns true but it dosent start the command window at all
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top