Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Variable using WshShell.Run(...

Status
Not open for further replies.

donkmoore

IS-IT--Management
Jul 31, 2002
1
US
I am fairly new using vbscript and I having a problem. I am writing a .asp pages that uses VBScript to gather the uptime on numerous servers. I cannot get the results of a WshShell.Run command to pass to a variable. I am not sure if this is even possible, but would appreciate the help?

Here is the command that I am using. I have already setup the array to read each server in and it is working fine, but this command doesn't work.

set WshShell = CreateObject("WScript.Shell")

set oUptime(count) = WshShell.run ("\\hqapp22\d$\scripts\uptime.exe" &srvr, 8,true)

I see the results pop-up in the command prompt window and then send the variable to a message box and only get "0" for my results.

Is this possible or am I just making a stupid mistake.

Thanks,
Don
 
donkmoore,

You need a space between the command and the server variable
Try this first.

set oUptime(count) = WshShell.run ("\\hqapp22\d$\scripts\uptime.exe " & srvr, 8,true)


fengshui_1998
 
Did this work?

I think that WshShell.run is supposed to return an error code and not the results of the uptime.exe process. If this is true then the above example won't work.

I am trying to do something similar, and I want to get back the results of the executed command. How?
 
No, this didn't work. I ended up having to run a batch file and having the contents dumped to a text file. Then I had to read the contents in my script and proceed from there.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top