Shutdown computer in LAN help

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
joakim
Posts: 24
Joined: 07 Mar 2012 12:08

Shutdown computer in LAN help

#1 Post by joakim » 22 Oct 2012 05:19

Hi, im trying to shudown computers in a LAN but its not working, in administrator.

first i open cmd and type : net view to get a list of the computers in the LAN

then i ping the computer i want to shutdown,

then i type: shutdown -i

i select the computer i want to shutdown by writing the name of it when press shutdown but its only shutdowns my computer :(

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Shutdown computer in LAN help

#2 Post by abc0502 » 22 Oct 2012 05:25

Shutdown command is like this:
shutdown -s -f -m \\computer_name -t 30 -c comment


The compute name is what you are missing, the GUI not working on my pc ?? but this should work if you have administrator access to the pc


Edit:
BTW, It never worked with me whether i have admin rights or not :?
Last edited by abc0502 on 22 Oct 2012 06:32, edited 2 times in total.

Boombox
Posts: 80
Joined: 18 Oct 2012 05:51

Re: Shutdown computer in LAN help

#3 Post by Boombox » 22 Oct 2012 06:20

.

Code: Select all

wmic /node:"COMPUTERNAME" /user:REMOTEUSERNAME /password:REMOTEPASSWORD process call create "cmd.exe" /c shutdown -s -t 0


Or automate it a little...

Code: Select all

@echo off
:main
set "netnode="
set "remuser="
set "rempass="
cls

for /f "tokens=1 delims=\" %%g in ('net view ^| findstr "\\"') do (
ping -4 -n 1 %%g | findstr "Pinging">>netview.txt)

echo.
echo   Network Computers
echo   -----------------
for /f "tokens=2,3" %%g in (netview.txt) do echo   %%g %%h& del netview.txt
echo   -----------------

echo.
echo   Which computer?
set /p netnode=
echo.
echo   Username at remote location?
set /p remuser=
echo.
echo   Password of remote user?
set /p rempass=

:error
cls
echo.
echo   Network Computer: %netnode%...
echo.
echo   1 to shutdown, or 2 to restart...?

set /p option=
if %option%==1 goto shutdown
if %option%==2 goto restart
goto error

:restart
wmic /node:"%netnode%" /user:%remuser% /password:%rempass% process call create "cmd.exe" /c shutdown -r -t 0

:shutdown
wmic /node:"%netnode%" /user:%remuser% /password:%rempass% process call create "cmd.exe" /c shutdown -s -t 0

goto main


Any Dos command can replace 'shutdown -r -t 0'.

Code: Select all

wmic /node:"%netnode%" /user:%remuser% /password:%rempass% process call create "cmd.exe" /c systeminfo>>(YOUR NETSHARE)



NOTE: WMIC WILL NOT WORK REMOTELY, IF THE REMOTEUSER HAS NO PASSWORD!

Post Reply