Archive: Changing Path in a .cmd File


Changing Path in a .cmd File
Hi there..

gona ask my question so stupid, but i couldnt find a solution. In my setup i got a cmd File looks like this:

cd C:\Programme\Maintlog5
PATH=%SYSTEMROOT%\SYSTEM32;%SYSTEMROOT%;C:\Plex5\Maintlog\Build\Release;\\DevSvr\ObBuild500\Maintlog\Client\GER\Release;
START MAINTLOG.EXE


But the problem i got - the path i.m.e. "C:\Programme\Maintlog5" is the Intallpath and with the routine the User could change this path. Someone got a idea how i could change the cmd line linking into the install Dir? tnx

Use this script: http://nsis.sourceforge.net/archive/....php?pageid=17

You can get it to FileOpen your cmd file and change the lines of
e.g.

C:\Programme\Maintlog5

to

$INSTDIR



Function ReplaceText
ClearErrors
FileOpen $0 "$INSTDIR\cmdfile.bat" "r"
GetTempFileName $R0
FileOpen $1 $R0 "w"
loop:
FileRead $0 $2
IfErrors done
StrCmp $2 "C:\Programme\Maintlog5$\r$\n" 0 +3
FileWrite $1 "$INSTDIR$\r$\n"
Goto loop
StrCmp $2 "C:\Programme\Maintlog5" 0 +3
FileWrite $1 "$INSTDIR"
Goto loop
FileWrite $1 $2
Goto loop

done:
FileClose $0
FileClose $1
Delete "$INSTDIR\cmdfile.bat"
Rename $R0 "$INSTDIR\cmdfile.bat"
FunctionEnd


Remember to extract the cmd file before calling the script.
Remember to call the script after allowing the user to specify the InstallDir first.
Maybe call it (Call ReplaceText) in the .onInstSuccess Function.

-Stuart

You don't need a batch/.cmd file to do that. To change the working directory you can use SetOutPath, to set enviroment variables you can use this, and to execute files you can use Exec, ExecWait, ExecShell, or nsExec.