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

Refresh / Reload PATH while executing script... 1

Status
Not open for further replies.

PScottC

MIS
Mar 16, 2003
1,285
US
I'm having a problem with a script which installs some software (among other things). Once the new software is installed, the script calls a configuration batch file provided with the software. Unfortunately, the batch job fails because it expects its application to be in the system's PATH, but because the batch is run under the process of the script, the new path isn't visible.

Is there a way to make the script process aware of the new PATH?

Code:
Set oShell = CreateObject("Wscript.Shell")

oShell.Run "msiexec /passive /i somemsi.msi"

oShell.Run "batchscript params" [red][b]<-- Broken Here[/b][/red]



PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
You can make change of the current directory to the "system's path" (whatever it means) or to that effect whatever path appropriate before calling the batchscript like this.
[tt]
oShell.Run "msiexec /passive /i somemsi.msi"
[blue]oShell.currenddirectory="c:\somesystempath"[/blue]
oShell.Run "batchscript params"
[/tt]
Or nothing holds you back from assigning a path to the batchscript. But it is not clear what is what.
 
In this particular case I'm doing a silent install of ActiveState Perl. When the install completes, I need to run the PPM command to install some custom modules. As far as I can tell, the PPM command is actually a script which must then be run by the Perl interpreter.

So... In the course of the Perl install, it adds itself to the path. The problem is that when I call PPM using oShell.run (even if I use the explicit path to PPM), PPM fails to call the Perl interpreter because it doesn't know where it is. If I do a
[blue]wscript.echo oShell.ExpandEnvironmentStrings("%path%")[/blue]
I see the old path, without the Perl path appended to it.

How do I modify the path for the current process (i.e. the script doing the install), without modifying the user or system environment?

I don't have the script in front of me right now, but I will try your suggestion about changing the working directory of the running process, and see if that fixes the issue.

Thanks!

PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
You can try:
[tt] oShell.currentdirectory="c:\perl\bin"[/tt]
if you install the perl to c:\perl. ppm in this instance stands for ppm.bat which in turn call perl with perl.exe in the system search path. If that c:\perl\bin is not added or added by not yet broadcast, you can do the currentdirectory above so it would be found no problem.
 
Makes sense. I'll give it a shot on Monday and let you know.


PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
Thanks Tsuji! The solution you suggested worked. Have a star.

PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top