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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pcAnywhere and OLE problems 5

Status
Not open for further replies.

CathyG

Programmer
Jul 2, 2002
2
0
0
NZ
What I am trying to achieve is:

I have to create a Remote object which connects to a host in Antarticia, delete and rename files on that host then transfer files back to another host in New Zealand.

(at present I am using a direct connection, around my own network to try and achieve this before trying to connect by cable modem)
I am using pcAnywhere 10.5 and in this version the scripting has been removed. I have created a VB application (to work with pcAnywhere's automation server) which connects to my Host (fine so far), I can transfer the files no problem as I can use the AWREM32 FileTransferFromHost(HostFile,RemoteFile) function to do this. My problem is deleting and renaming files on the Host. What object do I use to do this?

Do I use the RemoteDataManager DeleteObject(Name,Password)object or do I have to get hold of the HostDataManager DeleteObject(Name,Password) object to do this? If so HOW?
There doesn't appear to be anything in the AWREM32 functions that can assist in this.

I have tried several different methods but without success.

Can anyone help? Please. Thanks in anticipation

Cheers
C
 
Well, what I did was dynamically create a batch file in my VB program that did all the Copying / Deleting / Renaming. Then send the batch file to the host (temp directory) and then execute it. I can't think of a better way of doing it, but if you find one let me know!

Dan
 
I too was left high and dry when pcAnywhere discontinued scripting, and I have the added handicap of being very new to "real" programming. I'm trying to get up to speed fast on Visual Basic, but my work demands that I come up with something right away.

Cathy or Dankelt, can you tell me how to call those pcAnywhere functions in VB to connect to the host, transfer a file, and execute an application on the host computer? I've gotten as far as creating the object variables and creating the RemoteDataManager object, but I can't find any sample code for running things like "awConnect()", "FileXFerToHost()", or "ExecuteHostFile()". Nothing I've tried has worked.

I hope you can help me with this. Thanks very much!
 
Well, first thing you have to do is add OLE Automation, winawsvr, Microsoft Scripting Runtime, and AWREM32 references in your VB Project. Here is some code that should connect to a host, send a file to the host, then execute the file on the host. Let me know if you have any questions about it...

Dim Remote As Object

Private Sub Main ()
Set Remote = CreateObject("Awrem32.Application")
Dim Host, HostData, RemoteData as String
Dim WentOK as Boolean


Host = "c:\some_directory\some_host.chf"
RemoteData = "c:\myfiles\myfiletosend.exe"
HostData = "c:\received_files\myfiletoreceive.exe"

' Connet to the Host:
WentOK = Remote.awConnect(Host)

If WentOK = False Then
'Do something?? Message, or Log??
Else
'Do something else... or nothing
End If


' Send the file
WentOK = Remote.FileXferToHost(HostData, RemoteData)

If WentOK = False Then
'Do something?? Message, or Log??
Else
'Do something else... or nothing
End If

' Execute the file on the host
WentOK = Remote.ExecuteHostFile(HostData)

If WentOK = False Then
'Do something?? Message, or Log??
Else
'Do something else... or nothing
End If

' Disconnect from the host
WentOK = Remote.awDisconnect()

End Sub
 
Hey thanks, Dankelt. Works perfectly. This is a great site. It's strange that the pcAnywhere CD gives sample code for messing around with settings and so on but none for these functions which you'd think are the basic things people would want to do.

Thanks again!
Marty
 
I have create this code. But all the time when the modem started to answser to the other side. The modem will disconnect and close ther program. What's the problem on me? Thanks

Private Sub Form_Load()

Dim Remote As Object

Private Sub Main()

'Form1.Visible = False

Set Remote = CreateObject("Awrem32.Application")
Dim Host, HostData, RemoteData As String
Dim WentOK As Boolean

Host = "c:\program files\symantec\pcanywhere\Test.chf"
RemoteData = "c:\AutoTran\dayend.dat"
HostData = "c:\pos\dayend.dat"

' Connet to the Host:
WentOK = Remote.awConnect(Host)

WentOK = Remote.FileXferFromHost(HostData, RemoteData)

' Disconnect from the host
WentOK = Remote.awDisconnect()

End Sub

End Sub
 
I have hit this problem also. The problem is the fact that Remote.awConnect(Host) doesn't wait for the connection to be established. What I did to work around it is put the script into a loop, checking the connection status every 10 seconds.

Here is my pause function:
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.
End Function



'And here is the code to connect to the host:
Set Remote = CreateObject(&quot;Awrem32.Application&quot;)
Dim con, cnt As Integer
Dim Host as String
Dim WentOK as Boolean
Dim fso As New FileSystemObject, log As TextStream 'Create Log File

Set log = fso.CreateTextFile(&quot;c:\temp\my.log&quot;, True)

Host = &quot;c:\myhost.chf&quot;

WentOK = Remote.awConnect(Host)

If WentOK = False Then
log.WriteLine (&quot;ERROR: Couln't connect to host &quot; + Host)
End
Else
log.WriteLine (&quot;Connected to host &quot; + Host)
End If

cnt = 0
con = 0
Do Until con = 1
cnt = cnt + 1
Pause
Select Case cnt
Case 1
con = Remote.ConnectionStatus
Case 2
con = Remote.ConnectionStatus
Case 3
con = Remote.ConnectionStatus
Case 4
con = Remote.ConnectionStatus
Case 5
con = Remote.ConnectionStatus
Case 6
con = Remote.ConnectionStatus
Case Else
log.WriteLine (&quot;ERROR: Could not establish connection to the host!&quot;)
End
End Select
Loop



 
Hi, Dankelt, Thanks a lot. It's working fine now. Thanks again. : )
 
I am not able to create AWREM32.APPLICATION object in
DELPHI 3.0. I Have installed PCAnywhere 8.02.

Plz Help
 
Million Thanks Dankelt, I am using 10.5 now with Delphi. Trying out File Transfers and maintaining the Log. AwConnect returns True even if it didnt connect. ConnectionStatus Property is more safe i guess.

 
When i am trying to run command on host, The result returns True but actually the Command is not executed.

I am trying to Move the Files to be transfered from host to a Temporary Folder & using FileXferFromHost Transfering files to remote and Deleting the files in the Temporary Folder after Successfully Transmitting the files.

Plz Helpp !!!!!!!!!!!!!!.

Following is the Code i am using.

strCommand = &quot;Move C:\FILEXFR\OUTHO\*.* C:\FILEXFR\TMP\&quot;
bResult = V.ExecuteHostFile(strCommand)

 
You cannot specify any command line options with ExecuteHostFile. So all you are really running is the command Move. What I did to work around this problem is create a batch file that does the move command, send the batch file to a temp folder on the host, and then Execute the batch file on the host. I don't know of any other way to do this, PCAW 10 AWREM support is pretty weak.
 
Hi, Dankelt, Thanks a lot Again !!. I just wish I could not rely on batch files.

Thanks for you help.

 
Hi, Dankelt,

FileXferFromHost Can only Transfer File By File. In Earlier version of PCAnywhere 8.02, Scripts used to work fine except for the AWREM32 not getting unloaded (destroyed) from the memory.

AutoTransfer Option Does not allow any other commands after the File transfer is done. Otherwise life would have been simpler.

my following code doesnt work (V is the Ole Object)

V.FileXferFromHost('C:\FILEXFR\OUTHO\*.*','C:\TEMP\');


Help !!!!!!

Thanks in Advance.



 
Try this:

V.FileXferFromHost('C:\FILEXFR\OUTHO\*.*','C:\TEMP\*.*');
 
Hi Dankelt

It Doesnt Work. Does your VB application running smoothly?
My Goal is sending N receiving files automatically from around 10 locations. Once the file transfer is done sucessfully, the files has to be moved to a backup folder.

I wish to keep a log of files being sent and received.

Plz Help.. OLE Automation is makin me sick......

Thanks in Advance.





 
edwinj, My app sends and received multiple files using wildcards without any problems. I'm not sure why yours isn't working. Does it only not work when you use wildcards?
As far as logging goes, you are on your own here. I am not a Delphi programmer, so I can't tell you how to do this. I am doing it in my VB app though. It will just be a matter of opening a file, and writing to it. It shouldn't be to difficult. Sorry I can't be of more help...
Let me know how it goes!

Regards...
Dan
 
Hello Cathy or Dankelt or anyone else,
This is the first time I ask for help via a forum.
My office used for some years pcAnywhere 9.2 with scripts to perform datatransfer from the remote PC to the host.
Now we have to use version 10.5 because version 9.2 doesn't support Windows XP. So I have to write the scripts in a very short time in C++.
I have read the answer of Dankelt (sept. 8, 2002), code for VB (sending a file to the host, execute the file on the host pc).
Can anyone help me to start in the same way in C++, creating a scriptfile or application to perform several tasks on the other PC.
I hope I will get an answer soon. Thanks very much.

Gertruus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top