Solved

Running a script one time

Posted on 2006-06-21
7
657 Views
Last Modified: 2008-01-09
I have a script that I need to run on all the machines on my network but I need to run it one time and one time only. What's the easiest way to do that?
0
Comment
Question by:Newsboy
7 Comments
 
LVL 12

Expert Comment

by:craskin
ID: 16953314
what does the script do? with some rewriting, it may not be necessary to worry about it running more than once.
0
 
LVL 82

Expert Comment

by:oBdA
ID: 16953603
Depends on what you're planning to do and what your network looks like.
If it's an AD domain, you have several possibilities:
* the logon script, running with user permissions
* a GPO with a user logon script, running with user permissions as well
* a GPO with a computer startup script, running with system permissions
Then there's Sysinternal's PsExec (http://www.sysinternals.com/Utilities/PsExec.html) that can be run against a list of machines.
Either way, you can just create a "flag file" in the script when the script has done its job, and if this flag file exists when the script starts, just exit.
0
 
LVL 4

Expert Comment

by:Jandakel2
ID: 16953940
Most scripts can be edited to only run if they have not been ran before, i.e. if you are mapping a drive, check for the previously mapped drive and if it exists, halt the script process.  If you were to configure you script in this fashion, the easiest way to deploy it would be to set it up as part of your default domain policy, as either a computer startup script, or a user logon script.  I have an auditing program that I run, that I really only need ran once, but I leave it on for days at a time to make sure I get all the PC's and never see a detrimental impact....obviously all situations are different though...hope this helps,

JK
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 17

Expert Comment

by:Eagle6990
ID: 16955272
I second PSExec.  It work great and you can run it against either a list of machine, or the entire domain in one pass.
0
 
LVL 3

Author Comment

by:Newsboy
ID: 16959838
Here's the script

rem ******************************* FIXWSUS.CMD *************************************
net stop wuauserv

regsvr32 /s wuapi.dll

regsvr32 /s wups.dll

regsvr32 /s wuaueng.dll

regsvr32 /s wucltui.dll

regsvr32 /s msxml3.dll

c:
cd %windir%\SoftwareDistribution
rd /s/q DataStore
mkdir DataStore
rd /s/q Download
mkdir Download

net start wuauserv

rem Fixes problem with client machines not showing up on the server due to imaging method

reg delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /v AccountDomainSid /f
reg delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /v PingID /f
reg delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /v SusClientId /f
cls
@echo Triggering detection after resetting WSUS client identity
net stop "Automatic Updates"
net start "Automatic Updates"
wuauclt /resetauthorization /detectnow
echo susid set to unique>c:\wsusfix.txt

exit

I like the flag idea, I am a domain with AD and use GP extensively. However I have little to no experience with actually writing script. So how would I edit this one to flag if it's been run or not?

Thanks so much I think this is what I'm looking for.
0
 
LVL 82

Accepted Solution

by:
oBdA earned 500 total points
ID: 16959978
Looking at your script, you already have something that you can use for that:
echo susid set to unique>c:\wsusfix.txt

So all you need is a simple
if exist "c:\wsusfix.txt" goto :eof
at the beginning of the script.
0
 
LVL 3

Author Comment

by:Newsboy
ID: 16961033
Worked like a charm, thanks so much, I had not clue it was that easy. This will save me days of work.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

by Batuhan Cetin Within the dynamic life of an IT administrator, we hold many information in our minds like user names, passwords, IDs, phone numbers, incomes, service tags, bills and the order from our wives to buy milk when coming back to home.…
I guess it is not common knowledge to most Wintel engineers/administrators: If you have an SNMP-based monitoring system in your environment (and it's common to have SNMP or Syslog) it's reasonably easy to enable monitoring of the Windows Event logs,…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

709 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now