View Single Post
  #1 (permalink)  
Old June 26th, 2014, 06:01 AM
muditvb muditvb is offline
Registered User
 
Join Date: Jun 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.
Reply With Quote