open multipule pings and send reboot cmds

403 Views Asked by At

I am trying to open a few constant ping windows a certain size at certain positions and send reboot commands to each. Then rdp to another server and automatically reboot it(this server is not in the same domain and I can't ping it). All from a batch file.

This is what I have so far:

start cmd /k ping x.x.x.x -t

start cmd /k ping y.y.y.y -t

start cmd /k ping z.z.z.z -t

shutdown -r -f -m \x.x.x.x

shutdown -r -f -m \y.y.y.y

shutdown -r -f -m \z.z.z.z

mstsc c:\srv1.rdp

end

Right now these ping windows open on top of each other. And attempts to make srv1 reboot on its own have been unsuccessful. I have tried creating a batch file on srv1 then in the rdp file telling it to open this program, but couldn't get it to work.

Any ideas?

1

There are 1 best solutions below

0
On

I can help you with the windows positioning. The other part doesn't sound batch related to me.

@echo off
setlocal

set "Server1=x.x.x.x"
set "Server2=y.y.y.y"   

echo shutdown -r -f -m \\%server1%
call :PosWindows 0 100 %server1% "Pinging %server1%"
echo shutdown -r -f -m \\%server2%
call :PosWindows 0 500 %server2% "Pinging %server2%"
exit /b


:PosWindows xpos ypos serverip title
set /a "pos=(%2 << 16) + %1"
>nul reg add "hkcu\console\%~4" /v WindowPosition /t REG_DWORD /d "%pos%" /f
>%3.cmd echo.@echo off
>>%3.cmd echo.ping %3 -t
start "%~4" cmd /k "%3.cmd"
del /q "%3.cmd"
exit /b

Just add as many servers as you want and set the Ypos to a number greater than before.