/build/static/layout/Breadcrumb_cap_w.png

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.

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)

Posted by: anonymous_9363 15 years ago
Red Belt
0
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: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
3rd Degree Black Belt
0
- 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
Red Belt
0
Good point, Rob. I'd forgotten that you can specify deletions there.

Also, @OP, you appreciate that, as the variable is a System-level one, a reboot will be required to clear it? This is one reason why I always use User-level ones when I can.
Posted by: faithkim 15 years ago
Senior Yellow Belt
0
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.
Posted by: anonymous_9363 15 years ago
Red Belt
0
I've never heard of a patch being used for that purpose. Their primary purpose is for updates to binaries (EXEs and DLLs).
...it seems to work well and I don't need any CA.

Is there anything you can advise?
Er, if it works, what else is there to do/advise? Just use the MSI! :)
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ