You are here

Need help

9 posts / 0 new
Last post
terra666
Offline
Last seen: 3 years 9 months ago
Joined: 2014-06-22 13:42
Need help

Hi,
I need to move a certain folder when the program is running on a 32-bit system and a different folder when on 64-bit system. Lets call them folder_32 & folder_64 respectively.

Custom.nsh

${SegmentFile}
${Segment.OnInit}
; Borrowed the following from PAL 2.2, Remove on release of PAL 2.2
; Work out if it's 64-bit or 32-bit
System::Call kernel32::GetCurrentProcess()i.s
System::Call kernel32::IsWow64Process(is,*i.r0)
${If} $0 == 0
StrCpy $Bits 32
${Else}
StrCpy $Bits 64
${EndIf}
!macroend

${SegmentInit}
${If} $Bits = 64
${SetEnvironmentVariablesPath} folderG "$EXEDIR\Data\folder_64"
${Else}
${SetEnvironmentVariablesPath} folderG "$EXEDIR\Data\folder_32"
${EndIf}
!macroend

and in AppsNamePortable.ini

[DirectoriesMove]
folderG=%PAL:APPDIR%\AppNamePortable\folder

for some reason it does not move folder_32 or folder_64 depending on the system.

Gord Caswell
Gord Caswell's picture
Offline
Last seen: 3 days 11 hours ago
DeveloperModerator
Joined: 2008-07-24 18:46
What is happening

In that case, what is> happening?

John T. Haller
John T. Haller's picture
Offline
Last seen: 6 hours 30 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Environment Variables Need %

Since folderG is an environment variable, it should be listed as %folderG% within your launcher INI.

Sometimes, the impossible can become possible, if you're awesome!

terra666
Offline
Last seen: 3 years 9 months ago
Joined: 2014-06-22 13:42
Tried it both ways

Tried it both ways. No results.

JLim
Offline
Last seen: 4 months 4 weeks ago
Joined: 2013-07-17 01:30
If I remember correctly, the

If I remember correctly, the left hand side of the = sign in Launcher ini can not be a variable.
I try to convert what you want to the following custom code.
btw if you are using the latest version of "PortableApps.com Launcher", the ${Segment.OnInit} part need not anymore as it has been build in now.
==========================================================
${SegmentFile}

Var folderG

${SegmentInit}
${If} $Bits = 64
StrCpy $folderG "$EXEDIR\Data\folder_64"
${Else}
StrCpy $folderG "$EXEDIR\Data\folder_32"
${EndIf}
!macroend

${SegmentPreExecPrimary}
${If} ${FileExists} "$EXEDIR\App\AppNamePortable\folder"
RMDir /r "$folderG"
${Else}
Rename "$folderG" "$EXEDIR\App\AppNamePortable\folder"
${EndIf}
!macroend

${SegmentPostPrimary}
Rename "$EXEDIR\App\AppNamePortable\folder" "$folderG"
!macroend
==========================================================
hope this help.

John T. Haller
John T. Haller's picture
Offline
Last seen: 6 hours 30 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Correct IIRC

I haven't looked at the code in a while, but I think you're correct that the left variable can't be a variable.

Sometimes, the impossible can become possible, if you're awesome!

terra666
Offline
Last seen: 3 years 9 months ago
Joined: 2014-06-22 13:42
After posting the code here

After posting the code here and seeing the answeres I was able to simplify my code to something like these:
Custom.nsh

Var /GLOBAL BaseDir
Var /GLOBAL Folder_Base
Var /GLOBAL Folder_32
Var /GLOBAL Folder_64


${SegmentInit}
	# The Global of AppNamePortable Folder
	StrCpy $BaseDir "$EXEDIR\App\AppName"
	
	# The Location of folders
	StrCpy $Folder_Base "$BaseDir\Folder\*.*"
	StrCpy $Folder_32 "$EXEDIR\App\Folder\x32\*.*"
	StrCpy $Folder_64 "$EXEDIR\App\Folder\x64\*.*"
		
	${ReadUserConfig} $0 Run64bit
    ${If} $Bits = 64 
	${AndIf} Run64bit = "true"
		Rename "$Folder_64" "$Folder_Base"
	${Else}
		Rename "$Folder_32" "$Folder_Base"
    ${EndIf}
!macroend


${SegmentPost}
	#Restores Structure to original 
	${If} ${FileExists} "$Folder_64"
		Rename "$Folder_Base" "$Folder_32"
	${EndIf}
	${If} ${FileExists} "$Folder_32"
		Rename "$Folder_Base" "$Folder_64"
	${EndIf}

However, now for some reason the ${AndIf} is not working

JLim
Offline
Last seen: 4 months 4 weeks ago
Joined: 2013-07-17 01:30
The ${AndIf} part should be:

The ${AndIf} part should be:
${AndIf} $0 == "True"

terra666
Offline
Last seen: 3 years 9 months ago
Joined: 2014-06-22 13:42
Thank you.

Thank you.

Log in or register to post comments