Solved

Running a script one time

Posted on 2006-06-21
7
663 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 84

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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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 84

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

749 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