Delete System environment Variable
Dear experts,
I'd like to delete active System environment Variable "TZ" which was set by other application. So, I made a vbscript as following
But this script works well in dos command but doesn't work inside package.
and I made another Vbscript as following. it works well in dos command but doesn't work either with MSI
Can someone advise me? I am using installshield 11.5
Thanks in advance
I'd like to delete active System environment Variable "TZ" which was set by other application. So, I made a vbscript as following
But this script works well in dos command but doesn't work inside package.
DIM objShell
set objShell = wscript.createObject("wscript.shell")
objShell.Run "%COMSPEC% /C ", 0, TRUE
objShell.Run "reg DELETE ""HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"" /v TZ /f", 0, TRUE
and I made another Vbscript as following. it works well in dos command but doesn't work either with MSI
On Error Resume Next
const HKLM = &H80000002
strKeyPath = "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
strStringValueName = "TZ" '
strComputer = "."
set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
Return = objReg.DeleteValue(HKLM, strKeyPath, strStringValueName)
Can someone advise me? I am using installshield 11.5
Thanks in advance
0 Comments
[ + ] Show comments
Answers (5)
Please log in to answer
Posted by:
anonymous_9363
15 years ago
OK, a few points:
- The first script fails because you can't use the 'WScript' directive in Custom Actions that run 'inside' the WI engine (as opposed to being exracted and run as a normal script). The engine uses its own interpreter, whereas the 'WScript' directive is unique to Windows Scripting Host. Thus:
- The second script looks OK. You have error-trapping set to 'Resume Next' so add some code to check that a) objReg got created (using 'IsObject(objReg)') and whether the 'DeleteValue' method worked by checking the content of Err.Number
- Why not simply use the RemoveRegistry table?
- The first script fails because you can't use the 'WScript' directive in Custom Actions that run 'inside' the WI engine (as opposed to being exracted and run as a normal script). The engine uses its own interpreter, whereas the 'WScript' directive is unique to Windows Scripting Host. Thus:
set objShell = wscript.createObject("wscript.shell")
should be changed to:set objShell = createObject("wscript.shell")
Note that this only applies to the directive, not object names/Prog IDs (e.g. "WScript.Shell")- The second script looks OK. You have error-trapping set to 'Resume Next' so add some code to check that a) objReg got created (using 'IsObject(objReg)') and whether the 'DeleteValue' method worked by checking the content of Err.Number
- Why not simply use the RemoveRegistry table?
Posted by:
MSIPackager
15 years ago
- Why not simply use the RemoveRegistry table?
Why not even more simply use the Environment table? http://msdn.microsoft.com/en-us/library/aa368369(VS.85).aspx since that's what it's there for.
Cheers,
Rob.
Posted by:
anonymous_9363
15 years ago
Posted by:
faithkim
15 years ago
Thanks for advices :)
In fact I tried environment variable table but it doesn't work. and I found strange sympthom.
I was deleting system environment variable in MSP (patch) using command
--> msiexec /p xyz.msp /qn and it never succeeded to remove variable set by original package.
However when I made a small package MSI and run command
--> msiexec /i abc.msi /qn and it seems to work well and I don't need any CA.
Is there anything you can advise? or any place to check?
Thanks once again.
In fact I tried environment variable table but it doesn't work. and I found strange sympthom.
I was deleting system environment variable in MSP (patch) using command
--> msiexec /p xyz.msp /qn and it never succeeded to remove variable set by original package.
However when I made a small package MSI and run command
--> msiexec /i abc.msi /qn and it seems to work well and I don't need any CA.
Is there anything you can advise? or any place to check?
Thanks once again.
Posted by:
anonymous_9363
15 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.