/bundles/itninjaweb/img/Breadcrumb_cap_w.png
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   [ - ] Hide Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
Answer this question or Comment on this question for clarity

Answers

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?
Answered 03/09/2009 by: VBScab
Red Belt

Please log in to comment
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.
Answered 03/09/2009 by: MSIPackager
Third Degree Black Belt

Please log in to comment
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.
Answered 03/09/2009 by: VBScab
Red Belt

Please log in to comment
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.
Answered 03/10/2009 by: faithkim
Senior Yellow Belt

Please log in to comment
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! :)
Answered 03/10/2009 by: VBScab
Red Belt

Please log in to comment