Question Locked

How can I run a batchfile to install software only once?

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I've dropped a batch file into our login script to install some software across my network but would like it to run only once instead of attempting to install multiple times.
Is there a "runonce" command I can put in anywhere?
TIA,
Alan

3 replies

by timwalsh

Essentially, you want to check and see if the software is already installed. The easiest way to do this would be to check and see if the primary executable exists where it is supposted to be.

At the start of your script you can use an "If Exist filename" or "If NOT Exist fileneame" statement where filename would be the path to your primary executable.

With the "If Exist" statement, you tell itto run a command such as "quit" or "exit" if the fielename exists, followed by ELSE and another command (such as your batch file) to run if it doesn't exist.

A more elegent way to do it would be to use the "If NOT Exist" statement. This way there is only one command to specify and run (your batchfile), and this only happens if the filein question isn't found. Otherwise nothing happens.

Make sure you check help files to get the correct statment syntax.

by rob miners

@echo off
if exist c:\ambo2.txt goto end

if not exist c:\ambo2.txt goto nothere

:nothere

echo. It's not here

:END
pause

This discussion is closed to new replies.