Link to home
Start Free TrialLog in
Avatar of abendv_10
abendv_10

asked on

setting environment variables using VB

Hello,
We are thinking to migrate one of our file & print server from NetWare to Windows 2003.
In the NetWare Logon script we set a search drive which contain some batch files, exe files etc..
I like to understand how can I add path to environment using vb script.
by the way, in windows 2003, if I want to let users to run batch files from this drive, is that the way to do it ?

Thanks.

Adi.
Avatar of vinnyd79
vinnyd79

If you are looking to add a path to the existing Path environment variable then try this.Add this to a text file with a .vbs extension:

Dim objShell,objEnviron
Set objShell = CreateObject("Wscript.Shell")
Set objEnviron = objShell.Environment("System")
objEnviron.Item("Path") = objEnviron.Item("Path") & ";C:\MyPath"

Set objEnviron = Nothing
Set objShell = Nothing
Avatar of abendv_10

ASKER

Hi vinnyd79,
It works but I have two problems.
1.This script add the path  ";C:\MyPath" Everytime I logon in addition to the same path that allready exist from the last logon. then the Environment variables PATH has more and more ";C:\MyPath".

2. To execute this script the users must be Administrators on the Machine. In Terminal Server Environment it is a big
problem.


Correct me if I worng.

any way you helped me and I give you the points.
I will be hapy for more advices.

Adi.
ASKER CERTIFIED SOLUTION
Avatar of vinnyd79
vinnyd79

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The Error is "Permission denied"
                   code: 800A0046