
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Maybe you have to enclose the dfspath in double qoutes? How do I resolve an access denied error in DFS when trying to show root?
Or maybe the user doesn't have permission to write in C:\ ?
