Archive: How to get a directory deleted *after* executing a file?


How to get a directory deleted *after* executing a file?
Okay, I want to do the following: Install a bunch of files to a certain directory, and then at the end of the install it executes a file that compiles certain files and copies others. After the executable is done that, I want to remove the directories that the executable copied/compiled the files from. However I tried using the following nsi script:

# [Installer Attributes]
Name "Norse Mini Mod"
OutFile "norseinstaller.exe"
Caption "Norse Mini Mod Setup"
BrandingText ""



# [Additional Installer Settings ]
ShowInstDetails show
AutoCloseWindow false
SilentInstall normal
CRCCheck on
SetCompress auto
SetDatablockOptimize on
SetOverwrite on

# [Background Gradient]
BGGradient 808000 804040 FFFFFF

# [Files]
Section "default"
SetOutPath $INSTDIR
File /r "C:\Program Files\Black Isle\BGII - SoA\norsemod"
File "C:\Program Files\Black Isle\BGII - SOA\NorseSetup.exe"
SectionEnd

# [Directory Selection]
InstallDir "$PROGRAMFILES\Black Isle\BGII - SOA"

# [Registry Get]
InstallDirRegKey HKLM \
"Software\Microsoft\Windows\CurrentVersion\App Paths\BG2Main.Exe" \
"Path"


DirShow show
DirText "Select your default BGII - SoA directory."

;called when the installer is nearly finished initializing
Function .onInit

;message box
MessageBox MB_YESNO "This will install the Norse Mini Mod. Continue?" IDYES NoAbort
Abort
NoAbort:
FunctionEnd

;called when the user hits the 'cancel' button
Function .onUserAbort
MessageBox MB_YESNO "Abort install?" IDYES NoCancelAbort
Abort
NoCancelAbort:
FunctionEnd

;called when the install was successful
Function .onInstSuccess
CreateDirectory "$INSTDIR\backup"
Exec "$INSTDIR\NorseSetup.exe norsemod/norsemod.tp2 --tlkout dialog.tlk"
RMDir /r "$INSTDIR\norsemod"
Delete "$INSTDIR\norsesetup.debug"

FunctionEnd



#eof!

And it runs the executable at the end, howvever it deletes the directory before the executable can compile/copy the files to the appropriate directories...

Any thoughts on how to do this?

Thanx in advance.


japbeth,

use ExecWait instead of Exec to execute the decompressor. Then it will wait for the decompressor to finish and shut down and then the script will continue and remove the dir. Maybe you should also include a delete command to delete the files in this dir first otherwise it will not be possible to remove the dir. It's only a suggestion, because I don't know what the decompressor will do with the source files. Maybe it will already delete them, hey, I don't know...

So anyway, just use ExecWait...

Good luck, greetz,
-Hendri.


And why clear the branding text if you have nothing else to put there and didn't modify the source?

That just seems mean to me.

-Scott


Re: How to get a directory deleted *after* executing a file?

Originally posted by japheth
File /r "C:\Program Files\Black Isle\BGII - SoA\norsemod"
File "C:\Program Files\Black Isle\BGII - SOA\NorseSetup.exe"

I'd make sure on all instructions similar to this that you change them to something like File /r '"C:\Program Files\Black Isle\BGII - SoA\norsemod"'

Don't think there should be any problems, but with the spaces in the path you might end up with it delimiting the path incorrectly in some commands. I think that NSIS will straighten things up for you internally, but better to double check anyway.