Archive: Problem executing file


Problem executing file
Hi..

I am creating a new installer.

Currently I have the following directory structure: The root folder in which I am working is C:\test. Inside test, I have the following folders:

files
->regfolder
->register.bat
installer
->installer.nsi

Inside files folder, I have a file called register.bat (in the regfolder subfolder) which has got some commands which I intend to run during installation.
installer folder contains my nsi script and after compilation, this is where the exe is created.

After installation, only the files folder and its contents are stored in the program files directory of my program.

The thing is that...during installation, I want to run the register.bat. I have tried with no success. I am using the following command:

ExecWait '".\files\regfolder\register.bat" doRegister $0 $0 $1 $2' $0

The script bat file doesnt get executed. I just get a cmd shell for less than a second and it disappears. Please could someone tell me what I am doing wrong?

Thanks a lot in advance.


I don't think ExecWait works when calling the batch file directly. You'll probably want to call the command interpreter directly with the batch file as a parameter using either the nsExec plugin or ExecWait. (Unless you needed input from the user, I'd suggest using nsExec to hide the command window. Something like this should work (borrowed from a post by AfrowUK in this thread):


ReadEnvStr $R0 COMSPEC
nsExec::Exec `"$R0" /C ".\files\regfolder\register.bat"`
Pop $R0

Hi comperio...


thanks for your response. Now that part of my code works. However, I have some other questions....


How do I test for empty text fields when the next button is clicked on a custom dialog?

How can I set up the onClick function for the BrowseButton Element of a DirRequest?

How do I make the text fields remember input? For example, from dialog 1, I type some stuff into the fields on that dialog and click next. When I click prev, I want to be able to see the information that was typed there previously.


Thanks a lot in advance for your answers.


How do I test for empty text fields when the next button is clicked on a custom dialog?
Use use a page callback function (also referred to as the page's leave function).
Example:
; assume $0 is value of text
${If} "$0" == ""
MessageBox MB_OK "Blank not allowed"
abort
${EndIf}


How can I set up the onClick function for the BrowseButton Element of a DirRequest?
I'm not sure, but probably you'd have to modify the source to allow a callback. My suggestion would be to create your own custom page rather than try to use the stock directory page. That way, you'll have full control over everything.

How do I make the text fields remember input? For example, from dialog 1, I type some stuff into the fields on that dialog and click next. When I click prev, I want to be able to see the information that was typed there previously.
Assuming you are using nsDialogs, you'd store the value in a variable and then use that to set the defaults at page load. (See the "memory" section of the nsDialogs readme, which is included with NSIS.)