Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- """
- fast_shutdown.py
- This script modifies the shutdown timeout value in the Windows registry.
- It sets the value of 'WaitToKillServiceTimeout' under the registry key
- 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control' to 500 milliseconds,
- allowing for a faster shutdown process.
- This modification can potentially reduce the time it takes for Windows to
- shut down after initiating the shutdown command.
- Note: Running this script requires administrative privileges.
- """
- import winreg as reg
- def modify_shutdown_timeout():
- """
- Modify the shutdown timeout value in the Windows registry.
- This function attempts to open the registry key for modification and sets
- the 'WaitToKillServiceTimeout' value to 500 milliseconds. If successful,
- it prints a success message; otherwise, it prints an error message.
- Returns:
- None
- """
- try:
- # Open the key for modification
- key = reg.OpenKey(reg.HKEY_LOCAL_MACHINE, r'SYSTEM\CurrentControlSet\Control', 0, reg.KEY_SET_VALUE)
- # Set the value of WaitToKillServiceTimeout to 500 (500 milliseconds)
- reg.SetValueEx(key, 'WaitToKillServiceTimeout', 0, reg.REG_SZ, '500')
- # Close the key
- reg.CloseKey(key)
- print("Shutdown timeout modified successfully.")
- except Exception as e:
- print(f"Error occurred while modifying shutdown timeout: {e}")
- def main():
- """
- Main function to execute the script.
- Returns:
- None
- """
- modify_shutdown_timeout()
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement