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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WshShell.Run won't execute another program

Status
Not open for further replies.

Chewie71

MIS
Sep 4, 2001
89
US
Hello,

I've got a section of code below that I want to execute the WinXP SP1 install. I've tried mapping a drive as you see below...and also just using the straight UNC path. Neither works. For testing purposes, the script echoes out the current SP version, click OK and it should run the SP1 install (testing machine already has sp1, that's why it's checking to see if spver < 2), and finally echoes to the screen &quot;Installing SP1&quot;. It never starts the SP1 install however. I can run it manually by double clicking on it...and it warns me I already have SP1. But it will not start from my script. Any help would be appreciated.

Thanks,
Matt

' CHECK FOR XPSP1, INSTALL IF IT DOES NOT EXIST
Wscript.echo objItem.CSDversion
spver = Split(objItem.CSDVersion, &quot; &quot;)
Wscript.echo spver(2)
If CInt(spver(2)) < 2 then
WshNetwork.MapNetworkDrive &quot;I:&quot;, &quot;\\AC\INSTALL&quot;
WshShell.Run &quot;I:\Patches and Fixes\WinXP\SP1\XPSP1.EXE&quot;,1,true
Wscript.Echo &quot;Installing SP1&quot;
End If
 
Hello Chewie71,

[1] Seems fine the script. Show us objItem.CSDversion see if your split thing is OK.
[2] Your run bWaitOnReturn is true, so your echo would be &quot;SP1 installed&quot; or something. Otherwise, move the echo up before it actually installs.

regards - tsuji
 
Try this:
Code:
WshShell.Run &quot;&quot;&quot;I:\Patches and Fixes\WinXP\SP1\XPSP1.EXE&quot;&quot;&quot;,1,true
or this:
Code:
WshShell.Run Chr(34)&&quot;I:\Patches and Fixes\WinXP\SP1\XPSP1.EXE&quot;&Chr(34),1,true

Hope This Help
PH.
 
Yes, sure have to do what PHV suggests.

-tsuji
 
UglyBagOfWater, as the pathname to run contains embedded spaces we have to enclose them between quotes.
In VB, to insert a quote into a litteral constant you have to type them twice:
Code:
WScript.Echo &quot;Litteral with embedded &quot;&quot; as you see&quot;
An alternative is to use the Chr function and to know that the ascii code for a quote is 34:
Code:
WScript.Echo &quot;Litteral with embedded &quot; & Chr(34) & &quot; as you see&quot;

Hope This Help
PH.
 
something related...

i need to execute nslookup passing a file that contain a list of ip addresses and get another file with the result...

i tried this...

Public Const csIPList = &quot;C:\IPS.CFG&quot;
Public Const csResult = &quot;C:\RESOLVE.TXT&quot;

Dim lsCmd
lsCmd = &quot;nslookup <&quot; & csIPList & &quot; >&quot; & csResult

Dim WshShell, ReturnCode
Set WshShell = WScript.CreateObject(&quot;WScript.Shell&quot;)
ReturnCode = WshShell.Run(lsCmd,1,True)

...but nslookup try to resolve &quot;c:\resolve.txt&quot; instead de list of ips ....

in cmd prompt ...

nslookup <c:\ips.cfg >resolve.txt

...runs ok...

what it is wrong in the code...?????

thanks in advanced
 
Try this:
Code:
lsCmd = &quot;cmd /c nslookup <&quot; & csIPList & &quot; >&quot; & csResult


Hope This Help
PH.
 
yes... it works...

other thing... i'm using nslookup to find computername from ip address.... but many ips fails because dns server doesn't have any register of them...

there are some other way to find computer name having it's ip?

thanks in advanced
 
tutank, thanks for the feedback.
Your last post would get more response in an appropriate forum.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top