Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an Active Directory domain running on Windows Server 2003 R2. Clients are a mixture of Windows XP SP2, Vista, and Windows 7. I want to run a script (batch file, but possibly a VB script) on each machine, once. I don't want this to happen on Logon, Logoff, Startup, or Shutdown. I just want it to happen as soon as possible, and once.

Is there a relatively painless way to do this that will work across all the client types?

Thanks.

UPDATE: I should have mentioned this originally: Many of the PCs are behind cheap 5-port routers plugged into an ethernet jack. Think five grad students sharing an office. So each PC in an office has an RFC1918 IP. I'm on the public side of the router, so I can't connect directly to the PC. Hence PsExec or WMI won't work. WinRM might, but most of the PCs don't have that installed. I think my only option is to use a GPO somehow, maybe to schedule a task to run a script from a network drive.

share|improve this question
    
Are you wanting the script to run on the local client desktops (in the current session) or just perform some operation against the desktops? What sort of script are you running? –  Mr Furious Jun 4 '10 at 17:02
    
the issue here maybe what Mr Furious is alluding to and that is you can't run the script as the user! Only as the user psexec'ing the command. if you don't care then psexec is the way to do it! –  tony roth Jun 4 '10 at 17:23
add comment

5 Answers

I would say use psTools psexec.exe to remotely run the script.

It's a painless process to get up and running, doesn't need you to log into every station, and doesn't leave a footprint after-wards.


In response to all the comments, since they can talk to the DC's to be on the domain, you should be able to jump onto a DC and run the psexec script from there.

share|improve this answer
    
You will probably want to query the AD for all your workstations and use that as your source to loop through since you seemingly already have a properly functioning domain. If you have SQL server, you could easily write the results to a table or a log file and use SSIS to import the results then view via SQL reporting services or something cool like that. Of course, if you do all that work maybe SCCM is something you will want to look at. –  BoxerBucks Jun 4 '10 at 17:24
    
A salient detail I failed to mention was that many of the PCs are behind routers (with non-routable IPs. This wasn't my decision, but it's understandable -- we get billed internally per IP). So I think psExec and WMI won't work. WinRM might, but it's not an option for the XP boxes. –  David Jun 4 '10 at 18:49
    
@David: hmm by not routeable do you mean RFC1918 addressing, or like they don't let you get from point a to point b within you're own network? If it's just RFC1918 addressing if you are internal to the network you should be fine. Basically if you can ping the host you should be able to use psexec. –  Zypher Jun 4 '10 at 19:07
    
you can ping these things right? –  tony roth Jun 4 '10 at 19:45
    
I'm not internal to the network. I'm on a routable IP, but many offices have cheap routers plugged into a single ethernet jack, and then 3 or more PC's are plugged into the router. So I can't get past the router. The best I could do is port-forward to a single PC. –  David Jun 4 '10 at 19:47
show 7 more comments

This sounds like a job for psexec. PSexec will allow you to remotely execute a script on all computers in the domain if you provide '\' as the computer. You will need to add some kind of logic to your script to leave some kind of indication on the system that is has completed, and check for that before starting.

share|improve this answer
add comment

You could write a wrapper script and use psexec to connect to the remote machines and execute the script you want to run provided it is on a location that is accessible to those machines. You just have to have a source for the pc's you are connecting to to loop through them.

share|improve this answer
add comment

You can also write a script (PS, VBScript, etc) to execute it via WMI, but as others have pointed out psTools is probably the easiest way.

share|improve this answer
add comment

I want to run a script (batch file, but possibly a VB script) on each machine, once. I don't want this to happen on Logon, Logoff, Startup, or Shutdown. I just want it to happen as soon as possible, and once. Is there a relatively painless way to do this that will work across all the client types?

VBscript.

Many of the PCs are behind cheap 5-port routers plugged into an ethernet jack. Think five grad students sharing an office. So each PC in an office has an RFC1918 IP.

I'm surprised that this works at all. I presume that all of the routers have different subnets; otherwise, your domain will be in complete and utter chaos as you have any number of clients all trying to claim the same 192.168.x.x IP address...

I'm on the public side of the router, so I can't connect directly to the PC. Hence PsExec or WMI won't work.

This is your first problem. You need to get "inside" the network of each one. It sounds like the remote PCs are behind some kind of firewall NAT, and that will cause all kinds of headaches. Technically, "in a perfect world", your server should be on the same network as your clients. Are the clients connecting via VPN? If so, that will be your ticket "in".

I think my only option is to use a GPO somehow, maybe to schedule a task to run a script from a network drive.

This may be an issue if the GPO you create applies when the user logs in, given that you said you don't want it to happen when the user logs onto the machine.


I'm sorry to offend you with this, but given the nature of the question, I have to ask (if you are willing to answer): why do you need to do this? A managed network wouldn't be configured in this insane fashion, and frankly, from my POV it appears as if you wish to mount some kind of breach against these internal networks.

share|improve this answer
    
Answering in multiple comments. Although I didn't install the routers, they are all configured identically. So yes, multiple workstations in the domain may have the same RFC1918 address (192.168.1.234, say). The workstations are configured to use the University DNS servers, and do not register their IP back to the server. This doesn't appear to have created a problem. –  David Jun 6 '10 at 14:49
    
Clients are not connecting via VPN. As described in another comment, we have multiple offices (each with multiple workstations) in several buildings on a university network. The university charges a fee per IP per month, so NAT'ing routers were placed in the offices to save money. This was not my decision. –  David Jun 6 '10 at 14:50
    
Don't worry, I'm not offended. In general, I want to be able to run scripts to query the configuration of individual workstations in potentially arbitrary ways. In this specific case, I have a relatively small subset of workstations with a particular piece of commercial software that uses a registry setting to store the location of a shared network license. I want to run REG query on each workstation to see which workstations have that key. I will use an adm template via GPO to push a new value of that key to those clients, and then I want to query the registry again to see if it worked. –  David Jun 6 '10 at 14:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.