Archive: How to translate this .bat file?


How to translate this .bat file?
Hy!

I am newbie nsis user:cool:
I want change from my .bat files to NSIS script files.
How to translate this .bat file to .nsi script?
I need "md" variable to work under nsis.
Thanks in advance.

ps: sorry my wrong english

code:

if exist c:\myapp\myapp.exe goto drvc
if exist d:\myapp\myapp.exe goto drvd
if exist e:\myapp\myapp.exe goto drve
goto end

:drvc
set md=c
goto start

:drvd
set md=d
goto start

:drve
set md=e
goto start

:start
%md%:
cd\
del %md%:\myapp\11.dat
del %md%:\myapp\12.dat
copy a:\11.dat %md%:\myapp
copy a:\12.dat %md%:\myapp


Why not use WriteRegStr HKEY_LOCAL_MACHINE "Software\yourapp" "Install_Dir" "$INSTDIR"
during the install, and put
InstallDirRegKey HKEY_LOCAL_MACHINE "Software\yourapp" "Install_Dir"
at the top of the script, so if the program has been installed before then the installer will default to the directory used last time.

Or if your really lazy you could just make NSIS unpack the batch file etc into a temporary directory, run it, and then delete the temporary stuff- makes using NSIS at all a bit pointless though I suppose :p :p :p

I assume you've already worked out to use File instead of copy and Delete instead of Del.


prodangle: thx to reply, but:

We have many "myapp" programs (this is old dos-based program) in same computer, and i don't know, what is the drive letter (eg. c, d, e, etc.). I need the drive letter to upgrade:

del %md%:\myapp\11.dat
del %md%:\myapp\12.dat
copy a:\11.dat %md%:\myapp
copy a:\12.dat %md%:\myapp

I hope you understand me:)
Thanks in advance, and sorry my wrong english (i don't speak english, and one dictionarry is in my left hand now:().

JB


I think this'll work:


IfFileExists c:\myapp\myapp.exe cdrv nocdrv
cdrv:
SetOutPath c:\myapp
nocdrv:

IfFileExists d:\myapp\myapp.exe ddrv noddrv
ddrv:
SetOutPath d:\myapp
noddrv:

IfFileExists e:\myapp\myapp.exe edrv noedrv
edrv:
SetOutPath e:\myapp
noedrv:

SetOverwrite on
File 11.dat
File 12.dat

Of course you'll still need

Dirshow Hide

at the top of the script, along with all the other stuff (sections etc) but should be simple to copy from one of the sample scripts.

Hope that helps.


Hi

I modify your example a little bit:

;Detect Drive Letter
Function .onInit
IfFileExists c:\myapp.exe cdrv nocdrv
cdrv:
StrCpy $INSTDIR c:\
nocdrv:

IfFileExists d:\myapp.exe ddrv noddrv
ddrv:
StrCpy $INSTDIR d:\
noddrv:

IfFileExists e:\myapp.exe edrv noedrv
edrv:
StrCpy $INSTDIR e:\
noedrv:
FunctionEnd
Section
SetOverwrite on
SetOutPath $INSTDIR\myapp
Del $INSTDIR\myapp_lib\*.tmp
Del $INSTDIR\myapp_lib\*.cdx
Del $INSTDIR\myapp_drawing\*.tmp
;etc.
File d:\myapp_update\11.dat
File d:\myapp_update\11.dat
SectionEnd


...and this work!! $INSTDIR=%md% variable, this is the thing whereto i need.
Many thanks prodangle, and good luck!

JB