- Thread Author
-
- #1
I want to do the following - first deploy new version of software to multiple PCs, and then restart all PCs for changes to take effect.
First part is not a problem, for second part is it possible to check if there is restart.bat in Dropbox folder every x minutes, and if there is, execute it. Hoping everything works fine, I would just remove restart.bat from Dropbox after 10 minutes.
How can I achieve this bat check?
First part is not a problem, for second part is it possible to check if there is restart.bat in Dropbox folder every x minutes, and if there is, execute it. Hoping everything works fine, I would just remove restart.bat from Dropbox after 10 minutes.
How can I achieve this bat check?
Solution
Powershell
Code:
$rebootScript = "PATHTODROPBOXDIRECTORY\reboot.bat"
WHILE($true)
{
IF(Test-Path -Path $rebootScript)
{
Start-Process -Path $rebootScript
break
} ELSE
{
Start-Sleep -Seconds 300
}
}
- Joined
- Jul 4, 2015
- Messages
- 8,998
CMD/batch are going to be deprecated in the future you're better off using powershell.
If you're using a script to install the software you could do
If you're using a script to install the software you could do
Code:
install sofware....
:LOOP
IF EXIST PATHTODROPBOXDIRECTORY\reboot.bat (
shutdown /r /t 10 /c "Computer restarting to complete software install"
GOTO EXITLOOP
) ELSE (
TIMEOUT /T 300
GOTO :LOOP
)
:EXITLOOP
exit 0
- Joined
- Jul 4, 2015
- Messages
- 8,998
Powershell
Code:
$rebootScript = "PATHTODROPBOXDIRECTORY\reboot.bat"
WHILE($true)
{
IF(Test-Path -Path $rebootScript)
{
Start-Process -Path $rebootScript
break
} ELSE
{
Start-Sleep -Seconds 300
}
}
- Thread Author
-
- #4
CMD/batch are going to be deprecated in the future you're better off using powershell.
If you're using a script to install the software you could do
Code:install sofware.... :LOOP IF EXIST PATHTODROPBOXDIRECTORY\reboot.bat ( shutdown /r /t 10 /c "Computer restarting to complete software install" GOTO EXITLOOP ) ELSE ( TIMEOUT /T 300 GOTO :LOOP ) :EXITLOOP exit 0
This restarts PC if reboot.bat is already in dropbox folder. If I add reboot.bat during countdown nothing happens, window just closes after 300 seconds, it doesn't loop?
- Joined
- Jul 4, 2015
- Messages
- 8,998
This script would look for that file and if found kick off a restart. If you would rather have it launch the reboot.bat then replace the shutdown line with START PATHTO\reboot.bat
You'd probably be better of just forcing a reboot after the install, if you have systems in use include the /c flag to notify users of system reboot
You'd probably be better of just forcing a reboot after the install, if you have systems in use include the /c flag to notify users of system reboot