0

In windows 10, instead of doing a full reboot, it's convenient to do a partial reboot by login out and login in again, for instance to reload a certain set of drivers and OS user related data. I can do a full reboot with restart-computer, but that's not what I want. I am looking for a fast cycle and the effects of a logoff-login cycle (on drivers and userworld in particular).

  • Is there a way to achieve this quick reboot by the mean of one powershell script ? In particular, I do not want to have to specify again which user (local user) and the password.
  • More technically, I know that a few drivers are unloaded and then reloaded in the "logoff-login" cycle; would that be called a fast kernel reboot ?

A certain edition of Windows server (Azure Stack HCI) allows kernel soft reboot (https://learn.microsoft.com/en-us/azure-stack/hci/manage/kernel-soft-reboot), this is not what I am looking for.

8
  • 1
    @John Are you sure, as my understanding of Fast Startup is it saves the current state of the system to hiberfil.sys, then uncompresses and boots to the system state that was saved to hiberfil.sys. Since Fast Startup creates issues when installing programs requiring system state refreshes, such as services needing to be stopped and restarted, is that what the OP is looking for?
    – JW0914
    Commented Dec 4, 2023 at 14:41
  • @JW0914 In your nomenclature, 'fast startup' does not do any reboot (unload then reload of any user data and drivers), it just save the current state and then put it back. So no, this is orthogonal.
    – Soleil
    Commented Dec 4, 2023 at 15:18
  • 1
    The default nature of a system reboot or even a shutdown on Windows 10 and Windows 11 is to utilize the hybrid shtudown to allow for a fast startup. You have to explicitly disable that behavior to get a full shutdown. What you want to happen is not clear for that reason. "would that be called a fast kernel reboot?" - No; When you log out of a user and log back into a user the NT kernel isn't restarted. " I do not want to have to specify again which user (local user) and the password." - There is no way to perform any kind of reboot and expect NOT to reauthenticate the user again.
    – Ramhound
    Commented Dec 4, 2023 at 15:53
  • @Ramhound The hybernation cycle do not have the effects the logoff-login cycle have. I updated the OP.
    – Soleil
    Commented Dec 4, 2023 at 16:10
  • 1
    I've read about this for Windows Updates effectiveness for doing something that sounds similar but I have never used it or seen it in use myself: learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/…. I'm sure there's a way to trace out what Windows is doing or setting, etc. with this and see if you can trick it to think it needs to do this for a Windows Update to be effective. Commented Dec 5, 2023 at 0:00

1 Answer 1

1

My understanding is that you wish to automatically logoff and then login back as the same user. This is impossible in one PowerShell script, as it would be terminated by the logoff, but there is a trick.

The trick is to set your account to be auto-login and then logout. You would then be automatically logged back in.

To turn on automatic logon in Windows, see the post How do I change automatic logon via Script or Command Line? You may set the listed registry entries in your PowerShell script, before executing the logoff.

For logoff, see the article Changing computer state. The simplest is to execute the command shutdown.exe -l.

If you have for login a "welcome message", you will still have to click on OK to fully log in.

2
  • Interesting, but it poses a security threat. And what about setting the autologin by ps, logoff and login back, and unset autologin ? In that case I won't have the permanent autologin
    – Soleil
    Commented Dec 4, 2023 at 15:13
  • You may add a logon script that will delete the autologin registry entries, so they don't stay forever.
    – harrymc
    Commented Dec 4, 2023 at 15:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .