set environment variable path 
Author Message
 set environment variable path

I want to set the environment variable path in a wsf script and it should do
somehting like this:

set path %path;p:\...test\test\

How should it look in scripting??



Sun, 26 Sep 2004 21:36:53 GMT  
 set environment variable path

Quote:
> I want to set the environment variable path in a wsf script and it should do
> somehting like this:

> set path %path;p:\...test\test\

> How should it look in scripting??

Three questions:

What OS?

Do you want it to be active after your script has terminated?

Do you want it to be permanent (survive a reboot)?

--
torgeir



Sun, 26 Sep 2004 22:00:28 GMT  
 set environment variable path


Quote:

> > I want to set the environment variable path in a wsf script and it
should do
> > somehting like this:

> > set path %path;p:\...test\test\

> > How should it look in scripting??

> Three questions:

> What OS?
Win2000
> Do you want it to be active after your script has terminated?
no
> Do you want it to be permanent (survive a reboot)?
no
> --

thnx in advance


Sun, 26 Sep 2004 22:29:15 GMT  
 set environment variable path
Here's one way to do it if you want the path to be reset after the script
completes.

Dim WshShell
Dim WshSysEnv

Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("SYSTEM")

WshSysEnv("PATH") = WshSysEnv("PATH") & ";C:\TEST\"

MsgBox WshSysEnv("PATH")

Gordon Bell




Quote:

> > I want to set the environment variable path in a wsf script and it
should do
> > somehting like this:

> > set path %path;p:\...test\test\

> > How should it look in scripting??

> Three questions:

> What OS?
Win2000
> Do you want it to be active after your script has terminated?
no
> Do you want it to be permanent (survive a reboot)?
no
> --

thnx in advance


Sun, 26 Sep 2004 22:53:16 GMT  
 set environment variable path

Quote:


> > What OS?
> Win2000
> > Do you want it to be active after your script has terminated?
> no
> > Do you want it to be permanent (survive a reboot)?
> no

This will set an environment variable for the script and all it programs it
calls. It will only apply to the current session("Process") and it's subsequent
child processes.

Set WshShell = CreateObject("WScript.Shell")
Set WshProcessEnv = WshShell.Environment("Process")

sCurrPath = WshProcessEnv("PATH")

sAddOn = "p:\test\test\"

If Right(sCurrPath, 1) = ";" Then
  sNewPath = sCurrPath & sAddOn
Else
  sNewPath = sCurrPath & ";" & sAddOn
End If

' Set the environment variable
WshProcessEnv("PATH") = sNewPath

--
torgeir



Sun, 26 Sep 2004 23:05:16 GMT  
 set environment variable path

Quote:

> Here's one way to do it if you want the path to be reset after the script
> completes.

> Set WshShell = WScript.CreateObject("WScript.Shell")
> Set WshSysEnv = WshShell.Environment("SYSTEM")

Ehh, SYSTEM is permanent.

--
torgeir



Sun, 26 Sep 2004 23:22:43 GMT  
 set environment variable path
Thnx it's working!!!


Quote:



> > > What OS?
> > Win2000
> > > Do you want it to be active after your script has terminated?
> > no
> > > Do you want it to be permanent (survive a reboot)?
> > no

> This will set an environment variable for the script and all it programs
it
> calls. It will only apply to the current session("Process") and it's
subsequent
> child processes.

> Set WshShell = CreateObject("WScript.Shell")
> Set WshProcessEnv = WshShell.Environment("Process")

> sCurrPath = WshProcessEnv("PATH")

> sAddOn = "p:\test\test\"

> If Right(sCurrPath, 1) = ";" Then
>   sNewPath = sCurrPath & sAddOn
> Else
>   sNewPath = sCurrPath & ";" & sAddOn
> End If

> ' Set the environment variable
> WshProcessEnv("PATH") = sNewPath

> --
> torgeir



Tue, 28 Sep 2004 20:24:02 GMT  
 set environment variable path

Sorry, I didn't notice that...


Quote:

> Here's one way to do it if you want the path to be reset after the script
> completes.

> Set WshShell = WScript.CreateObject("WScript.Shell")
> Set WshSysEnv = WshShell.Environment("SYSTEM")

Ehh, SYSTEM is permanent.

--
torgeir



Tue, 28 Sep 2004 05:52:17 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Set path environment

2. how to set PATH (environment) using WSH?

3. Expanding SYSTEM %PATH% with embedded SYSTEM environment variable problem

4. cscript and the PATH-environment variable

5. Building paths with environment variables

6. Environment variable PATH

7. Error in changing the Path Environment variable

8. Increase length of system Path environment variable?

9. How to set a DOS environment variable

10. How do SET a DOS environment variable

11. How set an environment variable with vbscript?

12. Set environment variable and lcaunch an application

 

 
Powered by phpBB® Forum Software