I don't get it. I actually made the launcher, even downloaded the template just today. I used the REGKEYS setting, and just removed the /D=2 switch. I ran the program like 4 times and the settings were saved/restored correctly.
Wraithdu, I finally got it working!!!! Figured out what was going wrong.
Firstly, in my regkeys section I was using "HKCU\..." for my regkeys and for some reason I can't restore to the registry when it's in this format(I don't know if this is specific to me). I double clicked the newly created Registry.reg and it said that it had loaded the info into the registry but it actually hadn't. So I changed the script to "HKEY_CURRENT_USER\..." and this Registry.reg worked.
Secoundly, I found that debugview would seem to startup and ask for the license agreement sometimes, even though the registry had my settings in it. So what I had to do was add a "sleep 100" to the end of where it restores the registry.reg in the template. Now it seems to work perfectly.
It would be interesting to know what you put in your regkeys section.
Cheers for all your help! I'm so glad I cracked it!
Rochey
I can't think of anything else really. I know that the Sleep times can make a difference, but I've never had a problem with Sleep 50 on any system I've tried. And I'm stumped why you can't use HKCU.
I thought you might be interested to know that I found a bug in v3.2 of the NSIS registry plugin. It's exactly what you mentioned - the short name HKCU is saved as just that in the REG file instead of being expanded to HKEY_CURRENT_USER.
HKLM does not seem to be affected. Check the Winamp forums to download v3.1 which does not have this problem.
Also in talking with the developer I've managed to get out of him which functions need Sleep time to function correctly. Only ${registry::RestoreKey} DOES NOT wait for the reg operation to finish before moving on in the script, meaning this is the ONLY plugin call that needs Sleep time to finish. This is because all it does is call 'regedit /s'.
So to work around this and be able to get rid of ALL your Sleep commands, use -
ExecWait 'regedit /s "file"'
Klonk can edit his template accordingly if he wishes to remove the Sleep commands and replace the RestoreKey call.
The 'newadvsplash::wait' call is never made, so the plugin DLL is left in the temp directory after launcher exit (if a splash screen is used). Should probably add in the Clean function -
You need to add it in the Clean function. Here's the whole thing for you.
Function Clean
StrCmp "$SECONDLAUNCH" "true" CleanEnd ; do not do anything if launched a second time
!ifdef DOREG | DOREGFILE
${registry::Unload} ; unload registry functions from, memory
!endif
!ifdef SPLASHIMAGE
StrCmp "$SPLASHSCREEN" "enabled" 0 CleanEnd
newadvsplash::wait
!endif
CleanEnd:
FunctionEnd
The app I had the splash problem with (TextPad4) was compiled using Portable application template version 1.8, so I had to fit your example code in, AND NOW it works correctly!!
New to using this template and making portable. I had previously used v2.0 for the one that I am trying to make a porta app, but with my software upgrade and using v2.1 I am receiving an error message.
Thank you for any help.
Error Message at end of compile:
---------------------------------------
MakeNSIS v2.30 - Copyright 1995-2007 Contributors
See the file COPYING for license details.
Credits can be found in the Users Manual.
Processing script file: "C:\Temp\ScottradeElite\ApplicationPortableTemplate.nsi"
!define: "AUTHOR"="Scottrader"
!define: "APP"="ScottradeELITE"
!define: "VER"="1.0.0.0"
!define: "EXE"="Scottrader.exe"
!define: "EXEPARMS"=""
Usage: !define ([/date|/utcdate] symbol [value]) | (/math symbol val1 OP val2)
OP=(+ - * / % & | ^)
Error in script "C:\Temp\ScottradeElite\ApplicationPortableTemplate.nsi" on line 36 -- aborting creation process
Settings from ApplicationPortableTemplate.nsi
--------------------------------------------------
; ----- Basic informations
!define AUTHOR "Scottrader" ; your name
!define APP "ScottradeELITE" ; insert application name, e.g. "TestApp"
!define VER "1.0.0.0" ; insert version of launcher
!define EXE "Scottrader.exe" ; insert program exe name, e.g. "testapp.exe"
!define EXEPARMS "" ; insert some default Parameters
; ----- Application specific stuff
; insert regkeys to use separated by "||", comment out, when not used,
; e.g. HKCU\Software
!define REGKEYS "HKEY_CURRENT_USER\Software\Scottrader" ""
; If a file "Registry.reg" within the data directory is found then it is read
; and all parent registry keys are processed as if they'd have been set within
; REGKEYS
; !define USEREGKEYSFILE "TRUE"
; delete alle defined registry keys before own ones are applied (during Init)
!define DELETEREGKEYS "TRUE"
; insert settings files to use separated by "||" as stored on the host
; computer, e.g. "$WINDIR\TEST.INI", comment out, when not used
; !define SETTINGSFILES ""
; insert settings directories to use separated by "||" as stored on the host
; computer, e.g. "$PROFILE\TEST", comment out, when not used
; !define SETTINGSDIRS ""
; Require local administrator rights to run the launcher, necessary when
; writing to e.g. HKLM registry key. If not required comment out
; !define ADMINREQUIRED "TRUE"
; Redirect Userprofile folder, comment out when your application calls other
; programs, i.e. to disable automatic redirection. Default value "TRUE".
!define REDIRECTUSERPROFILE "TRUE"
; When "TRUE" a launcher is created that contains the sources and copies them
; into the appropriate folder if they do not exist yet.
!define INSTALLSOURCES "TRUE"
; define which GTK version should be used, e.g. 2.0
; !define USEGTKVERSION ""
; define which JAVA version should be used, e.g. 1.6.0.10
!define USEJAVAVERSION "1.6.0.10"
; ----- Normally no need to change anything here
; format of portable name (dirs and filenames)
!define PNAME "${App}Portable"
; comment this line out when default icon should be used
; !define ICON "${PNAME}.ico"
; comment this line out when no splashscreen image should be used
; !define SPLASHIMAGE "${PNAME}.jpg"
; could be changed when settings for multiple applications should be stored in
; one INI file
; !define INI "${PNAME}.ini"
The previous removal of the extra "" allowed the compile to continue but there are other compile problems as follows:
[Excerpts of error messages during NullSoft compile]
...
StrCpy $DATADIR "$EXEDIR\Data" () ()
StrCpy $PROGRAMDIR "$EXEDIR\App\ScottradeELITE" () ()
StrCpy $SOURCEDIR "$EXEDIR\Other\ScottradeELITEPortaSources" () ()
IfFileExists: "$EXEDIR\ScottradeELITEPorta\App\ScottradeELITE\*.*" ? 0 : CheckPortableAppsDIR
StrCpy $PROGRAMDIR "$EXEDIR\ScottradeELITEPorta\App\ScottradeELITE" () ()
StrCpy $DATADIR "$EXEDIR\ScottradeELITEPorta\Data" () ()
StrCpy $SOURCEDIR "$EXEDIR\ScottradeELITEPorta\Other\ScottradeELITEPortaSources" () ()
Goto: InitVarEnd
IfFileExists: "$EXEDIR\PortableApps\ScottradeELITEPorta\App\ScottradeELITE\*.*" ? 0 : InitDataDIR
StrCpy $PROGRAMDIR "$EXEDIR\PortableApps\ScottradeELITEPorta\App\ScottradeELITE" () ()
StrCpy $DATADIR "$EXEDIR\PortableApps\ScottradeELITEPorta\Data" () ()
StrCpy $SOURCEDIR "$EXEDIR\PortableApps\ScottradeELITEPorta\Other\ScottradeELITEPortaSources" () ()
Goto: InitVarEnd
StrCmp "$DATADIR" "" equal=0, nonequal=InitVarEnd
MessageBox: 48: ""DataDirectory" was not set in INI file. Please check your configuration!"
Abort: ""
FunctionEnd
Function: "InitInstall"
StrCmp "$EXTRACTSOURCES" "TRUE" equal=0, nonequal=InitInstallSourcesEnd
SetOutPath: "$SOURCEDIR"
File: "ApplicationPortableTemplatev2.nsi" 42989 bytes
File: "readme.txt" 73 bytes
SetOutPath: "$DATADIR"
File: "Registry.reg" 7664 bytes
FunctionEnd
Function: "Init"
IfFileExists: "$DATADIR\*.*" ? +2 :
CreateDirectory: "$DATADIR"
IfFileExists: "$PROGRAMDIR\*.*" ? +2 :
CreateDirectory: "$PROGRAMDIR"
IfFileExists: "$PROGRAMDIR\$PROGRAMEXE" ? FoundEXE :
MessageBox: 52: "$PROGRAMEXE was not found.
Do you want to copy your local installation into your portable applications directory? (This could take some time)
When you select "NO" this launcher will be terminated. In this case, please copy the necessary files yourself." (on IDYES goto +2)
Abort: ""
File: "Dialogs.dll"->"$PLUGINSDIR\Dialogs.dll" 11776 bytes
Plugin Command: Folder Select installation folder of ScottradeELITE Select the main folder where you installed "ScottradeELITE" on your harddrive: $PROGRAMFILES 10
CopyFiles: "$R0\*.*" -> "$PROGRAMDIR", size=0KB
MessageBox: 68: "Copying is finished now. You could now (or later) delete unneeded files.
Do you want to launch ScottradeELITEPorta?" (on IDYES goto +2)
Abort: ""
IfFileExists: "$PROGRAMDIR\$PROGRAMEXE" ? FoundEXE :
MessageBox: 48: "$PROGRAMEXE was not found. Please check your configuration!"
Abort: ""
File: "FindProcDLL.dll"->"$PLUGINSDIR\FindProcDLL.dll" 31744 bytes
Plugin Command: FindProc $PROGRAMEXE
StrCmp "$R0" "1" equal=, nonequal=EndEXE
StrCpy $SECONDLAUNCH "true" () ()
FunctionEnd
...
[Compile aborted with messages at end of compile log]
...
Function: "RunApp"
!insertmacro: GetParametersCall
!insertmacro: end of GetParametersCall
StrCmp "$R0" "" equal=0, nonequal=+2
StrCpy $R0 "$PROGRAMPARMS" () ()
StrCmp "$R0" "" equal=0, nonequal=+2
StrCpy expects 2-4 parameters, got 1.
Usage: StrCpy $(user_var: output) str [maxlen] [startoffset]
Error in script "C:\Temp\ApplicationPortableTemplatev2.nsi" on line 636 -- aborting creation process
...
[end of log]
Question:
Wondering if the data directory structure is correct for as follows:
c:\temp\ScottradeElite
c:\...\...\App
c:\....\...\...\ScottradeElite ;copy of C:\Program Files PC application
c:\...\...\Data
c:\...\...\Other
The PC application seems to have no *.ini or parameters or need for other applications to run.
Since ${EXEPARMS} is empty, it results in the StrCpy command only having 1 parameter, $R0, and the error you received. You'll notice in the error it gives you the usage of StrCpy, which is a clue that is where your error is. To fix it, either comment out the !define at the beginning of your script since you don't use it anyway, or change the above code to
First...loving the new version. Being able to avoid UAC elevation prompts is very cool in apps that 'play' properly.
Now for a challenge. If there is already a work around for this I appologize. I did try and search but didn't see a solution:
I have an application that writes to $Appdata the problem is that Microsoft in all their 'wisdom' has changed the name of the folder.
On XP, if you go to a command prompt and type: cd %adddata%
you will arrive at something like:
c:\documents and settings\username\Application Data
On Vista, if you do the same command you will arrive at something like:
c:\users\username\Appdata\Roaming
So, in my nsi file if I specify something like:
!define SETTINGSDIRS "$Appdata\Settings Folder"
Then put try launching on XP I will get all my settings put into
'Application Data\Settings Folder'
Moving to a Vista box the application is looking for settings in 'AppData\Roaming\Settings Folder' and doesn't find them so it creates 'AppData\Roaming\Settings Folder' and I have to put in all my configurations again. Not really a huge deal until I move back to XP and some config I managed to update is now not available because of the directory name mix up so round and round we go.
Have you made any structural changes to the template? Since it uses the $APPDATA constant, it should be expanded at runtime based on your OS, meaning it should put the files in the correct place on XP and Vista.
Are your files ending up in the XP version AppData directory when launched in Vista?
What version of NSIS are you using to compile the template?
As a test, create a simple script that just does
Section
MessageBox MB_OK "$APPDATA"
SectionEnd
and run it on XP and Vista, and post back the results. Also, what are your lines for
If you enable redirection, the first time you run the app on XP you get this structure on your USB drive:
applicationportable\data\UserProfile\Application Data (used by XP)
Then when you run the app on Vista it is like you never ran it before and this structure gets created on the USB drive:
applicationportable\data\UserProfile\AppData (used by Vista)
The 2 don't 'talk' to each other so if you save settings in one they don't transfer to the other.
!define SETTINGSFILES is commented out
!define SETTINGSDIRS is "$Appdata\WebRunner"
Usage: StrCpy $(user_var: output) str [maxlen] [startoffset]
Error in script "C:\Documents and Settings\Douglas\Desktop\NSISPortable.nsi" on line 647 -- aborting creation process
Hi Klonk, I have been trying to get your NSIS script working by using the USEREGKEYSFILE but everytime I try to use this my Registry.reg file gets deleted. I have had to resort to not using this and using the REGKEYS section (which does the job).
Have you had any problems using USEREGKEYSFILE?
I use it by filling in the "basic information" section. Then commenting out everything in the "Application specific stuff" section except USEREGKEYSFILE and DELETEREGKEYS (both set to True) and then compiling. Everything seems ok and when I run my new portable app, in my data dir, I can see Registry.reg and RegistryBackup.reg but when I close my portable app both reg files get deleted.
Am I using it wrong?
I don't mind using the REGKEYS section but I am a bit anal and when something doesn't work as it should I have to try and find out why.
I am using the new 2.2 version and the /D=2 switch has been removed (I have just done
a check on my script).
It still doesn't seem to work. Any more ideas wraithdu?
What I don't understand is when we use the REGKEYS part of the script this creates a Registry.reg file and everything seems to work as normal so how come this Registry.reg file doesn't get deleted?
I am using the new 3.3 version of the registry plugin. I will post the 2 reg files tomorrow when I get a chance.
Heres my reg files
Registry.reg
REGEDIT4
I wrote a quick script to test the RegFileToStack function, and it works fine. I've gone over the template a bunch of times, and the code looks good. Compile a quick script with the code below, run it in the same directory as your Registry.reg file, and see if you get the 2 keys back correctly -
Section
StrCpy $R0 "Registry.reg"
Push "EndOfStack" ; set end marker for stack
FileOpen $0 $R0 r
StartRegFileRead:
FileRead $0 $R0
IfErrors EndRegFileRead ; end of file
StrCpy $9 $R0 5
StrCmp $9 "[HKEY" 0 StartRegFileRead ; only work on lines containing a registry key
StrCpy $R0 $R0 "" 1 ; remove first "["
${WordFind} "$R0" "]" "+01" $R0 ; remove last "]" and everything behind -> only registry key is left
StrCmp $R1 "" DoRegFileWork ; start with very first registry key
StrLen $9 $R1
StrCpy $R2 $R0 $9
StrCmp $R1 $R2 StartRegFileRead ; if current registry key is a subkey of the key read before read next key
DoRegFileWork:
Push $R0 ; put actual unique registry to stack
StrCpy $R1 "$R0\"
Goto StartRegFileRead
EndRegFileRead:
FileClose $0
StrCpy $R0 ""
KeyLoop:
Pop $R1
StrCmp $R1 "EndOfStack" EndLoop
StrCpy $R0 "$R0$R1$\r$\n"
Goto KeyLoop
EndLoop:
MessageBox MB_OK $R0
SectionEnd
I also should ask, what version of NSIS are you using?
I tried your script but when I compile I get an error on line 11 Invalid command $(WordFind). I am using NSIS ver 2.30. I tried to see if I was missing a plugin and found that there is a new version of NSIS 2.31 and tried this, still the same compile
error. And I even tried NSIS ver 2.07.
Sorry to seem dumb but could you tell me what I need to do to compile your script then I'll give it a go.
Rochey
Sorry, here's the full script (can't edit the above for some reason, out of time?)
!include WordFunc.nsh ; add header for word manipulation
!insertmacro WordFind ; add function for splitting strings
SilentInstall Silent ; start as launcher, not as installer
OutFile FileToStack.exe
Section
StrCpy $R0 "Registry.reg"
Push "EndOfStack" ; set end marker for stack
FileOpen $0 $R0 r
StartRegFileRead:
FileRead $0 $R0
IfErrors EndRegFileRead ; end of file
StrCpy $9 $R0 5
StrCmp $9 "[HKEY" 0 StartRegFileRead ; only work on lines containing a registry key
StrCpy $R0 $R0 "" 1 ; remove first "["
${WordFind} "$R0" "]" "+01" $R0 ; remove last "]" and everything behind -> only registry key is left
StrCmp $R1 "" DoRegFileWork ; start with very first registry key
StrLen $9 $R1
StrCpy $R2 $R0 $9
StrCmp $R1 $R2 StartRegFileRead ; if current registry key is a subkey of the key read before read next key
DoRegFileWork:
Push $R0 ; put actual unique registry to stack
StrCpy $R1 "$R0\"
Goto StartRegFileRead
EndRegFileRead:
FileClose $0
StrCpy $R0 ""
KeyLoop:
Pop $R1
StrCmp $R1 "EndOfStack" EndLoop
StrCpy $R0 "$R0$R1$\r$\n"
Goto KeyLoop
EndLoop:
MessageBox MB_OK $R0
SectionEnd
I compiled it this time, thanks.
I ran my DebugView Portable and in my data directory I had Registry.reg and RegistryBackup.reg. I then put your filetostack.exe in the same folder and ran it. I got a Message box titled Name Setup with HKEY_CURRENT_USER\software\sysinternals\debugview
HKEY_CURRENT_USER\software\sysinternals\dbgview
inside. After closing DebugView Portable my reg files disappeared (as usual).
That means that the function is returning the correct registry keys. Time to look somewhere else. I'll have to build this thing and see what happens to me.
The reason you couldn't update your previous post is because somebody had replied to it already.
_________________________
I don't believe in signatures
I can't believe I didn't see it earlier...forest for the trees man.
The first line of the RegFileToStack function NEEDS TO BE (drum roll)
ClearErrors
Dum dum dummy. The second time the function is called from the CleanReg section the error flag is already set from the first run, so it exits without doing anything, leaving the stack empty and YOU without a reg file. I WIN!!!
You are a Star wraithdu!!!! works fine now. I hate it when something should work but doesn't, but not any more.
It's strange I must be the only person who has tried to use the reg keys file. Oh well. hopefully klonk will update his version to fix this.
Cheers again wraithdu.. I could kiss you (but I won't so don't worry!)
MakeNSIS v2.21 - Copyright 1999-2006 Nullsoft, Inc.
Portions Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler (zlib).
Portions Copyright (C) 1996-2002 Julian R Seward (bzip2).
Portions Copyright (C) 1999-2003 Igor Pavlov (lzma).
Contributors: nnop@newmail.ru, Ryan Geiss, Andras Varga, Drew Davidson, Peter Windridge, Dave Laundon, Robert Rainwater, Yaroslav Faybishenko, Jeff Doozan, Amir Szekely, Ximon Eighteen, et al.
There are a bunch of plugins for NSIS that are commonly used by PortableApps. If the plugin is not present (usually in the NSIS/Plugins directory) you'll get just this error message. Registry is one of them. You can download them from the NSIS web site.
One of these days someone (maybe I) should figure out how to automate that a bit.
I did some experimenting a while back with "" and variables (after suggesting use of "" in another post). When speaking about a variable being interpreted as a single parameter, NSIS will do this by default with the $0 / $R0 / $SOMEUSERVAR variables at both compile time and run time. For example -
StrCpy $0 "hello world"
StrCmp $0 "hello world" yes no
This works fine, and NSIS doesn't complain that $0 is actually two words, it is still interpreted as one parameter. This doesn't work though for DEFINED variables. Ex -
!define USERVAR "hello world"
StrCmp ${USERVAR} "hello world" yes no
Here, NSIS will error at compile saying the StrCmp has too many parameters. Similarly, if ${USERVAR} is empty, it will error saying there are too FEW parameters.
So my new working philosophy is to quote defined vars, and leave the others alone, unless we're talking about executing commands/programs. In that case, it always gets extra quotes -
Exec '"$EXECSTRING" params'
Of course, in most cases the extra quotes won't harm anything, so if you're unsure, leave them in.
Invalid command: ${registry::DeleteKey}
Error in script "D:\Program Files\TuneUp Utilities 2007\TuneUp2007 Portable.nsi" on line 80 -- aborting creation process
Hi everyone,
I found a sever bug when using a registry file as source. Since Windows XP the registry file created via export from regedit (version >= 5) is in unicode format. As NSIS is natively not capable of handling unicode I will have to change the reading routine.
I'm working on that. As soon I'm finished I release a new version
For the meantime open the file with a unicode capable editor and save it as ASCII. I believe SCite could do that.
And I think with the new version I'll open a new thread as this one is quite long already...
Anyone searching for an explanation or what plugins are needed:
Take a look at the first port in this thread or open the script and look at the end. There is a large area with a lot comments and explanations.
Thanks for all the hard work with these templates, they're very much appreciated.
I have set up a NSIS 2.33 environment for myself to be used with your portable apps build template version 2.3. Whilst doing that I discovered that your script would now fail when building w/ SPLASHIMAGE. It seems like 'newsadvsplash::wait' now needs to be expressed as 'newsadvsplash::stop /WAIT' with the latest newsadvsplash plugin.
The announcement about this can found in this post:
I think also it would be helpful to include the URLs to where to find and download the required plugins in the REQUIREMENTS section of your template. For Your convenience, and others, I'll provide them here:
is there a way in which I can specify/reference an icon that doesn't reside in it's own .ico file? For example in order to pass the application's generic icon on to the ApplicationPortable.exe launcher, e.g. via 'iconfilename[,index]', similar to when referencing an embedded icon from an exe, dll, ico, bmp when working with autorun.inf.
An example, for the Autorun key "icon", can be found here:
; If a file "Registry.reg" within the data directory is found then it is read
; and all parent registry keys are processed as if they'd have been set within
; REGKEYS
I'm probably misreading/interpreting this, but shouldn't it say "...all child registry keys..." [to the one(s) specified in REGKEYS] instead of "...all parent registry keys..."?
EXEPARMS are passed to application as ONE string - NOT tokens
Hi Klonk,
I just stumbled on a major problem with the current incarnation of the Portable Application Template, i.e. 2.3. "Command line arguments", specified in EXEPARMS, are handed over to the launched application as ONE string token instead of being split into several individual tokens.
The problem is due to $R0 being quoted in this statement (on Line 659):
ExecWait '"$PROGRAMDIR\$PROGRAMEXE" "$R0"' ; run program
Removing the quotes remedies that problem, and the statement will change into:
ExecWait '"$PROGRAMDIR\$PROGRAMEXE" $R0' ; run program
After introducing that change, if one needs to specify one or more arguments - containing spaces - to the application to be launched, this is how it's done:
You can try this out for yourself with this batch file:
- - - - - - - - cut & past this - - - - - - - beg of - e.g. DebugArgs.bat
@echo off
rem
rem Let your Portable Application Template installer launch this batch file,
rem by setting '!define EXE "DebugArgs.bat"' in your .nsi file.
rem
echo Output from script %0%
echo.
echo Arguments:
echo.
echo arg1=%1%
echo arg2=%2%
echo arg3=%3%
echo arg4=%4%
echo arg5=%5%
echo arg6=%6%
echo arg7=%7%
echo arg8=%8%
echo arg9=%9%
echo.
echo.
pause
- - - - - - - - cut & past this - - - - - - - end of - e.g. DebugArgs.bat
I'm sorry if I have to make You disappointed here (or it's me that messed up my testing).
Try my batch script and You'll see that You will end up with different number of arguments passed to/received by the script.
NOTE, handling strings within the .nsi environment itself, is different to exporting them as arguments, like in this case were the OS command parser will become involved.
Java support and Portable Application Template 2.3
To "automagically" have support for multiple versions of the Java Runtime Environment would be very useful. But I'm not sure I manage to figure out how it's implemented, or supposed to work.
Irrespectively of the version of the JRE, if I for example have a portable JRE installed in /PortableApps/CommonFiles/Java[/bin], I can launch that version of Java explicitly by specifying e.g. (relative to App\$APP\):
Of course, this defeats the "dynamic" lookup of the JRE executables.
Usually, one launches either the targeted JRE/bin/java[w][.exe] explicitly OR adds the bin directory of the desired java[w].exe to the PATH environment variable, after which one can just type 'java ...' or 'javaw ...' to launch Java.
Now, I've noticed, the Portable Application Template allows me to specify (well, rather recommend) a certain release of java via the USEJAVAVERSON variable, e.g. by setting it to "1.5.0_12". I'm not sure I understand the point hereby, since:
1). By doing this there is an environment variable (JAVA_HOME) being set [why? I don't know - JRE doesn't require this as it can be dynamically retrieved in Java via "System.getProperty('java.home');"], and the value of '$JAVA_HOME\bin' is added to the PATH environment variable (which does make sense - although there is still no need to introduce the variable JAVA_HOME).
2). even if I now have, the "dynamically" assigned, JRE in the path, I cannot launch java by specifying just 'java[.exe]' or 'javaw[.exe]' in the !define EXE statement. Trying to do this will lead to a pop-up message with the following content at the execution (not compilation) of the launcher:
+------------------------------------------------------------
| Application Portable - 0.0.0.0
+--------------------------------------
|
| ! java[.exe] was not found.
| Do you want to copy your local installation into your portable applications directory? (This could take some time)
|
| When you select "NO" this launcher will be terminated. In this case, please copy the necessary files yourself.
|
| [ Yes ] [ No ]
|
+--------------------------------------
Since this doesn't work, and I don't seem to be able to figure out how to take advantage of the "dynamic" JRE discovery by myself, I'd be very grateful if someone could enlighten me here.
Best regards!
BTW, asserting that the correct version of Java is used for your Java program is usually accomplished by starting it via e.g. 'java -version:1.6 ...', which will fail w/ a message like below if no jre1.6.x cannot be localized on the system:
yes You did, and now I also know why You see the same output in both cases. You're running a "clean room" envionment, NOT the Portable Application Template v2.3.
Try the same using PAT and You'll see that the NSIS compiler will bail out at line 653, because ${EXEPARMS} in that line is quoted w/ "double quotes". If one changes the quoting to use back quotes instead You'll succeed (but then You'll presumably fail in the case of using back quotes in the mix).
Removing the quotes entirely will result in no arguments being passed at all.
So, let's agree upon two things:
1). It's PAT that breaks nested sting handling, not the NSIS scripting language.
2). I was wrong when assuming it had something to do with the Windows shell.
I don't know whether there is a way in which PAT can be modified to handle all the supported quoting methods described below, or not.
Ok, I've got the big picture now. I think the solution is on line 755 (template v2.4, just downloaded today) -
StrCpy $R0 `${EXEPARMS}`
Using backquotes here prevents any mishandling of nested single and double quotes. Then in line 30 you can use any combination of single and double quotes to satisfy whatever program you're passing args to -
The underlying problem is the !define directive during compile time. If a referenced define is empty, ie ${EXEPARMS}, and is NOT quoted, then the compile exits with incorrect syntax for the given command, in this case StrCpy (too few arguments).
Furthermore, an unquoted definition is taken as a literally typed string, ie
!define TEST "one two three"
${TEST} equals three arguments, "one", "two", and "three"
and "${TEST}" now equals one argument, "one two three"
whereas
StrCpy $TEST "one two three"
$TEST and "$TEST" both equal one argument "one two three"
Quoting `${EXEPARMS}` will allow compile even if it is an empty variable.
This is not the case with a regular variable, ie $R0. Even if it is empty and unquoted, the compiler recognizes it as a valid argument.
I don't get it. I actually made the launcher, even downloaded the template just today. I used the REGKEYS setting, and just removed the /D=2 switch. I ran the program like 4 times and the settings were saved/restored correctly.
I hate to say it, but I'm stumped.
Wraithdu, I finally got it working!!!! Figured out what was going wrong.
Firstly, in my regkeys section I was using "HKCU\..." for my regkeys and for some reason I can't restore to the registry when it's in this format(I don't know if this is specific to me). I double clicked the newly created Registry.reg and it said that it had loaded the info into the registry but it actually hadn't. So I changed the script to "HKEY_CURRENT_USER\..." and this Registry.reg worked.
Secoundly, I found that debugview would seem to startup and ask for the license agreement sometimes, even though the registry had my settings in it. So what I had to do was add a "sleep 100" to the end of where it restores the registry.reg in the template. Now it seems to work perfectly.
It would be interesting to know what you put in your regkeys section.
Cheers for all your help! I'm so glad I cracked it!
Rochey
I had probably just what you had -
!define REGKEYS "HKCU\Software\Sysinternals\DbgView||HKCU\Software\Sysinternals\DebugView"
That and I just removed the /D=2 switch. Other specs that may be of relevance -
WinXP SP2
Intel Core2Duo
NSIS 2.29 long string build
registry plugin v3.1
I can't think of anything else really. I know that the Sleep times can make a difference, but I've never had a problem with Sleep 50 on any system I've tried. And I'm stumped why you can't use HKCU.
Either way, glad you got it working!
@Rochey
I thought you might be interested to know that I found a bug in v3.2 of the NSIS registry plugin. It's exactly what you mentioned - the short name HKCU is saved as just that in the REG file instead of being expanded to HKEY_CURRENT_USER.
HKLM does not seem to be affected. Check the Winamp forums to download v3.1 which does not have this problem.
EDIT -
bug fixed in v3.3 available at winamp forums.
Also in talking with the developer I've managed to get out of him which functions need Sleep time to function correctly. Only ${registry::RestoreKey} DOES NOT wait for the reg operation to finish before moving on in the script, meaning this is the ONLY plugin call that needs Sleep time to finish. This is because all it does is call 'regedit /s'.
So to work around this and be able to get rid of ALL your Sleep commands, use -
ExecWait 'regedit /s "file"'
Klonk can edit his template accordingly if he wishes to remove the Sleep commands and replace the RestoreKey call.
Cheers for the info wraithdu. I'll change my scripts.
Rochey
doesn't this open a DOS window??? (Haven't tried it yet though it's a valueable information...
I'll change it accordingly as this is the best way, you're right.
With using sleep you could never be sure that you waited long enough...
Will be included in version 2.2 whioch will be released very soon (today)
Found a bug in the 2.1 template (by accident).
The 'newadvsplash::wait' call is never made, so the plugin DLL is left in the temp directory after launcher exit (if a splash screen is used). Should probably add in the Clean function -
!ifdef SPLASHIMAGE
StrCmp "$SPLASHSCREEN" "enabled" 0 CleanEnd
newadvsplash::wait
!endif
CleanEnd:
Just exactly where did you insert this code?
Everytime I have tried to use 'newadvsplash' the plugin
DLL is left in the temp directory after launcher exit (as
you described).
Please help!
newadvsplash::wait
At the end.
______________________
Signature...What Signature?
You need to add it in the Clean function. Here's the whole thing for you.
Function Clean
StrCmp "$SECONDLAUNCH" "true" CleanEnd ; do not do anything if launched a second time
!ifdef DOREG | DOREGFILE
${registry::Unload} ; unload registry functions from, memory
!endif
!ifdef SPLASHIMAGE
StrCmp "$SPLASHSCREEN" "enabled" 0 CleanEnd
newadvsplash::wait
!endif
CleanEnd:
FunctionEnd
I'll add this..
The app I had the splash problem with (TextPad4) was compiled using Portable application template version 1.8, so I had to fit your example code in, AND NOW it works correctly!!
Thanks
New to using this template and making portable. I had previously used v2.0 for the one that I am trying to make a porta app, but with my software upgrade and using v2.1 I am receiving an error message.
Thank you for any help.
Error Message at end of compile:
---------------------------------------
MakeNSIS v2.30 - Copyright 1995-2007 Contributors
See the file COPYING for license details.
Credits can be found in the Users Manual.
Processing config:
Processing plugin dlls: "C:\Program Files\NSIS\Plugins\*.dll"
- AdvSplash::show
- Banner::destroy
- Banner::getWindow
- Banner::show
- BgImage::AddImage
- BgImage::AddText
- BgImage::Clear
- BgImage::Destroy
- BgImage::Redraw
- BgImage::SetBg
- BgImage::SetReturn
- BgImage::Sound
- Dialer::AttemptConnect
- Dialer::AutodialHangup
- Dialer::AutodialOnline
- Dialer::AutodialUnattended
- Dialer::GetConnectedState
- Dialogs::Author
- Dialogs::Folder
- Dialogs::InputBox
- Dialogs::InputRegCode
- Dialogs::Open
- Dialogs::Save
- Dialogs::Ver
- FindProcDLL::FindProc
- InstallOptions::dialog
- InstallOptions::initDialog
- InstallOptions::show
- LangDLL::LangDialog
- Math::Script
- NSISdl::download
- NSISdl::download_quiet
- Splash::show
- StartMenu::Init
- StartMenu::Select
- StartMenu::Show
- System::Alloc
- System::Call
- System::Copy
- System::Free
- System::Get
- System::Int64Op
- System::Store
- TypeLib::GetLibVersion
- TypeLib::Register
- TypeLib::UnRegister
- UserInfo::GetAccountType
- UserInfo::GetName
- UserInfo::GetOriginalAccountType
- VPatch::vpatchfile
- newadvsplash::hwnd
- newadvsplash::play
- newadvsplash::show
- newadvsplash::stop
- newadvsplash::wait
- nsDialogs::Create
- nsDialogs::CreateControl
- nsDialogs::CreateItem
- nsDialogs::GetUserData
- nsDialogs::OnBack
- nsDialogs::OnChange
- nsDialogs::OnClick
- nsDialogs::OnNotify
- nsDialogs::SelectFileDialog
- nsDialogs::SelectFolderDialog
- nsDialogs::SetRTL
- nsDialogs::SetUserData
- nsDialogs::Show
- nsExec::Exec
- nsExec::ExecToLog
- nsExec::ExecToStack
- registry::_Close
- registry::_CopyKey
- registry::_CopyValue
- registry::_CreateKey
- registry::_DeleteKey
- registry::_DeleteKeyEmpty
- registry::_DeleteValue
- registry::_Find
- registry::_HexToStr
- registry::_KeyExists
- registry::_MoveKey
- registry::_MoveValue
- registry::_Open
- registry::_Read
- registry::_ReadExtra
- registry::_RestoreKey
- registry::_SaveKey
- registry::_StrToHex
- registry::_Unload
- registry::_Write
- registry::_WriteExtra
!define: "MUI_INSERT_NSISCONF"=""
Changing directory to: "C:\Temp\ScottradeElite"
Processing script file: "C:\Temp\ScottradeElite\ApplicationPortableTemplate.nsi"
!define: "AUTHOR"="Scottrader"
!define: "APP"="ScottradeELITE"
!define: "VER"="1.0.0.0"
!define: "EXE"="Scottrader.exe"
!define: "EXEPARMS"=""
Usage: !define ([/date|/utcdate] symbol [value]) | (/math symbol val1 OP val2)
OP=(+ - * / % & | ^)
Error in script "C:\Temp\ScottradeElite\ApplicationPortableTemplate.nsi" on line 36 -- aborting creation process
Settings from ApplicationPortableTemplate.nsi
--------------------------------------------------
; ----- Basic informations
!define AUTHOR "Scottrader" ; your name
!define APP "ScottradeELITE" ; insert application name, e.g. "TestApp"
!define VER "1.0.0.0" ; insert version of launcher
!define EXE "Scottrader.exe" ; insert program exe name, e.g. "testapp.exe"
!define EXEPARMS "" ; insert some default Parameters
; ----- Application specific stuff
; insert regkeys to use separated by "||", comment out, when not used,
; e.g. HKCU\Software
!define REGKEYS "HKEY_CURRENT_USER\Software\Scottrader" ""
; If a file "Registry.reg" within the data directory is found then it is read
; and all parent registry keys are processed as if they'd have been set within
; REGKEYS
; !define USEREGKEYSFILE "TRUE"
; delete alle defined registry keys before own ones are applied (during Init)
!define DELETEREGKEYS "TRUE"
; insert settings files to use separated by "||" as stored on the host
; computer, e.g. "$WINDIR\TEST.INI", comment out, when not used
; !define SETTINGSFILES ""
; insert settings directories to use separated by "||" as stored on the host
; computer, e.g. "$PROFILE\TEST", comment out, when not used
; !define SETTINGSDIRS ""
; Require local administrator rights to run the launcher, necessary when
; writing to e.g. HKLM registry key. If not required comment out
; !define ADMINREQUIRED "TRUE"
; Redirect Userprofile folder, comment out when your application calls other
; programs, i.e. to disable automatic redirection. Default value "TRUE".
!define REDIRECTUSERPROFILE "TRUE"
; When "TRUE" a launcher is created that contains the sources and copies them
; into the appropriate folder if they do not exist yet.
!define INSTALLSOURCES "TRUE"
; define which GTK version should be used, e.g. 2.0
; !define USEGTKVERSION ""
; define which JAVA version should be used, e.g. 1.6.0.10
!define USEJAVAVERSION "1.6.0.10"
; ----- Normally no need to change anything here
; format of portable name (dirs and filenames)
!define PNAME "${App}Portable"
; comment this line out when default icon should be used
; !define ICON "${PNAME}.ico"
; comment this line out when no splashscreen image should be used
; !define SPLASHIMAGE "${PNAME}.jpg"
; could be changed when settings for multiple applications should be stored in
; one INI file
; !define INI "${PNAME}.ini"
The compiler says error on line 36. Checking line 36 you have -
!define REGKEYS "HKEY_CURRENT_USER\Software\Scottrader" ""
I see an extra set of "" there, how bout you? Try -
!define REGKEYS "HKEY_CURRENT_USER\Software\Scottrader"
The previous removal of the extra "" allowed the compile to continue but there are other compile problems as follows:
[Excerpts of error messages during NullSoft compile]
...
StrCpy $DATADIR "$EXEDIR\Data" () ()
StrCpy $PROGRAMDIR "$EXEDIR\App\ScottradeELITE" () ()
StrCpy $SOURCEDIR "$EXEDIR\Other\ScottradeELITEPortaSources" () ()
IfFileExists: "$EXEDIR\ScottradeELITEPorta\App\ScottradeELITE\*.*" ? 0 : CheckPortableAppsDIR
StrCpy $PROGRAMDIR "$EXEDIR\ScottradeELITEPorta\App\ScottradeELITE" () ()
StrCpy $DATADIR "$EXEDIR\ScottradeELITEPorta\Data" () ()
StrCpy $SOURCEDIR "$EXEDIR\ScottradeELITEPorta\Other\ScottradeELITEPortaSources" () ()
Goto: InitVarEnd
IfFileExists: "$EXEDIR\PortableApps\ScottradeELITEPorta\App\ScottradeELITE\*.*" ? 0 : InitDataDIR
StrCpy $PROGRAMDIR "$EXEDIR\PortableApps\ScottradeELITEPorta\App\ScottradeELITE" () ()
StrCpy $DATADIR "$EXEDIR\PortableApps\ScottradeELITEPorta\Data" () ()
StrCpy $SOURCEDIR "$EXEDIR\PortableApps\ScottradeELITEPorta\Other\ScottradeELITEPortaSources" () ()
Goto: InitVarEnd
StrCmp "$DATADIR" "" equal=0, nonequal=InitVarEnd
MessageBox: 48: ""DataDirectory" was not set in INI file. Please check your configuration!"
Abort: ""
FunctionEnd
Function: "InitInstall"
StrCmp "$EXTRACTSOURCES" "TRUE" equal=0, nonequal=InitInstallSourcesEnd
SetOutPath: "$SOURCEDIR"
File: "ApplicationPortableTemplatev2.nsi" 42989 bytes
File: "readme.txt" 73 bytes
SetOutPath: "$DATADIR"
File: "Registry.reg" 7664 bytes
FunctionEnd
Function: "Init"
IfFileExists: "$DATADIR\*.*" ? +2 :
CreateDirectory: "$DATADIR"
IfFileExists: "$PROGRAMDIR\*.*" ? +2 :
CreateDirectory: "$PROGRAMDIR"
IfFileExists: "$PROGRAMDIR\$PROGRAMEXE" ? FoundEXE :
MessageBox: 52: "$PROGRAMEXE was not found.
Do you want to copy your local installation into your portable applications directory? (This could take some time)
When you select "NO" this launcher will be terminated. In this case, please copy the necessary files yourself." (on IDYES goto +2)
Abort: ""
File: "Dialogs.dll"->"$PLUGINSDIR\Dialogs.dll" 11776 bytes
Plugin Command: Folder Select installation folder of ScottradeELITE Select the main folder where you installed "ScottradeELITE" on your harddrive: $PROGRAMFILES 10
CopyFiles: "$R0\*.*" -> "$PROGRAMDIR", size=0KB
MessageBox: 68: "Copying is finished now. You could now (or later) delete unneeded files.
Do you want to launch ScottradeELITEPorta?" (on IDYES goto +2)
Abort: ""
IfFileExists: "$PROGRAMDIR\$PROGRAMEXE" ? FoundEXE :
MessageBox: 48: "$PROGRAMEXE was not found. Please check your configuration!"
Abort: ""
File: "FindProcDLL.dll"->"$PLUGINSDIR\FindProcDLL.dll" 31744 bytes
Plugin Command: FindProc $PROGRAMEXE
StrCmp "$R0" "1" equal=, nonequal=EndEXE
StrCpy $SECONDLAUNCH "true" () ()
FunctionEnd
...
[Compile aborted with messages at end of compile log]
...
Function: "RunApp"
!insertmacro: GetParametersCall
!insertmacro: end of GetParametersCall
StrCmp "$R0" "" equal=0, nonequal=+2
StrCpy $R0 "$PROGRAMPARMS" () ()
StrCmp "$R0" "" equal=0, nonequal=+2
StrCpy expects 2-4 parameters, got 1.
Usage: StrCpy $(user_var: output) str [maxlen] [startoffset]
Error in script "C:\Temp\ApplicationPortableTemplatev2.nsi" on line 636 -- aborting creation process
...
[end of log]
Question:
Wondering if the data directory structure is correct for as follows:
c:\temp\ScottradeElite
c:\...\...\App
c:\....\...\...\ScottradeElite ;copy of C:\Program Files PC application
c:\...\...\Data
c:\...\...\Other
The PC application seems to have no *.ini or parameters or need for other applications to run.
Your directory structure looks fine.
Your problem is for 2 reasons, and you can fix it 2 ways. First, you have this line at the top of your config (from your other post)
!define EXEPARMS ""
which creates the variable and leaves it empty. Then there's this section in the RunApp function
!ifdef EXEPARMS
StrCmp $R0 "" 0 +2
StrCpy $R0 ${EXEPARMS}
!endif
Since ${EXEPARMS} is empty, it results in the StrCpy command only having 1 parameter, $R0, and the error you received. You'll notice in the error it gives you the usage of StrCpy, which is a clue that is where your error is. To fix it, either comment out the !define at the beginning of your script since you don't use it anyway, or change the above code to
!ifdef EXEPARMS
StrCmp "$R0" "" 0 +2
StrCpy $R0 "${EXEPARMS}"
!endif
The "" will act as the second parameter for StrCpy even if the variable is empty. It's good practice to put quotes around stuff like
StrCpy $R0 "$somevariable"
StrCmp "$R1" "$R2"
for pointing to that problem. I'll check the sources and add a lot "" ;-).
First...loving the new version. Being able to avoid UAC elevation prompts is very cool in apps that 'play' properly.
Now for a challenge. If there is already a work around for this I appologize. I did try and search but didn't see a solution:
I have an application that writes to $Appdata the problem is that Microsoft in all their 'wisdom' has changed the name of the folder.
On XP, if you go to a command prompt and type: cd %adddata%
you will arrive at something like:
c:\documents and settings\username\Application Data
On Vista, if you do the same command you will arrive at something like:
c:\users\username\Appdata\Roaming
So, in my nsi file if I specify something like:
!define SETTINGSDIRS "$Appdata\Settings Folder"
Then put try launching on XP I will get all my settings put into
'Application Data\Settings Folder'
Moving to a Vista box the application is looking for settings in 'AppData\Roaming\Settings Folder' and doesn't find them so it creates 'AppData\Roaming\Settings Folder' and I have to put in all my configurations again. Not really a huge deal until I move back to XP and some config I managed to update is now not available because of the directory name mix up so round and round we go.
Anyone have an idea?
Have you made any structural changes to the template? Since it uses the $APPDATA constant, it should be expanded at runtime based on your OS, meaning it should put the files in the correct place on XP and Vista.
Are your files ending up in the XP version AppData directory when launched in Vista?
What version of NSIS are you using to compile the template?
As a test, create a simple script that just does
Section
MessageBox MB_OK "$APPDATA"
SectionEnd
and run it on XP and Vista, and post back the results. Also, what are your lines for
!define SETTINGSFILES
!define SETTINGSDIRS
If you enable redirection, the first time you run the app on XP you get this structure on your USB drive:
applicationportable\data\UserProfile\Application Data (used by XP)
Then when you run the app on Vista it is like you never ran it before and this structure gets created on the USB drive:
applicationportable\data\UserProfile\AppData (used by Vista)
The 2 don't 'talk' to each other so if you save settings in one they don't transfer to the other.
!define SETTINGSFILES is commented out
!define SETTINGSDIRS is "$Appdata\WebRunner"
thanks
Scott
Why I get this error? I'm a newbie with NSIS...
Usage: StrCpy $(user_var: output) str [maxlen] [startoffset]
Error in script "C:\Documents and Settings\Douglas\Desktop\NSISPortable.nsi" on line 647 -- aborting creation process
!define EXEPARMS
line look like? Did you comment it out?
If you have set anything please make sure that the " are at the beginning and at the end...
I commented it out and now it's working fine
thanks
Hi Klonk, I have been trying to get your NSIS script working by using the USEREGKEYSFILE but everytime I try to use this my Registry.reg file gets deleted. I have had to resort to not using this and using the REGKEYS section (which does the job).
Have you had any problems using USEREGKEYSFILE?
I use it by filling in the "basic information" section. Then commenting out everything in the "Application specific stuff" section except USEREGKEYSFILE and DELETEREGKEYS (both set to True) and then compiling. Everything seems ok and when I run my new portable app, in my data dir, I can see Registry.reg and RegistryBackup.reg but when I close my portable app both reg files get deleted.
Am I using it wrong?
I don't mind using the REGKEYS section but I am a bit anal and when something doesn't work as it should I have to try and find out why.
Cheers
Rochey
Does it work if you remove the /D=2 switch from the ${registry::SaveKey} command in the CleanReg function? I thought I remembered this acting funny.
I am using the new 2.2 version and the /D=2 switch has been removed (I have just done
a check on my script).
It still doesn't seem to work. Any more ideas wraithdu?
What I don't understand is when we use the REGKEYS part of the script this creates a Registry.reg file and everything seems to work as normal so how come this Registry.reg file doesn't get deleted?
Rochey
EDIT - i was wrong, deleted
EDIT - N/M, it seems that variables are treated as a single parameter even without "". There goes that idea...
What version of the registry plugin are you using?
Can you post the contents of your 'Registry.reg' and 'RegistryBackup.reg' files during runtime?
Anyway, you should probably add the following immediately after the line reading 'Function RegFileToStack' -
StrCpy $R1 ""
to clear the variable since it is called from both InitReg and CleanReg.
I am using the new 3.3 version of the registry plugin. I will post the 2 reg files tomorrow when I get a chance.
Heres my reg files
Registry.reg
REGEDIT4
[HKEY_CURRENT_USER\Software\Sysinternals\dbgview]
"Settings"=hex:90,01,00,00,64,00,00,00,64,00,00,00,f4,01,00,00,2c,01,00,00,23,\
00,00,00,64,00,00,00,73,04,00,00,00,00,00,00,01,01,01,01,00,01,00,00,f3,ff,\
ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,90,01,00,00,00,00,00,00,01,02,02,\
22,43,6f,75,72,69,65,72,00,00,00,00,00,90,e1,12,00,f0,5e,15,00,38,e1,12,00,\
f0,5e,15,00,00,00,00,00,00,01,01,01,ff,ff,ff,00,ff,ff,ff,00,ff,ff,ff,00,ff,\
ff,ff,00,ff,ff,ff,00,ff,00,00,00,80,00,ff,00,ff,80,40,00,40,80,80,00,00,80,\
ff,00,01,00,00,00,00,00,00,00,00,01,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,80,80,ff,00,80,ff,\
80,00,80,ff,ff,00,80,ff,80,00,ff,ff,80,00,01,00,00,00,ff,ff,ff,00,ff,ff,ff,\
00,ff,ff,ff,00,ff,ff,ff,00,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,ff,00,00,00,80,00,ff,00,ff,80,40,00,40,80,80,00,00,\
80,ff,00,80,80,ff,00,80,ff,80,00,80,ff,ff,00,80,ff,80,00,ff,ff,80,00
"Recent"=hex:00
"InFilters"=hex:2a,00,00
"ExFilters"=hex:20,00,00
"HiFilters"=hex:6f,6b,3b,61,76,61,69,6c,00,66,61,69,6c,3b,75,6e,61,76,61,69,00,\
00
"HiCurFilters"=hex:66,61,69,6c,3b,75,6e,61,76,61,69,00,00,00,00,00,00,6f,6b,3b,\
61,76,61,69,6c,00,00,00,20,00,20,00,20,00,20,00,20,00,20,00,20,00,20,00,20,\
00,20,00,20,00,00
[HKEY_CURRENT_USER\Software\Sysinternals\debugview]
"EulaAccepted"=dword:00000001
and Registrybackup.reg
REGEDIT4
[HKEY_CURRENT_USER\Software\Sysinternals\debugview]
"EulaAccepted"=dword:00000001
[HKEY_CURRENT_USER\Software\Sysinternals\dbgview]
"Settings"=hex:90,01,00,00,64,00,00,00,64,00,00,00,f4,01,00,00,2c,01,00,00,23,\
00,00,00,64,00,00,00,62,03,00,00,00,00,00,00,01,00,01,01,00,01,00,00,f3,ff,\
ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,90,01,00,00,00,00,00,00,01,02,02,\
22,43,6f,75,72,69,65,72,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,01,01,01,ff,ff,ff,00,ff,ff,ff,00,ff,ff,ff,00,ff,\
ff,ff,00,ff,ff,ff,00,ff,00,00,00,80,00,ff,00,ff,80,40,00,40,80,80,00,00,80,\
ff,00,01,00,00,00,00,00,00,00,00,01,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,80,80,ff,00,80,ff,\
80,00,80,ff,ff,00,80,ff,80,00,ff,ff,80,00,01,00,00,00,ff,ff,ff,00,ff,ff,ff,\
00,ff,ff,ff,00,ff,ff,ff,00,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,ff,00,00,00,80,00,ff,00,ff,80,40,00,40,80,80,00,00,\
80,ff,00,80,80,ff,00,80,ff,80,00,80,ff,ff,00,80,ff,80,00,ff,ff,80,00
"Recent"=hex:00
"InFilters"=hex:2a,00,00
"ExFilters"=hex:00
"HiFilters"=hex:00
"HiCurFilters"=hex:00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00
Hmmm, reg file looks good. This is the same program you were having problems with before isn't it. I'll check something out and get back to you.
I wrote a quick script to test the RegFileToStack function, and it works fine. I've gone over the template a bunch of times, and the code looks good. Compile a quick script with the code below, run it in the same directory as your Registry.reg file, and see if you get the 2 keys back correctly -
I also should ask, what version of NSIS are you using?
I tried your script but when I compile I get an error on line 11 Invalid command $(WordFind). I am using NSIS ver 2.30. I tried to see if I was missing a plugin and found that there is a new version of NSIS 2.31 and tried this, still the same compile
error. And I even tried NSIS ver 2.07.
Sorry to seem dumb but could you tell me what I need to do to compile your script then I'll give it a go.
Rochey
ack..
oops..
Sorry, here's the full script (can't edit the above for some reason, out of time?)
I compiled it this time, thanks.
I ran my DebugView Portable and in my data directory I had Registry.reg and RegistryBackup.reg. I then put your filetostack.exe in the same folder and ran it. I got a Message box titled Name Setup with HKEY_CURRENT_USER\software\sysinternals\debugview
HKEY_CURRENT_USER\software\sysinternals\dbgview
inside. After closing DebugView Portable my reg files disappeared (as usual).
That means that the function is returning the correct registry keys. Time to look somewhere else. I'll have to build this thing and see what happens to me.
The reason you couldn't update your previous post is because somebody had replied to it already.
_________________________
I don't believe in signatures
The developer formerly known as ZGitRDun8705
I can't believe I didn't see it earlier...forest for the trees man.
The first line of the RegFileToStack function NEEDS TO BE (drum roll)
ClearErrors
Dum dum dummy. The second time the function is called from the CleanReg section the error flag is already set from the first run, so it exits without doing anything, leaving the stack empty and YOU without a reg file. I WIN!!!
You are a Star wraithdu!!!! works fine now. I hate it when something should work but doesn't, but not any more.
It's strange I must be the only person who has tried to use the reg keys file. Oh well. hopefully klonk will update his version to fix this.
Cheers again wraithdu.. I could kiss you (but I won't so don't worry!)
MakeNSIS v2.21 - Copyright 1999-2006 Nullsoft, Inc.
Portions Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler (zlib).
Portions Copyright (C) 1996-2002 Julian R Seward (bzip2).
Portions Copyright (C) 1999-2003 Igor Pavlov (lzma).
Contributors: nnop@newmail.ru, Ryan Geiss, Andras Varga, Drew Davidson, Peter Windridge, Dave Laundon, Robert Rainwater, Yaroslav Faybishenko, Jeff Doozan, Amir Szekely, Ximon Eighteen, et al.
Processing config:
Processing plugin dlls: "d:\Program Files\NSIS\Plugins\*.dll"
- AdvSplash::show
- Banner::destroy
- Banner::getWindow
- Banner::show
- BgImage::AddImage
- BgImage::AddText
- BgImage::Clear
- BgImage::Destroy
- BgImage::Redraw
- BgImage::SetBg
- BgImage::SetReturn
- BgImage::Sound
- Dialer::AttemptConnect
- Dialer::AutodialHangup
- Dialer::AutodialOnline
- Dialer::AutodialUnattended
- Dialer::GetConnectedState
- InstallOptions::dialog
- InstallOptions::initDialog
- InstallOptions::show
- LangDLL::LangDialog
- Math::Script
- NSISdl::download
- NSISdl::download_quiet
- Splash::show
- StartMenu::Init
- StartMenu::Select
- StartMenu::Show
- System::Alloc
- System::Call
- System::Copy
- System::Free
- System::Get
- System::Int64Op
- System::Store
- TypeLib::GetLibVersion
- TypeLib::Register
- TypeLib::UnRegister
- UserInfo::GetAccountType
- UserInfo::GetName
- VPatch::vpatchfile
- nsExec::Exec
- nsExec::ExecToLog
- nsExec::ExecToStack
!define: "MUI_INSERT_NSISCONF"=""
Changing directory to: "D:\Program Files\FastStone Capture"
Processing script file: "D:\Program Files\FastStone Capture\ApplicationPortableTemplate.nsi"
!define: "AUTHOR"="Viet Nguyen"
!define: "APP"="Fast Stone"
!define: "VER"="0.0.0.0"
!define: "EXE"="FSCapture.exe"
!define: "EXEPARMS"=""
!define: "REGKEYS"=""
!define: "USEREGKEYSFILE"="TRUE"
!define: "DELETEREGKEYS"="TRUE"
!define: "SETTINGSFILES"=""
!define: "SETTINGSDIRS"=""
!define: "ADMINREQUIRED"="TRUE"
!define: "REDIRECTUSERPROFILE"="TRUE"
!define: "INSTALLSOURCES"="TRUE"
!define: "USEGTKVERSION"=""
!define: "USEJAVAVERSION"=""
!define: "PNAME"="Fast StonePortable"
!define: "ICON"="Fast StonePortable.ico"
!define: "SPLASHIMAGE"="Fast StonePortable.jpg"
!define: "INI"="Fast StonePortable.ini"
SetDatablockOptimize: on
SetCompress: force
SetCompressor: /FINAL /SOLID lzma
!define: "DOREGFILE"=""
!include: could not find: "Registry.nsh"
Error in script "D:\Program Files\FastStone Capture\ApplicationPortableTemplate.nsi" on line 121 -- aborting creation process
You can give me a guid = image.
There are a bunch of plugins for NSIS that are commonly used by PortableApps. If the plugin is not present (usually in the NSIS/Plugins directory) you'll get just this error message. Registry is one of them. You can download them from the NSIS web site.
One of these days someone (maybe I) should figure out how to automate that a bit.
MC
for that. Will be added in next version.
I did some experimenting a while back with "" and variables (after suggesting use of "" in another post). When speaking about a variable being interpreted as a single parameter, NSIS will do this by default with the $0 / $R0 / $SOMEUSERVAR variables at both compile time and run time. For example -
StrCpy $0 "hello world"
StrCmp $0 "hello world" yes no
This works fine, and NSIS doesn't complain that $0 is actually two words, it is still interpreted as one parameter. This doesn't work though for DEFINED variables. Ex -
!define USERVAR "hello world"
StrCmp ${USERVAR} "hello world" yes no
Here, NSIS will error at compile saying the StrCmp has too many parameters. Similarly, if ${USERVAR} is empty, it will error saying there are too FEW parameters.
So my new working philosophy is to quote defined vars, and leave the others alone, unless we're talking about executing commands/programs. In that case, it always gets extra quotes -
Exec '"$EXECSTRING" params'
Of course, in most cases the extra quotes won't harm anything, so if you're unsure, leave them in.
Invalid command: ${registry::DeleteKey}
Error in script "D:\Program Files\TuneUp Utilities 2007\TuneUp2007 Portable.nsi" on line 80 -- aborting creation process
Help !
Do you have all the plugins? I think they are listed in the script source code. Just go to the NSIS site and download/install them.
MC
I visted NSIS site but I can't download the plugin, help !.
I had plugin registry.nsh
is there any tutorials on how to set it up better also when we write it do we put it in the Portalaunch.ini or the appinfo.ini
An eye for an eye makes the whole world blind.
Mahatma Gandhi,
Indian political and spiritual leader (1869 - 1948)
Hi everyone,
I found a sever bug when using a registry file as source. Since Windows XP the registry file created via export from regedit (version >= 5) is in unicode format. As NSIS is natively not capable of handling unicode I will have to change the reading routine.
I'm working on that. As soon I'm finished I release a new version
For the meantime open the file with a unicode capable editor and save it as ASCII. I believe SCite could do that.
And I think with the new version I'll open a new thread as this one is quite long already...
Anyone searching for an explanation or what plugins are needed:
Take a look at the first port in this thread or open the script and look at the end. There is a large area with a lot comments and explanations.
Hi Klonk,
Thanks for all the hard work with these templates, they're very much appreciated.
I have set up a NSIS 2.33 environment for myself to be used with your portable apps build template version 2.3. Whilst doing that I discovered that your script would now fail when building w/ SPLASHIMAGE. It seems like 'newsadvsplash::wait' now needs to be expressed as 'newsadvsplash::stop /WAIT' with the latest newsadvsplash plugin.
The announcement about this can found in this post:
http://forums.winamp.com/showthread.php?postid=2274626#post2274626
I think also it would be helpful to include the URLs to where to find and download the required plugins in the REQUIREMENTS section of your template. For Your convenience, and others, I'll provide them here:
http://nsis.sourceforge.net/NewAdvSplash_plug-in
http://nsis.sourceforge.net/Registry_plug-in
http://nsis.sourceforge.net/Find_Process_By_Name
http://nsis.sourceforge.net/Dialogs_plug-in
And, of course, NSIS itself:
http://nsis.sourceforge.net/
Hope this helps someone else.
BTW, please post the link here to the new thread, once You've spawned it.
I'll add this for the next version.
Hi again,
is there a way in which I can specify/reference an icon that doesn't reside in it's own .ico file? For example in order to pass the application's generic icon on to the ApplicationPortable.exe launcher, e.g. via 'iconfilename[,index]', similar to when referencing an embedded icon from an exe, dll, ico, bmp when working with autorun.inf.
An example, for the Autorun key "icon", can be found here:
http://msdn2.microsoft.com/en-us/library/bb776823.aspx
Autorun.inf Entries
Thanks!
Just a very minor detail.
At the beginning of the template, v2.3, it says:
; If a file "Registry.reg" within the data directory is found then it is read
; and all parent registry keys are processed as if they'd have been set within
; REGKEYS
I'm probably misreading/interpreting this, but shouldn't it say "...all child registry keys..." [to the one(s) specified in REGKEYS] instead of "...all parent registry keys..."?
Regards!
Hi Klonk,
I just stumbled on a major problem with the current incarnation of the Portable Application Template, i.e. 2.3. "Command line arguments", specified in EXEPARMS, are handed over to the launched application as ONE string token instead of being split into several individual tokens.
The problem is due to $R0 being quoted in this statement (on Line 659):
ExecWait '"$PROGRAMDIR\$PROGRAMEXE" "$R0"' ; run program
Removing the quotes remedies that problem, and the statement will change into:
ExecWait '"$PROGRAMDIR\$PROGRAMEXE" $R0' ; run program
After introducing that change, if one needs to specify one or more arguments - containing spaces - to the application to be launched, this is how it's done:
!define EXEPARMS "arg1 $\"arg2 contains blanks$\" arg3"
or
!define EXEPARMS 'arg1 $\"arg2 contains blanks$\" arg3'
or
!define EXEPARMS `arg1 $\"arg2 contains blanks$\" arg3`
You can try this out for yourself with this batch file:
- - - - - - - - cut & past this - - - - - - - beg of - e.g. DebugArgs.bat
@echo off
rem
rem Let your Portable Application Template installer launch this batch file,
rem by setting '!define EXE "DebugArgs.bat"' in your .nsi file.
rem
echo Output from script %0%
echo.
echo Arguments:
echo.
echo arg1=%1%
echo arg2=%2%
echo arg3=%3%
echo arg4=%4%
echo arg5=%5%
echo arg6=%6%
echo arg7=%7%
echo arg8=%8%
echo arg9=%9%
echo.
echo.
pause
- - - - - - - - cut & past this - - - - - - - end of - e.g. DebugArgs.bat
Cheers
I'm pretty sure that this
!define EXEPARMS 'arg1 $\"arg2 contains blanks$\" arg3'
and this
!define EXEPARMS 'arg1 "arg2 contains blanks" arg3'
output the same string. When mixing quotes there's no need to escape the inside quotes. Unless I messed up my testing?
--------
Section
StrCpy $EXESTR "Path to EXE"
StrCpy $EXEARG 'arg1 "arg2 has space" arg3'
MessageBox MB_OK '"$EXESTR" $EXEARG'
SectionEnd
wraithdu,
I'm sorry if I have to make You disappointed here (or it's me that messed up my testing).
Try my batch script and You'll see that You will end up with different number of arguments passed to/received by the script.
NOTE, handling strings within the .nsi environment itself, is different to exporting them as arguments, like in this case were the OS command parser will become involved.
Greetings!
the commandline will be given "some stuff", which depending on the application might not be wanted... Will be fixed with next version...
To "automagically" have support for multiple versions of the Java Runtime Environment would be very useful. But I'm not sure I manage to figure out how it's implemented, or supposed to work.
Irrespectively of the version of the JRE, if I for example have a portable JRE installed in /PortableApps/CommonFiles/Java[/bin], I can launch that version of Java explicitly by specifying e.g. (relative to App\$APP\):
!define EXE "..\..\..\CommonFiles\Java\bin\java.exe"
or (if I don't want to have a Console Window open)
!define EXE "..\..\..\CommonFiles\Java\bin\javaw.exe"
Of course, this defeats the "dynamic" lookup of the JRE executables.
Usually, one launches either the targeted JRE/bin/java[w][.exe] explicitly OR adds the bin directory of the desired java[w].exe to the PATH environment variable, after which one can just type 'java ...' or 'javaw ...' to launch Java.
Now, I've noticed, the Portable Application Template allows me to specify (well, rather recommend) a certain release of java via the USEJAVAVERSON variable, e.g. by setting it to "1.5.0_12". I'm not sure I understand the point hereby, since:
1). By doing this there is an environment variable (JAVA_HOME) being set [why? I don't know - JRE doesn't require this as it can be dynamically retrieved in Java via "System.getProperty('java.home');"], and the value of '$JAVA_HOME\bin' is added to the PATH environment variable (which does make sense - although there is still no need to introduce the variable JAVA_HOME).
2). even if I now have, the "dynamically" assigned, JRE in the path, I cannot launch java by specifying just 'java[.exe]' or 'javaw[.exe]' in the !define EXE statement. Trying to do this will lead to a pop-up message with the following content at the execution (not compilation) of the launcher:
+------------------------------------------------------------
| Application Portable - 0.0.0.0
+--------------------------------------
|
| ! java[.exe] was not found.
| Do you want to copy your local installation into your portable applications directory? (This could take some time)
|
| When you select "NO" this launcher will be terminated. In this case, please copy the necessary files yourself.
|
| [ Yes ] [ No ]
|
+--------------------------------------
Since this doesn't work, and I don't seem to be able to figure out how to take advantage of the "dynamic" JRE discovery by myself, I'd be very grateful if someone could enlighten me here.
Best regards!
BTW, asserting that the correct version of Java is used for your Java program is usually accomplished by starting it via e.g. 'java -version:1.6 ...', which will fail w/ a message like below if no jre1.6.x cannot be localized on the system:
X:\> java -version:1.6 [...optionally remaining args here]
Unable to locate JRE meeting specification "1.6"
This is how it could look like if it's found (and we, in addition, specify just the plain -version argument)
X:\> java -version:1.5 -version
java version "1.5.0_12"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-b04)
Java HotSpot(TM) Client VM (build 1.5.0_12-b04, mixed mode)
Ok, so I ran the full test this time. This
and this
produce the exact same command window output. I think we're agreeing with eachother here, and arguing about it LOL.
Hello wraithdu,
yes You did, and now I also know why You see the same output in both cases. You're running a "clean room" envionment, NOT the Portable Application Template v2.3.
Try the same using PAT and You'll see that the NSIS compiler will bail out at line 653, because ${EXEPARMS} in that line is quoted w/ "double quotes". If one changes the quoting to use back quotes instead You'll succeed (but then You'll presumably fail in the case of using back quotes in the mix).
Removing the quotes entirely will result in no arguments being passed at all.
So, let's agree upon two things:
1). It's PAT that breaks nested sting handling, not the NSIS scripting language.
2). I was wrong when assuming it had something to do with the Windows shell.
I don't know whether there is a way in which PAT can be modified to handle all the supported quoting methods described below, or not.
http://nsis.sourceforge.net/How_can_I_use_quotes_in_a_string
Regards
Ok, I've got the big picture now. I think the solution is on line 755 (template v2.4, just downloaded today) -
StrCpy $R0 `${EXEPARMS}`
Using backquotes here prevents any mishandling of nested single and double quotes. Then in line 30 you can use any combination of single and double quotes to satisfy whatever program you're passing args to -
!define EXEPARMS 'arg1 "arg2 contains blanks" arg3'
or
!define EXEPARMS "arg1 $\"arg2 contains blanks$\" arg3"
both work fine now.
The underlying problem is the !define directive during compile time. If a referenced define is empty, ie ${EXEPARMS}, and is NOT quoted, then the compile exits with incorrect syntax for the given command, in this case StrCpy (too few arguments).
Furthermore, an unquoted definition is taken as a literally typed string, ie
!define TEST "one two three"
${TEST} equals three arguments, "one", "two", and "three"
and "${TEST}" now equals one argument, "one two three"
whereas
StrCpy $TEST "one two three"
$TEST and "$TEST" both equal one argument "one two three"
Quoting `${EXEPARMS}` will allow compile even if it is an empty variable.
This is not the case with a regular variable, ie $R0. Even if it is empty and unquoted, the compiler recognizes it as a valid argument.
So there, apparently !define sucks LOL
and removing the double quotes in the Exec and Execwait should be perfect to solve that.
BTW:Please post any problems to the new thread. Thanks.
Pages