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

By alankuehnau ·
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?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

If...Then statement

by timwalsh In reply to How can I run a batchfile ...

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.

Collapse -

A basic example

by Jacky Howe In reply to How can I run a batchfile ...

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

if not exist c:\ambo2.txt goto nothere


echo. It's not here


Related Discussions

Related Forums