Old 7th July 2008, 23:28   #1
-Gamah
Junior Member
 
Join Date: Jul 2008
Posts: 6
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)

Quote:
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?
-Gamah is offline   Reply With Quote
Old 8th July 2008, 13:31   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Old 8th July 2008, 16:19   #3
-Gamah
Junior Member
 
Join Date: Jul 2008
Posts: 6
Quote:
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?
-Gamah is offline   Reply With Quote
Old 8th July 2008, 16:41   #4
-Gamah
Junior Member
 
Join Date: Jul 2008
Posts: 6
Also, if i could just use NSIS to set an environment variable, that would make things much easier.
-Gamah is offline   Reply With Quote
Old 8th July 2008, 16:42   #5
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
I'll let you do a search for that one.

Stu
Afrow UK is offline   Reply With Quote
Old 8th July 2008, 17:06   #6
-Gamah
Junior Member
 
Join Date: Jul 2008
Posts: 6
I see nothing in the documentation on SETTING an environment variable, only the ones that NSIS uses.
-Gamah is offline   Reply With Quote
Old 8th July 2008, 18:24   #7
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
There's also this forum you can search as well as the Wiki.

Stu
Afrow UK is offline   Reply With Quote
Old 8th July 2008, 19:48   #8
-Gamah
Junior Member
 
Join Date: Jul 2008
Posts: 6
Okay I've done searching, now why doesn't this work?

Quote:
Function .setReg
WriteRegStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "GMOD_DIR" "$R1\SteamApps\$R0\garrysmod\garrysmod"
FunctionEnd
-Gamah is offline   Reply With Quote
Old 8th July 2008, 20:00   #9
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
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.
Comperio is offline   Reply With Quote
Old 8th July 2008, 20:27   #10
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Old 8th July 2008, 20:40   #11
-Gamah
Junior Member
 
Join Date: Jul 2008
Posts: 6
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?
-Gamah is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump