You are here

NSIS Script is not moving directory.... Please Help!

9 posts / 0 new
Last post
Espreon
Espreon's picture
Offline
Last seen: 12 years 3 months ago
Joined: 2006-09-29 18:23
NSIS Script is not moving directory.... Please Help!

Yeah the only roadblock in making MoinMoinDE Portable is the wiki folder in Data\settings folder is not being moved back to App\moinmoin when MoinMoinDE is closed after the 1st run it moves the wiki folder to the Data\settings folder but 2nd run and so forth the launcher is not moving the wiki folder from Data\settings back to App\moinmoin

The wiki folder has 3 sub-directories

Heres the .nsi:

;Copyright (C) 2004-2007 John T. Haller

;Website: http://armogohmasuites.sf.net/wiki/MoinMoinPortable

;This software is OSI Certified Open Source Software.
;OSI Certified is a certification mark of the Open Source Initiative.

;This program is free software; you can redistribute it and/or
;modify it under the terms of the GNU General Public License
;as published by the Free Software Foundation; either version 2
;of the License, or (at your option) any later version.

;This program is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;GNU General Public License for more details.

;You should have received a copy of the GNU General Public License
;along with this program; if not, write to the Free Software
;Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

!define NAME "MoinMoin Portable"
!define FRIENDLYNAME "MoinMoin Portable"
!define APP "MoinMoin"
!define VER "1.3.0.0"
!define WEBSITE "http://armogohmasuites.sf.net/wiki/MoinMoinPortable"

;=== Program Details
Name "${NAME}"
OutFile "${NAME}.exe"
Caption "${FRIENDLYNAME} | ArmogohmaSuites"
VIProductVersion "${VER}"
VIAddVersionKey ProductName "${FRIENDLYNAME}"
VIAddVersionKey Comments "Allows ${APP} to be run from a removable drive.  For additional details, visit ${WEBSITE}"
VIAddVersionKey CompanyName "Armogohmasuites"
VIAddVersionKey LegalCopyright "John T. Haller"
VIAddVersionKey FileDescription "${FRIENDLYNAME}"
VIAddVersionKey FileVersion "${VER}"
VIAddVersionKey ProductVersion "${VER}"
VIAddVersionKey InternalName "${FRIENDLYNAME}"
VIAddVersionKey LegalTrademarks "PortableApps.com is a Trademark of Rare Ideas, LLC."
VIAddVersionKey OriginalFilename "${NAME}.exe"
;VIAddVersionKey PrivateBuild ""
;VIAddVersionKey SpecialBuild ""

;=== Runtime Switches
CRCCheck On
WindowIcon Off
SilentInstall Silent
AutoCloseWindow True
RequestExecutionLevel user

;=== Program Icon
Icon "${NAME}.ico"

Section "Main"
	;=== Check if already running
	System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${NAME}") i .r1 ?e'
	Pop $0
	StrCmp $0 0 CheckINI TheEnd
	
	CheckINI:
		;=== Find the INI file, if there is one
		IfFileExists "$EXEDIR\MoinMoinPortable.ini" ""

		;=== Read the parameters from the INI file
		ReadINIStr $0 "$EXEDIR\MoinMoinPortable.ini" "MoinMoinPortable" "DisableSplashScreen"
		StrCmp $0 "true" SkipSplashScreen

ShowSplash:
		;=== Show the splash screen before processing the files
			InitPluginsDir
			File /oname=$PLUGINSDIR\splash.jpg "${NAME}.jpg"
			newadvsplash::show /NOUNLOAD 1200 100 0 -1 /L $PLUGINSDIR\splash.jpg

	SkipSplashScreen:
		;=== Check for data files
                IfFileExists `$EXEDIR\Data\settings\wiki\` MoveSettings
                IfFileExists `$EXEDIR\Data\settings\wikiconfig.py` MoveSettings
		IfFileExists `$EXEDIR\Data\settings\*.*` MoveSettings
			CreateDirectory `$EXEDIR\Data\settings`

	MoveSettings:
		Rename `$EXEDIR\Data\settings\wiki` `$EXEDIR\App\moinmoin`
        Rename `$EXEDIR\Data\settings\wikiconfig.py` `$EXEDIR\App\moinmoin\wikiconfig.py`

	LaunchNow:
		SetOutPath `$EXEDIR\App\moinmoin`
		ExecWait `$EXEDIR\App\moinmoin\moin.exe`

		;=== Move settings back
		        RMDir /r `$EXEDIR\Data\settings\wiki`
		        Rename "$EXEDIR\App\moinmoin\wiki" "$EXEDIR\Data\settings\wiki"
                Delete `$EXEDIR\Data\settings\wikiconfig.py`
                Rename "$EXEDIR\App\moinmoin\wikiconfig.py" "$EXEDIR\Data\settings\wikiconfig.py"

	TheEnd:
		newadvsplash::wait
SectionEnd

Please tell me what is preventing the wiki folder from being moved back to App\moinmoin

Thanks

rab040ma
Offline
Last seen: 5 months 5 days ago
Joined: 2007-08-27 13:35
program flow

Can you say where you expect the program is copying the the settings, which line?

One obvious question is whether the mutex stuff is causing the program to jump to the end, which might happen if a previous version is still running (you could check that with Process Explorer).

It might be good to add more comments about what you think each statement is doing and why you want it to do it.

One statement that looks odd is the line 64, where your program checks for the existence of the ini file, but doesn't do anything (you don't give it either a jump_if_present or a jump_otherwise option). Maybe you had something in mind there?

You might also want to test for errors and/or file existence in a few more places, like in the "move settings back" area -- maybe the files are still locked and the rename/move is failing? You could also stick a message box in there, to let you know (for testing) that it is actually getting to that point.

MC

Patrick Patience
Offline
Last seen: 4 years 11 months ago
DeveloperModerator
Joined: 2007-02-20 19:26
Try

Rename `$EXEDIR\App\settings\*.*` `$EXEDIR\App\moinmoin`

I'm pretty sure you can't rename the folder to somewhere else, but you can rename the contents of a folder, so renaming the contents of settings will rename the 'wiki' folder to the moinmoin dir.

wraithdu
Offline
Last seen: 11 years 5 months ago
Developer
Joined: 2007-06-27 20:22
@HSP

@HSP
Actually Rename only works for files or directories, no wildcards, so he's using it correctly. The problem is exactly what I mentioned LAST time he asked this question. This line under 'move settings back' -

Rename "$EXEDIR\App\moinmoin\wiki" "$EXEDIR\Data\settings\wiki"

There is no $EXEDIR\App\moinmoin\wiki directory ever created, so after program close nothing is moved back to the Data\settings directory.

Also in your 'move settings back' section, you should move your wikiconfig.py file BEFORE you move the rest of the directory, otherwise it won't be there for the next command.

Patrick Patience
Offline
Last seen: 4 years 11 months ago
DeveloperModerator
Joined: 2007-02-20 19:26
Wow, I'm not Crazy

I thought he asked this question twice. Phew.

I thought rename worked for wildcards...maybe not.

But yes, if it's not created, it can't move.

Espreon
Espreon's picture
Offline
Last seen: 12 years 3 months ago
Joined: 2006-09-29 18:23
The reason

why I asked this again is because the previous topic is gone...

As 4 you wraithdu... when you mean "the line" are you talkin about the line that uses the rmdir command? The wiki folder exists by default in an install of MMDE, the wiki folder IS being moved from the App to the Data folder, but not vice-versa...

wraithdu
Offline
Last seen: 11 years 5 months ago
Developer
Joined: 2007-06-27 20:22
Here...
MoveSettings:
	Rename `$EXEDIR\Data\settings\wiki` `$EXEDIR\App\moinmoin`
        Rename `$EXEDIR\Data\settings\wikiconfig.py` `$EXEDIR\App\moinmoin\wikiconfig.py`

Here you move settings\wiki to the main App\moinmoin directory, so that everything that was in settings\wiki is now in App\moinmoin. Note that there is no App\moinmoin\wiki directory here. To do that, you would need this line -

Rename `$EXEDIR\Data\settings\wiki` `$EXEDIR\App\moinmoin\wiki`

		;=== Move settings back
		        RMDir /r `$EXEDIR\Data\settings\wiki`
		        Rename "$EXEDIR\App\moinmoin\wiki" "$EXEDIR\Data\settings\wiki"
                Delete `$EXEDIR\Data\settings\wikiconfig.py`
                Rename "$EXEDIR\App\moinmoin\wikiconfig.py" "$EXEDIR\Data\settings\wikiconfig.py"

Here you're removing the original settings\wiki dir, which doesn't exist anyway since you moved it above.

Then you're moving App\moinmoin\wiki to settings\wiki...but as noted above, there is no App\moinmoin\wiki directory to move, so this fails.

Here's my guess on how the whole thing should look -

MoveSettings:
	Rename `$EXEDIR\Data\settings\wiki` `$EXEDIR\App\moinmoin\wiki`
        Rename `$EXEDIR\Data\settings\wikiconfig.py` `$EXEDIR\App\moinmoin\wikiconfig.py`

	LaunchNow:
		SetOutPath `$EXEDIR\App\moinmoin`
		ExecWait `$EXEDIR\App\moinmoin\moin.exe`

		;=== Move settings back
		Rename "$EXEDIR\App\moinmoin\wiki" "$EXEDIR\Data\settings\wiki"
                Rename "$EXEDIR\App\moinmoin\wikiconfig.py" "$EXEDIR\Data\settings\wikiconfig.py"
rab040ma
Offline
Last seen: 5 months 5 days ago
Joined: 2007-08-27 13:35
quietly failing

Again, if he is using Rename, he should be aware that it can fail without notifying anyone. At least while debugging, he should check for an error state. That would let him know immediately where the rename is failing. If the launcher is going to be made public, he should probably put in error handling for all the instructions that fail silently ... although the handling could be to let it fail silently, if all possible error states have been anticipated. But as this situation demonstrates, it is easy to assume that something will be one way, and just as easy for the computer to prove the assumption wrong in the most confusing and confounding way possible.

MC

Espreon
Espreon's picture
Offline
Last seen: 12 years 3 months ago
Joined: 2006-09-29 18:23
Uh Thanks

wraithdu, but I finally got the wiki folder to move back to App\moinmoin after tinkering around with the .nsi during lunch.

Log in or register to post comments