Answered vbs - psexec - remote processes

  • Wednesday, September 05, 2012 12:33 PM
     
     

    Hi

    Here is my problem, when i execute a script to be run remotely using the -d switch in psexec if it works it returns the PID of the remote process. However if it fails due to an error (e.g. account does not have rights) it returns an error code.

      cmd1 = "psexec \\" & ComputerString & " -d -h -u " & userID1 & " -p " & password1 & " cscript.exe /T:7200 \\unc_path-to.vbs"

      returnCode = objShell.Run (cmd1,1,TRUE)
      if  returnCode <> 0 Then

    >> So as both are +ve integers, how can i capture an error running the script, from the pid of the script?

    I need to use the -d (async mode) because the vbs can take up to an hour to run and it is being run on many machines.

    NB: I captured   Err.Number and this returns 0 in both cases

    Thanks


All Replies