WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.


Process ID

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

tRemoteConn Issue


I have the following in my script (it is not done yet, but is enough to display the error code).
done = @FALSE
While !done
ErrorMode (@OFF)
tRemoteConn(StrCat("\\", hostname))
ErrorMode (@CANCEL)
Display(2, err, err)
I am always getting an error code returned of -2147481648. Is this correct? I was expecting a 0.

I am using Process Extnder version 10013.


The PDH error 2147485648 indicates PDH_CSTATUS_NO_MACHINE Unable to connect to specified machine or machine is off line. You might want to add code to handle for this possiblity, that breaks out of the while loop after so many attempts...

User Reply:

yes, I know it is in an infinite loop right now. that is so I can test it. ok, the error being that the machine is offline makes since because when this script starts running, that is the state of the machine. it is rebooting. Problem is, once the machine comes up, it continues to give that same error. It never releases that error code.

If I keep that code running in its loop, and execute the code a second time, that second one returns a 0, but the other one continues to produce the 214...... error.

why does the first one not release the error or continue to not connect?


I decided to set up a test environment to test the script you posted using the version 10013 of the Process Extender.

I think I tracked down the issue. Basically the problem is that the tRemoteConn function merely calls the PdhConnectMachine API to handle the remote connection. The PdhConnectMachine function connects to the specified computer, and creates and initializes a computer entry in the PDH DLL.

Once the PdhConnectMachine function successfully connects, any subsequent calls in that script to the PdhConnectMachine function don't query the status of the remote machine. A good connection is assumed.

In short the tRemoteConn function cannot be used to query the status of the remote machine. Maybe use a Ping command instead.

Here are the results of my tests:

Test #1:

Remote System OFF
tRemoteConn = 0 | tGetLastError = 2147485648

Remote System RESTARTED (Note: There is quite a delay before results update)
tRemoteConn = 1 | tGetLastError = 0
Test #2:
Remote System ON
tRemoteConn = 1 | tGetLastError = 0

Remote System SHUTDOWN 
tRemoteConn = 1 | tGetLastError = 0
As you can see, Test #2 never picks up the fact that the remote system was shut down. I believe this is simply how the PDHConnectMachine function works. Note: The PDH library offers a function called PdhEnumMachines that apparently returns a list of the names of the computers that have been opened previously by the PDH DLL. Its possible that you could call this function to determine if the system has already made a successful connection. However the current version of the Process extender doesn't contain this functionality. Also I am not sure that will help you accomplish what your looking to do.

I recommend using one of our Ping function to ping the machine to see if its available on the network...

Article ID:   W16853
File Created: 2017:07:28:13:58:40
Last Updated: 2007:07:03:14:26:35