# Solved: Batch script to install an application



## jat421 (Jun 14, 2008)

Hi guys,

I am trying to put together a script that will uninstall and then install an application if the user has a specific folder on his/her computer.

This is what I got so far


```
IF NOT EXIST "C:\Program Files\temp\NUL" GOTO EXIT ELSE GOTO RUN
:RUN
msiexec /qb /uninstall [URL="file://\\server\uninstall\1eee0a40.msi"]\\server\uninstall\1eee0a40.msi[/URL] REBOOT=Suppress
msiexec /qb /l* C:\NCS-Log.txt /i [URL="file://\\server\install\setup.msiREBOOT=Suppress"]\\server\install[URL="file://\\yyz-fs\sys\Public\NCS_Install\setup.msi"]\setup.msi[/URL][/URL]
REBOOT=Suppress
 
:EXIT
exit
```
When I run this script it tries to remove the application even if the temp folder doesn't exits. What am I doing wrong?. Thanks a lot for your help!!!


----------



## TheOutcaste (Aug 8, 2007)

Your script seems to work fine for me on XP MCE. I tested by putting in some echo statements and commenting out the msiexec lines:

```
IF NOT EXIST "C:\Program Files\temp\NUL" GOTO EXIT ELSE GOTO RUN
:RUN
@echo in run section
REM msiexec /qb /uninstall \\server\uninstall\1eee0a40.msi REBOOT=Suppress
REM msiexec /qb /l* C:\NCS-Log.txt /i \\server\install\setup.msi REBOOT=Suppress
goto:EOF
:EXIT
@Echo we are at exit
REM exit
```
What OS are you running this in?
Is this running as a login script?

You might try using *GOTO:EOF* (the colon is needed) rather than *GOTO EXIT*

HTH

Jerry


----------



## jat421 (Jun 14, 2008)

omg perfect that works great!!. It was the GOTO:EXIT and plus I had to give a name of a file in the temp folder to check for Ture or False. It working perfectly now. Thanks for all the help!!!.


----------



## TheOutcaste (Aug 8, 2007)

You're Welcome!

Strange though, *GOTO EXIT* (without the colon) worked fine for me. Only time I've needed the colon was with the special *EOF* label. *GOTO:EOF* always exits without having to actually put in a label called *EOF*. I also had no trouble using *If NOT EXIST "C:\Program Files\temp\NUL"*. *If NOT EXIST *"*C:\Program Files\temp"* also worked as well. Guess it depends on just what version of the command interpreter you are using.

I've always found it best to avoid using labels that are the same as a valid command. Makes it less likely that differences between OS version will change how it works. Adding an underscore to any label that matches a command will avoid confusion, so using *_EXIT* might be a better choice than just *EXIT*.

Jerry


----------

