From MicroFocusInternationalWiki
Revision as of 09:12, 30 September 2005 by Pspencer (Talk | contribs) (Permanent environment variable change)

Jump to: navigation, search

Got a nagging question you'd like to get help from the community about? That, my friend, is the very reason the Cool Solutions Wiki was started. Come on in, post your question, and see who pops forth with an article about it.

I took the liberty of posting some previously Novell internal notes and guides on ZENworks on my [Evil ZEN Scientist blog].

While I'm at it - who else blogs or writes about ZENworks?

Blogging about ZENworks

How about a Cool Solutions for the following that still plague me:

  1. Automatic uninstall of Microsoft Client for Windows Networks
  2. Automatic uninstall of File/Printer sharing, Win XP

Permanent environment variable change

I am trying to update the Path environment variable on Windows 2000 machines through Zenworks. I want the changes to be permanent. I need to delete one path, and add two more. I have tried making an application object and putting the two paths to be added in the 'Environment variables' section - appending to the 'Path' variable with a ; separator. I checked the Path value, and it had not been updated. Any thoughts on how this can be done? Thanks!

The Microsoft setx.exe utility, which have from the Windows NT 4.0 resource kit, allows you to change an environment variable from a command line such that it will survive a reboot. The version I have (1.0a 5/31/96) appears to work fine on Windows XP Tablet SP2 and Windows 2000. However, it does appear that it was also part of the Windows 2000 resource kit, and you can download it from http://www.microsoft.com/windows2000/techinfo/reskit/tools/existing/setx-o.asp

After you have the utility, you could have a NAL object execute something like
setx Path %Path%;newpath1;newpath2
to do what you requested.

Another suggestion: A good solution (which is quick and safe) is to run a VBS script to modify the path in the registry. I suspect that the Windows NT/2000 utilities have been dropped from the Resource Kit because they are no longer needed now that WSH is included with XP. I have been using this for while now and have found that setting the registry is both immediate and is retained. Note that you can choose to either set the User or the System path, depending on the user rights, and also the needs of the application. I would also include logic in the code to audit the path and remove any redundant entries etc. The code would be a little more complex but I think it is worth the effort.
The following sample code shows the synxtax for reading and writing the registry.
' ReadSetPath.vbs
' Abstract: VBSript to read/Set PATH environment(s), both USER and SYSTEM.
' Version : 1.0 - Initial draft.
Dim objShell, strSystemPath, strUserPath, rCode, strNewPath

Set objShell = CreateObject("wscript.shell")
strSystemPath = objShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path")
strUserPath = objShell.RegRead("HKCU\Environment\Path")

strNewPath = "C:\Temp"
rCode = objShell.RegWrite("HKCU\Environment\Path", strUserPath & ";" & StrNewPath, "REG_SZ")

wscript.echo "USER path = " & strUserPath & _
"System Path = " & strSystemPath