run a script right now on every Windows computer in domain

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
I want to run a command on every Windows computer (2000 and XP) on our Windows 2000 domain. I would like to be able to force it to run right now, rather than have to wait for users to log off or reboot. Any ideas?

Or maybe I set through like a group policy to run a scheduled task?
 

SoulAssassin

Diamond Member
Feb 1, 2001
6,135
2
0
#1 What are you trying to run?
#2 Test it on a small population first.
#3 I assume you don't have rcmd on all these machines?
 

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
Originally posted by: SoulAssassin
#1 What are you trying to run?
#2 Test it on a small population first.
#3 I assume you don't have rcmd on all these machines?

1: sc config wuauserv start= auto
2: done
3: mmm, don't think so. I'll check that out.
 

nweaver

Diamond Member
Jan 21, 2001
6,813
1
0
if you can dump a list of computer names or ip's, then use psexec

psexec \\computername sc config wuauserver start=auto

 

SoulAssassin

Diamond Member
Feb 1, 2001
6,135
2
0
Find or write a script to dump all of the machines in your domain to a comma delimited text file. You should be able to find some Perl examples on Google. From there you need two very simple batch scripts. You will need admin rights on all of the machines. Obviously fill in all of the computer names into script1.

Contents of script 1:

script2.cmd machine1,machine2,machine9999,end

Contents of script 2:

:loop
echo Attempting %1 >> log.txt
sc config wuauserv start= auto \\%1 >> log.txt
shift
if %1 == end goto :eof
goto :loop
:eof
 

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
It looks like the problem with rcmd is you have to connect to one workstation at a time. There are about 300 workstations that this needs run on and I would really like to do them all in one swoop. If I wanted to run one at a time, I could use a program called Remote Execute program.

I set this to run as a startup script, but a lot of users don't even log off their computers, let alone restart them. This command is to configure the Automatic Updates service to be set to Automatic. We have been finding some computers with this set to Disabled, which is a big problem (as most people here would understand).

Remote Execute does have a command line interface. It may be possible to retrieve a list of all the computers from Active Directory and script a loop to read each machine name and use Remote Execute to run the command on each machine, but that is a bit beyond what I know how to write myself.

edit: oops, I see there have been a few responses while I was writing this :)
 

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
Originally posted by: SoulAssassin
Find or write a script to dump all of the machines in your domain to a comma delimited text file. You should be able to find some Perl examples on Google. From there you need two very simple batch scripts. You will need admin rights on all of the machines. Obviously fill in all of the computer names into script1.

Contents of script 1:

script2.cmd machine1,machine2,machine9999,end

Contents of script 2:

:loop
echo Attempting %1 >> log.txt
sc config wuauserv start= auto \\%1 >> log.txt
shift
if %1 == end goto :eof
goto :loop
:eof

So does adding the \\%1 (aka \\computername) to the end of "sc config wuauserv start= auto" cause it to run on a remote machine? Is that a feature of the sc command? Just trying to understand how this works...

edit: ah, yes, I google-answered my question. I also did not know about that "shift" command but I can deduce what it does. Nice.
 

SoulAssassin

Diamond Member
Feb 1, 2001
6,135
2
0
Originally posted by: Brazen

So does adding the \\%1 (aka \\computername) to the end of "sc config wuauserv start= auto" cause it to run on a remote machine? Is that a feature of the sc command? Just trying to understand how this works...

edit: ah, yes, I google-answered my question. I also did not know about that "shift" command but I can deduce what it does. Nice.

:D It's not as well known as it should be. Makes executing things like this on multiple computers much simpler.

 

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
hmmm, I am having trouble finding a script to retrieve the computer names. I tried exporting the list from the ADU&C snapin, but it put it in a funky format, and I really don't want to manually go in and clean it up. I'll keep looking, or maybe someone can link to one, or maybe I'll write a Bash script to clean up what I manually exported.
 

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0

SoulAssassin

Diamond Member
Feb 1, 2001
6,135
2
0
Originally posted by: Brazen
Originally posted by: SoulAssassin
http://www.intelliadmin.com/blog/2006/0...ting-and-stopping-services-across.html

You could modify this to run the sc.exe instead of their custom executable (which appears to only start/stop) or simply flip the start value under HKLM\System\CCS\Services\wuauserv\start to 2.

that looks pretty good. Maybe I can just change the one line at the very end, like you say, to run the sc command.

Yup, or just flip that reg key right before that line and use their util to start the service (or just script that in VB, real easy).