You are here

Help with ReplaceInFile command

3 posts / 0 new
Last post
Jacob Mastel
Offline
Last seen: 5 months 1 week ago
Developer
Joined: 2007-06-13 19:36
Help with ReplaceInFile command

I'm working on a launcher that will create file associations for .ssk and .sti files. I can't seem to get the registry to work though. Everytime I go through the Replace in file command it messes up the .reg file. It goes up from a couple KB's to 800 and tells me only binary data can be put into the registry. If anybody could help I'd appreciate it. My code is:

Outfile ..\..\StickiesPortable.exe
Name Stickies Portable
Icon "..\..\App\AppInfo\appicon.ico"
SilentInstall Silent
AutoCloseWindow True
RequestExecutionLevel user

!include "FileFunc.nsh"
!include "ReplaceInFile.nsh"
!include "Registry.nsh"
!include "StrRep.nsh"
!insertmacro GetRoot

Var APPDIR
Var DDATA
Var SETDIR

Section Main

	DefineVariables:
		StrCpy "$APPDIR" "$EXEDIR\App\Stickies"
		StrCpy "$DDATA" "$EXEDIR\App\DefaultData"
		StrCpy "$SETDIR" "$EXEDIR\Data\Settings"
	
	CheckStickies.ini:
		IfFileExists "$SETDIR\stickies.ini" CheckPortable.ini
			CopyFiles "$DDATA\stickies.ini" "$SETDIR\stickies.ini"

	CheckPortable.ini:
		IfFileExists "$SETDIR\StickiesPortable.ini" CheckSplash
			CopyFiles "$DDATA\StickiesPortable.ini" "$SETDIR\StickiesPortable.ini"
		
	CheckSplash:
		ReadINIStr $0 "$SETDIR\StickiesPortable.ini" "Settings" "DisplaySplash"
		StrCmp $0 "false" UpdatePaths

	ShowSplash:
		newadvsplash::show /NOUNLOAD 1200 0 0 -1 /L "$EXEDIR\Other\Source\stickies portable.jpg"
		
	UpdatePaths:
		${GetRoot} $EXEDIR $1
		ReadINIStr $2 "$SETDIR\StickiesPortable.ini" "Settings" "LastDrive"
		${ReplaceInFile} "$SETDIR\stickies.ini" "$2" "$1"
		${ReplaceInFile} "$SETDIR\StickiesPortable.ini" "$2" "$1"
		${ReplaceInFile} "$SETDIR\Stickies.reg" "$2" "$1"
		${registry::RestoreKey} "$SETDIR\Stickies.reg" $R2
		${registry::RestoreKey} "$SETDIR\StickyExtentions.reg" $R1
		Delete "$SETDIR\Stickies.reg.old"
		Delete "$SETDIR\stickies.ini.old"
		Delete "$SETDIR\StickiesPortable.ini.old"
		
	MoveFiles:
		Rename "$SETDIR\stickies.ini" "$APPDIR\stickies.ini"
		Rename "$SETDIR\StickiesPortable.ini" "$APPDIR\StickiesPortable.ini"
		Rename "$EXEDIR\Data\store.mdb" "$APPDIR\store.mdb"
	
	LaunchApp:
		SetOutPath "$APPDIR\"
		Sleep 1000
		ExecWait "$APPDIR\stickies.exe"
		
	CheckRunning:
		Sleep 1000
		FindProcDLL::FindProc "${DEFAULTEXE}"                  
		StrCmp $R0 "1" CheckRunning

	MoveFilesBack:
		Sleep 500
		Rename "$APPDIR\stickies.ini" "$SETDIR\stickies.ini"
		Rename "$APPDIR\StickiesPortable.ini" "$SETDIR\StickiesPortable.ini"
		Rename "$APPDIR\store.mdb" "$EXEDIR\Data\store.mdb"
		Sleep 500
		DeleteRegKey HKCR ".ssk"
		DeleteRegKey HKCR ".sti"
		DeleteRegKey HKCR "stickyfile"
		DeleteRegKey HKCR "stickyskin"
	
	TheEnd:
		newadvsplash::stop /WAIT
SectionEnd

The Registry Key Includes:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Stickyfile]

[HKEY_CLASSES_ROOT\Stickyfile\DefaultIcon]
@="F:\\PortableApps\\StickiesPortable\\App\\Stickies\\stickies.exe,5"

[HKEY_CLASSES_ROOT\Stickyfile\shell]
@="open"

[HKEY_CLASSES_ROOT\Stickyfile\shell\open]

[HKEY_CLASSES_ROOT\Stickyfile\shell\open\command]
@="\"F:\\PortableApps\\StickiesPortable\\App\\Stickies\\stickies.exe\" \"%1\""

[HKEY_CLASSES_ROOT\StickySkin]

[HKEY_CLASSES_ROOT\StickySkin\DefaultIcon]
@="F:\\PortableApps\\StickiesPortable\\App\\Stickies\\stickies.exe,2"

[HKEY_CLASSES_ROOT\StickySkin\shell]
@="open"

[HKEY_CLASSES_ROOT\StickySkin\shell\open]

[HKEY_CLASSES_ROOT\StickySkin\shell\open\command]
@="\"F:\\PortableApps\\StickiesPortable\\App\\Stickies\\stickies.exe\" \"%1\""

wraithdu
Offline
Last seen: 11 years 10 months ago
Developer
Joined: 2007-06-27 20:22
Can you post the contents of

Can you post the contents of your reg file? Also, are you sure the file isn't unicode? If you made it yourself, make sure you exported it as a Win9x/NT4 Reg file.

One quick fix -

LaunchApp:
		SetOutPath "$APPDIR"

There shouldn't be a trailing slash after the path.

Jacob Mastel
Offline
Last seen: 5 months 1 week ago
Developer
Joined: 2007-06-13 19:36
Thanks!

I was the way I was creating the .reg file. I wasn't exporting it right. Also thanks for the type on the SetOutPath.

Release Team Member

Log in or register to post comments