1 Reply Latest reply: Jun 26, 2014 12:10 PM by Fernando Obara Suzuki RSS

    How to gather output to a text file or a variable running psexec from vbscript?

      I've written a function which obtains UNC path from entered DFS path from remote computer by running dfsutil within psexec (dfsutil diag viewdfspath).
      But the problem is, the output gets displayed on a command prompt on my computer which I am unable to export (pipe) to any file or a variable.
      Below is the function which I have written:
      Function actiongetuncpath(remoteComputer)
      Dim retVal: retVal = False
      Set objShell = CreateObject("WScript.Shell")
      Command = "psexec -s \\" & remotecomputer & " dfsutil diag viewdfspath " & dfspath
      objShell.Run Command


      Log " !! Successfully executed get UNC path command on " & UCase (remotecomputer) , True, "dfspath", 1


      actiongetuncpath = retVal
      End Function


      'dfspath - variable that stores entered DFS path
      I have tried Command = "psexec -s \\" & remotecomputer & " dfsutil diag viewdfspath " & dfspath & ">C:\output.log"


      but it does not work giving error 87 in dfsutil.
      Using the same command locally will work but not remotely.


      Could anyone help me on this?
      I need to either export the output obtained in a txt / log file or to any variable which I can pipe to output screen.