script to add path to path
This script is designed to modify the registry key for the path, the first thing is to read the current value and save it to a variable, then remove the current key and creates a new one with the required modification
---------------------- ITPROSBOGOTACOLOMBIA'--------------------
'---- --------------------- --------------- THE RPROGRAMADOR CHANGO
'--------- ROUTE ADD TO PATH ----------- ---------------------
'read registry key and stored in the variable strValue
Const HKEY_LOCAL_MACHINE = & H80000002
'The script is running on the local machine
strComputer = "." September
Oreg = GetObject ("winmgmts: {impersonationLevel = impersonate}! \\ \\" & StrComputer & "\\ root \\ default: StdRegProv")
'Key for the path
strKeyPath = "SYSTEM \\ CurrentControlSet \\ Control \\ Session Manager \\ Environment "
strValueName = "Path"
'Capture the current value
oReg.GetExpandedStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
' Delete value of the registry key HKEY_LOCAL_MACHINE oReg.DeleteValue
, strKeyPath, strValueName
'Create path
updated addToPath = inputbox ("Enter the route to add the path: "" The Change Program - ITPBC) oReg.SetExpandedStringValue
HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue &";"& addToPath
0 comments:
Post a Comment