Mittwoch, 23. Januar 2013

PATH manipulation via VBS or JavaScript

Sometimes it is not possible to edit the PATH variable on your Computer. - In my case the admin blocked the panel - but my user has sufficient rights to do so.
Be carefull. Do save your Environment variable somewhere in a textfile.
It is possible to damage your system.

You can call the script with the cscript scripting host.
Don't forget to reopen a new Shell to see the result of your effort.
The current Command-Shell does not show any differece

the following script is in VBScript. But you can translate it easily to Javascript.
'************************************************************
'* Modifying The System Path With New Entries *
'************************************************************
Dim ExistingPath, NewPath
Set oShell = WScript.CreateObject("WScript.Shell")
Set oEnv = oShell.Environment("SYSTEM")

'************************************************************
'* Add your Path Entry Here *
'************************************************************
ExistingPath = oEnv("PATH")
NewPath = ExistingPath & ";" & "C:\ADD SOME PATH HERE"
oEnv("PATH") = NewPath 'WRITE NEW PATH, INCLUDING OLD ONE

Keine Kommentare:

Kommentar veröffentlichen