windowsbatch-filevbscriptcmdtivoli

VBScript and PSEXEC - Remotely Executing Application


I am updating an existing HTA application. The page displays records of each machine in the company that hasn't performed a backup (Via ibm tsm) within the last 3 days. I have made a button for each record that when pressed, should execute a cscript process using PSEXEC that run an exe on the target machine and passes an argument. (dsmc.exe INCREMENTAL) Now i can manually open a cmd prompt, use the \Remote cmd command to create a remote cmd, and run the application just fine. But without the extra step of creating a remote cmd prompt, and trying to

PSEXEC \\RemoteMachine cscript.exe "C:\Program Files\tivoli\tsm\baclient\dsmc.exe" INCREMENTAL

Only results in an error. I know that it should be possible to remotely execute this program and still pass in an argument but it just doesn't run. And when i create the remote cmd prompt using

PSEXEC \\RemoteMachine cmd

Any other lines in the execution script do not execute until i exit the remote cmd prompt.

Is there a secret to PSEXEC i don't understand or a way to grab an existing cmd prompt (The remote one i just created) and pass it the command to execute? Please Help

*Note, this is not my first script using PSEXEC. I typically use my VBScript to create a batch file locally with the PSEXEC Script contained, and then execute it. Never have been able to get wsshell.run to work with PSEXEC.


Solution

  • Here is (more or less) my syntax for using objShell.Run to work with psexec:

    Set objShell = CreateObject("Wscript.Shell")
    objShell.Run "cmd.exe /c ""%pathToPsexec%\psexec.exe"" -accepteula -s -i -d \\RemoteMachine cmd.exe /k ipconfig",0,True

    This is just an example, but shows that you can send nested switches, etc. It's also important to understand the switches of psexec.

    -accepteula - this accepts the license agreement on psexec. this isn't necessary unless you're running it for the first time and you want it to be quiet.
    -s - runs as the System account of the remote computer. If you don't use this, you need to specify -u and -p if you want to run interactively. Otherwise your credentials perform a network logon
    -i - specifies to run interactively. This can be omitted or a session can be specified.
    -d - don't wait for the remote command to finish before moving on