Archive: Setting a reg key with variables? And calling with batch?


Setting a reg key with variables? And calling with batch?
Here's what my script uses to find someone's game directory (this is an automatic addon installer)

Function .onInit

Call GetSteamAccountName
Pop $R0 ; CaDDy-
Pop $R1 ; E\Games\Steaaam

# Check if Steam is installed
StrCmp $R0 "" 0 +3
MessageBox MB_OK|MB_ICONSTOP $(SteamNotInstalled)
Abort

# It is installed so set INSTDIR
StrCpy $INSTDIR "$R1\SteamApps\$R0\garrysmod\garrysmod"
The "$R1\SteamApps\$R0\garrysmod\garrysmod is what i want written to a registry key.

This brings me to the second question, is it possible to call up a registry key as a variable in a batch file? If so, how would I do so?

Use ReadReg* and WriteReg* all of which are in the documentation. You could read a value in NSIS and pass it via the batch's command-line. However, what can you do in a batch that you cannot do in NSIS?

Stu


Originally posted by Afrow UK
However, what can you do in a batch that you cannot do in NSIS?

Stu [/B]
svn checkout and svn export :P

edit

So something like "WriteReg HKLM\Software\UltimateGmodPack\GmodInstdir "$R1\SteamApps\$R0\garrysmod\garrysmod\" will write the actual values in on the key and not just the $R1 and $R0?

Also, if i could just use NSIS to set an environment variable, that would make things much easier.


I'll let you do a search for that one.

Stu


I see nothing in the documentation on SETTING an environment variable, only the ones that NSIS uses.


There's also this forum you can search as well as the Wiki.

Stu


Okay I've done searching, now why doesn't this work?

Function .setReg
WriteRegStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "GMOD_DIR" "$R1\SteamApps\$R0\garrysmod\garrysmod"
FunctionEnd

What does the registry look like after calling the function?

Also, you might add a message box in your function function as a debug tool to see that $R0 and $R1 are set properly.


In what way does it not work? Are you calling the function? The . in front of the name does not make it get called automatically.

Stu


After compiling and running the installer, the GMOD_DIR entry IS MADE IN THE KEY properly, with $R0 and $R1 set and everything.

But when i go to command prompt and type %GMOD_DIR% it tells me that environment variable GMOD_DIR is not defined (though i'm LOOKING AT IT in regedit.exe

any ideas?