Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # Filename: fast_shutdown_mod.py
- # Version: 1.00
- # Author: Jeoi Reqi
- r"""
- 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 user specified value between 500 & 5,000 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(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 the specified timeout value.
- If successful, it prints a success message; otherwise, it prints an error message.
- Args:
- timeout (int): The timeout value in milliseconds.
- 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 the specified timeout
- reg.SetValueEx(key, 'WaitToKillServiceTimeout', 0, reg.REG_SZ, str(timeout))
- # 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.
- Prompts the user for input to specify the timeout value,
- then calls the modify_shutdown_timeout function with the specified value.
- Returns:
- None
- """
- try:
- timeout = int(input("Enter the timeout value (between 500 and 5000 milliseconds): "))
- if 500 <= timeout <= 5000:
- modify_shutdown_timeout(timeout)
- else:
- print("Invalid timeout value. Please enter a number between 500 and 5000.")
- except ValueError:
- print("Invalid input. Please enter a valid number.")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement