-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c6f73d8
commit 4690052
Showing
13 changed files
with
250 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import pyautogui | ||
import time | ||
|
||
# Wait a bit to ensure the script is ready to run | ||
time.sleep(2) | ||
|
||
# Simulate pressing Win+R to open the Run dialog | ||
pyautogui.hotkey('win', 'r') | ||
|
||
# Wait a bit for the Run dialog to appear | ||
time.sleep(1) | ||
|
||
# Type the command to enable the command prompt | ||
pyautogui.write('cmd.exe /k "REG add HKCU\Software\Policies\Microsoft\Windows\System /v DisableCMD /t REG_DWORD /d 0 /f"') | ||
|
||
# Press Enter to execute the command | ||
pyautogui.press('enter') | ||
|
||
# Wait a bit for the command to execute and the command prompt to open | ||
time.sleep(5) | ||
|
||
# Simulate pressing Alt+F4 to close the command prompt window | ||
pyautogui.hotkey('alt', 'f4') | ||
|
||
# Wait a bit to ensure the command prompt window is closed | ||
time.sleep(2) | ||
|
||
print("Command executed to enable the command prompt and the window has been closed.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@echo off | ||
setlocal | ||
|
||
:: Debugging: Echo the path to MpCmdRun.exe to verify it's being resolved correctly | ||
echo Checking MpCmdRun.exe path: C:\Program Files\Windows Defender\MpCmdRun.exe | ||
|
||
:: Check if Windows Defender signatures are removed | ||
for /f "tokens=*" %%a in ('"C:\Program Files\Windows Defender\MpCmdRun.exe" -ShowSignatureUpdates') do ( | ||
if "%%a"=="No signature updates are available." ( | ||
echo Signature updates are already removed. Reinstalling now... | ||
"C:\Program Files\Windows Defender\MpCmdRun.exe" -UpdateSignature | ||
) else ( | ||
echo Signature updates are available. Removing now... | ||
"C:\Program Files\Windows Defender\MpCmdRun.exe" -RemoveDefinitions -All | ||
) | ||
) | ||
|
||
endlocal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Python Script Explanation | ||
|
||
This Python script uses the `pyautogui` library to automate the process of enabling the Command Prompt on a Windows system through the Registry Editor. It follows these steps: | ||
|
||
1. **Wait**: The script starts by waiting for 2 seconds to ensure it's ready to run. This delay can be adjusted based on the system's responsiveness. | ||
|
||
2. **Open Run Dialog**: It simulates pressing the `Win+R` keys to open the Run dialog box, which is used to execute commands directly from the Windows desktop. | ||
|
||
3. **Wait for Run Dialog**: After opening the Run dialog, the script waits for 1 second to ensure the dialog is ready to accept input. | ||
|
||
4. **Type Command**: It then uses `pyautogui.write` to type a command into the Run dialog. This command uses `REG add` to modify the Windows Registry and set the `DisableCMD` value under `HKCU\Software\Policies\Microsoft\Windows\System` to `0`, effectively enabling the Command Prompt. The `/k` switch is used to keep the Command Prompt window open after executing the command. | ||
|
||
5. **Execute Command**: After typing the command, the script simulates pressing the `Enter` key to execute the command. | ||
|
||
6. **Wait for Command Execution**: It waits for 5 seconds to allow the command to execute and the Command Prompt window to open. This delay can vary based on system performance and the time it takes for the Registry change to take effect. | ||
|
||
7. **Close Command Prompt**: Once the Command Prompt window is open, the script simulates pressing `Alt+F4` to close the window. | ||
|
||
8. **Wait for Window Closure**: Finally, it waits for 2 seconds to ensure the Command Prompt window is closed before proceeding. | ||
|
||
9. **Print Completion Message**: The script prints a message indicating that the command has been executed to enable the Command Prompt, and the window has been closed. | ||
|
||
## Usage | ||
|
||
This script is useful for automating the process of enabling the Command Prompt on a Windows system, which can be particularly helpful in environments where the Command Prompt is disabled by default. It provides a quick and efficient way to re-enable the Command Prompt without manually navigating through the Registry Editor or Group Policy settings. | ||
|
||
However, it's important to note that modifying the Windows Registry can have significant effects on the system's behavior and security. Therefore, this script should be used with caution and understanding of the implications. Additionally, the use of `pyautogui` for automating keyboard and mouse inputs can be affected by screen resolution, DPI settings, and other factors, so it may require adjustments for different systems or environments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Batch Script Explanation | ||
|
||
This batch script is designed to manage the Windows Defender signatures on a Windows system. It checks if Windows Defender signatures are already removed and then either reinstalls them or removes all signature updates, depending on the current state. Here's a detailed breakdown of its functionality: | ||
|
||
## Script Breakdown | ||
|
||
### `@echo off` | ||
|
||
This command turns off the display of commands in the command prompt window, making the output cleaner and easier to read. | ||
|
||
### `setlocal` | ||
|
||
This command starts a new local environment for the batch file. Variables and environment changes made within this script will not affect the global environment. | ||
|
||
### `for /f "tokens=*"` | ||
|
||
This loop iterates over the output of the command enclosed in parentheses. The `tokens=*` option ensures that the entire line is treated as a single token, allowing the script to work with the full output of the command. | ||
|
||
### `"%Program Files%\Windows Defender\MpCmdRun.exe" -ShowSignatureUpdates` | ||
|
||
This command runs the Windows Defender `MpCmdRun.exe` utility with the `-ShowSignatureUpdates` option, which checks for available signature updates. The output of this command is processed by the `for` loop. | ||
|
||
### `if "%%a"=="No signature updates are available."` | ||
|
||
This conditional statement checks if the output from the `MpCmdRun.exe` command indicates that no signature updates are available. If this condition is true, it means that Windows Defender signatures are already removed. | ||
|
||
### `echo Signature updates are already removed. Reinstalling now...` | ||
|
||
If the signatures are already removed, the script echoes a message indicating that it will now reinstall the signatures. | ||
|
||
### `"%Program Files%\Windows Defender\MpCmdRun.exe" -UpdateSignature` | ||
|
||
This command runs the `MpCmdRun.exe` utility with the `-UpdateSignature` option, which reinstalls the Windows Defender signatures. | ||
|
||
### `else` | ||
|
||
If the signatures are not already removed, the script proceeds to the `else` block. | ||
|
||
### `echo Signature updates are available. Removing now...` | ||
|
||
This message indicates that the script will now remove all signature updates. | ||
|
||
### `"%Program Files%\Windows Defender\MpCmdRun.exe" -RemoveDefinitions -All` | ||
|
||
This command runs the `MpCmdRun.exe` utility with the `-RemoveDefinitions -All` options, which removes all signature updates from Windows Defender. | ||
|
||
### `endlocal` | ||
|
||
This command ends the local environment started by `setlocal`, returning control to the global environment. | ||
|
||
## Usage | ||
|
||
This script is useful for managing Windows Defender signatures, especially in scenarios where you need to ensure that all signature updates are removed or reinstated. It provides a straightforward way to check the current state of Windows Defender signatures and perform the necessary action based on that state. | ||
|
||
However, it's important to use such scripts with caution, as removing or reinstalling Windows Defender signatures can affect the system's security and functionality. Always ensure that you understand the implications of these actions and consider the security requirements of your system. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import pyautogui | ||
|
||
|
||
def open_run_dialog(): | ||
# Press Windows + R | ||
pyautogui.hotkey('win', 'r') | ||
|
||
|
||
def type_and_execute_command(): | ||
# Type the command | ||
command = "shell:::{ED7BA470-8E54-465E-825C-99712043E01C}" | ||
pyautogui.write(command) | ||
# Press Enter to execute the command | ||
pyautogui.press('enter') | ||
|
||
|
||
def main(): | ||
open_run_dialog() | ||
type_and_execute_command() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,4 @@ socket | |
re | ||
uuid | ||
psutil | ||
wmi | ||
wmi |