Link to home
Start Free TrialLog in
Avatar of Ikelca
IkelcaFlag for Canada

asked on

make windows automatically restart

hi all

what i am looking for is that having computer restart one more time automatically after I manually restart it at beginning. That way i dont have to wait there to do second restart manually.

I am ok with c# or batch file or adding registry

thanks
Avatar of Govvy
Govvy
Flag of United States of America image

Create batch file containing 'shutdown /r'
Avatar of Ikelca

ASKER

that is not what I am looking for
 because I have to logon to start batch file
I want no touch after first reboot
Use HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce to point to script
1-Create a LocalPolicy or a Computer Group Policy Object to run an AutoRestart batch file at computer startup.

GPO AutoRestart.bat:
If exist "C:\Temp\AutoRestart.txt" (
  del /f /q "C:\Temp\AutoRestart.txt"
  shutdown -f -r -t 1
)


Batch File to restart PC then, auto restart it (Because of the GPO):
ECHO. >"C:\Temp\AutoRestart.txt"
shutdown -f -r -t 1
@Govvy:
User will require to logon so that the run once takes effect. This defise the purpose of not waiting for the PC to boot before rebooting.
Avatar of Ikelca

ASKER

RUNONCE key require logon to run whatever inside
i have tried that already.

regarding GPO, it may work, but how can I use c# to create a new GPO? that's the question, isn't GPO linking to registry?? if that's the case, which key in registry?
Avatar of Ikelca

ASKER

ok this works ReneGe,

but it leaves GPO enabled, is there way to disable that after run?
ASKER CERTIFIED SOLUTION
Avatar of ReneGe
ReneGe
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ikelca

ASKER

let me try and get back to u
Avatar of Ikelca

ASKER

thanks guys, i decided to use scheduled task to run shutdown.exe
Glad I could help.