Solved

Running a script one time

Posted on 2006-06-21
7
658 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 83

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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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 83

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Organizations create, modify, and maintain huge amounts of data to help their businesses earn money and generally function.  Typically every network user within an organization has a bit of disk space to store in process items and personal files.   …
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

932 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

11 Experts available now in Live!

Get 1:1 Help Now