Computer Hope

Microsoft => Microsoft Windows => Windows Server => Topic started by: azmarkk on July 27, 2008, 09:38:28 PM

Title: dos shutdown command
Post by: azmarkk on July 27, 2008, 09:38:28 PM
I am trying to shutdown 157 windows xp workstations using the following bat file.
"shutdown -r -f -c " Automatic system restart has been called for by the system administrator. Shutdown will begin in 30 seconds".

Can I use wildcards and the -m \\abc** for system names.

Example "abc**"  for system named abc01, abc02 ect.
 I only want to shut down and restart certian pc's in the domain.

The domain server is running Server 2003.

Thanks
Title: Re: dos shutdown command
Post by: GuruGary on July 28, 2008, 03:45:23 PM
You can't use wildcards for the shutdown command, but you could probably do something like this in a batch file:

Code: [Select]
@echo off
for /f "tokens=*" %%a in ('net view ^| findstr /i /b "\\\\abc"') do (
   echo Rebooting %%a
   shutdown.exe -r -f -m "%%a" -c " Automatic system restart has been called for by the system administrator. Shutdown will begin in 30 seconds"
)

As with all batch scripts, this should be tested in a controlled environment before run on a live network.