Archive: addtopath function doesnt add all_users


addtopath function doesnt add all_users
I made a booboo on my last installer than overwrote the allusers path so i need to make a patch for my future installer. so i only want to add it to the path if it isn't in there, that way it wont add multiple strings of it.

i want to add it to: HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"

in the beginning of the code i do this:

!define ALL_USERS

!include "WinMessages.NSH"
!include "AddToPath.nsh"


later on i do this:

Push "%SystemRoot%\System32\WBEM"
Call AddToPath

it doesn't add it into the environment variables.

what am i doing wrong?
would this check automatically if it isnt in the path already or do i need to use StrStr to search?

thanks

also when the program gets uninstalled i still want to keep the path change present as i overwrote a system path that is required by winders.


AddToPath checks if the path exists at all and if it already exists in the user's PATH variable. If the folder doesn't exist, or already present in PATH, it won't do anything.

Nothing will be done in the uninstaller unless you call un.RemoveFromPath.


okay...but i dont have "%SystemRoot%\System32\WBEM" in my path and it isnt being added.

i do have other entries in the path just not that.


%SystemRoot%\System32\WBEM is not a valid path, so it doesn't exist as far as AddToPath is concerned. You should use $SYSDIR or ExpandEnvStrings.


Oh Ho!!! Todah Rabah!!!!!!

But, i just re-ran the installer and now that string was added a second time so now i have two C:\windows\system32\wbem listed.


any idea? i am unsure how to use StrStr to check if it is there already though.


well i got around it doing it like this and it seems to work.

ReadRegStr $1 HKLM \
"SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path
Push $1
Push "wbem"
Call StrStr
Pop $R0

StrCmp $R0 "" true false

true:
; the item isnt here so add it now
Push "$sysdir\wbem"
Call AddToPath
Goto End

false:
;nothing to do today, hurray!
Goto End