Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help pushing out a BAT file

Status
Not open for further replies.

ArizonaGeek

IS-IT--Management
Aug 21, 2006
768
US
Hi there, I need a little help. I wrote a batch file to point my antivirus software to a new server, it calls a small program in my antivirus software and points to a new address.

I have the batch file working but now I want it to run only once per PC. I was going to push it out with a GPO thru my 2003 AD but not sure how I can make it run only once per PC.

I have a few people on vacation and a couple that work from home a few days a week so I need to let it go for about 2 weeks. I just don't want it to install every time someone logs in.

Thanks for any help.

Cheers
Rob

The answer is always "PEBKAC!
 
Easiest way I know off hand is having the bat file dump a check file some place when it completes. Then start off by having the bat file look for the check file, if its there it will skip over your install/change.

Like this;
Code:
:CheckCounterSpy
REM __________________________________
REM Check to see if Counterspy is installed
REM @echo on
REM if exist \\YOURSERVER\yourSHARE\counterspyinstall\%computername%.txt goto SkipCounterSpy
REM Goto InstallCounterSpy

:InstallCounterSpy
REM __________________________________
REM Installing Counterspy Sub Directory
REM start /wait x:\installations\counterspy\cseagent-default.msi /passive /qb
REM echo %username% >  \\YOURSERVER\yourSHARE\counterspyinstall\%computername%.txt
REM goto CheckCounterSpy

:SkipCounterSpy

(yay! shameless advertising. my side business)
 
oops forgot to take out the REM's

Code:
:CheckCounterSpy
REM __________________________________
REM Check to see if Counterspy is installed
@echo on
if exist \\YOURSERVER\yourSHARE\counterspyinstall\%computername%.txt goto SkipCounterSpy
Goto InstallCounterSpy

:InstallCounterSpy
REM __________________________________
REM Installing Counterspy Sub Directory
start /wait x:\installations\counterspy\cseagent-default.msi /passive /qb
echo %username% >  \\YOURSERVER\yourSHARE\counterspyinstall\%computername%.txt
goto CheckCounterSpy

:SkipCounterSpy

(yay! shameless advertising. my side business)
 
While this would work I'd like to be able to not run the bat file at all if is installed. Running it every time someone logs in wont hurt the software but I have other logon scripts running up to two or three depending on the user. So I really want to try and run this only once and then not run at all again. This is literally like a 10 second update.

Thanks though, I'll play around with it to see if it'll work for me but if anyone else has a suggestion in only making it run once then not run at all after that I'd sure appreciate hearing about it.

Thanks again!

Cheers!
Rob

The answer is always "PEBKAC!
 
Have a look at the following registry keys:
Code:
# HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce

# HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce

The first one will run a command for ANYONE whos logs into a workstation (i.e. change the value to be something like: \\YourDC\netlogon\RunMe.bat) and will then delete the value (hence - RunOnce). The 2nd is user specific but will run no matter which workstation they logon to.

Cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top