Re: Remove environment variable
From: Michael Harris \(MVP\) (mikhar_at_mvps.org)
Date: 01/07/05
- Next message: jong: "Re: can't get access to disk share when connecting from a remote s"
- Previous message: Al Dunbar [MS-MVP]: "Re: can't get access to disk share when connecting from a remote s"
- In reply to: stev379: "Remove environment variable"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 7 Jan 2005 14:30:26 -0800
stev379 wrote:
> Hello,
> The script below works to delete the value of the path, but not
> the path variable itself. Our machines have no User environment Path
> variable set, only the System Path variable. An altered version of
> the script below creates the Path variable and sets the value. I
> only need the path when I run a specific app and don't want to leave
> the path variable lingering. Is there a way to completely remove the
> Path user environment variable?
The WshEnvironment object has a Remove method...
Set colUsrEnvVars = objShell.Environment("USER")
colUsrEnvVars.Remove("PATH")
> I'm not married to this particular script. If there is a better way
> to perform this (or the action of creating the path variable to begin
> with, I'm open to ideas...preferably in vbs.
>
> 'Begin script
>
> Set objShell = WScript.CreateObject("WScript.Shell")
> Set colUsrEnvVars = objShell.Environment("USER")
>
> colUsrEnvVars("PATH") = colUsrEnvVars("")
>
> Wscript.Echo "Current User Path = " & colUsrEnvVars("PATH")
>
> 'End script
>
> Thanks for any help or suggestions.
> -Steve
-- Michael Harris Microsoft.MVP.Scripting
- Next message: jong: "Re: can't get access to disk share when connecting from a remote s"
- Previous message: Al Dunbar [MS-MVP]: "Re: can't get access to disk share when connecting from a remote s"
- In reply to: stev379: "Remove environment variable"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|