githubEdit

⚑Automation

Here’s an updated Automation & Scheduled Tasks section with both CMD and PowerShell commands laid out in a copy-friendly format.

πŸ›  Windows Automation & Scheduled Tasks (CMD + PowerShell)

Below are useful automation tasks using both Command Prompt (CMD) and PowerShell, allowing you to schedule tasks, automate maintenance, and manage system operations efficiently.

1️⃣ Schedule a Task to Run Every Night

βœ… CMD:

schtasks /create /tn "NightlyTask" /tr "C:\Scripts\cleanup.bat" /sc daily /st 23:00

βœ… PowerShell:

$Trigger = New-ScheduledTaskTrigger -Daily -At 11PM
$Action = New-ScheduledTaskAction -Execute "C:\Scripts\cleanup.bat"
Register-ScheduledTask -TaskName "NightlyCleanup" -Trigger $Trigger -Action $Action

πŸ“Œ Purpose: Runs a cleanup script every night at 11 PM.

πŸ“Œ Use Case: Automating log cleanups, backups, or maintenance.

2️⃣ Automatically Shutdown the PC at a Specific Time

βœ… CMD:

shutdown /s /t 3600

βœ… PowerShell:

πŸ“Œ Purpose: Shuts down the PC after 1 hour (3600 seconds).

πŸ“Œ Use Case: Prevents computers from staying on overnight.

3️⃣ Restart the PC After a Set Time

βœ… CMD:

βœ… PowerShell:

πŸ“Œ Purpose: Restarts the PC after 30 minutes (1800 seconds).

πŸ“Œ Use Case: Used after installing software updates.

4️⃣ Schedule a System Reboot Every Sunday at 2 AM

βœ… CMD:

βœ… PowerShell:

πŸ“Œ Purpose: Forces a system reboot every Sunday at 2 AM.

πŸ“Œ Use Case: Ensures servers or workstations stay refreshed.

5️⃣ Empty the Recycle Bin Automatically

βœ… PowerShell:

πŸ“Œ Purpose: Deletes all items in the Recycle Bin.

πŸ“Œ Use Case: Helps free up disk space automatically.

6️⃣ Uninstall a Program Silently

βœ… CMD:

βœ… PowerShell:

πŸ“Œ Purpose: Removes a program silently without user prompts.

πŸ“Œ Use Case: Useful for mass uninstallations.

7️⃣ Create a Backup of a Folder Daily

βœ… CMD:

βœ… PowerShell:

πŸ“Œ Purpose: Backs up an entire folder to another drive.

πŸ“Œ Use Case: Automates file backups.

8️⃣ Disable Windows Defender Temporarily

βœ… PowerShell:

πŸ“Œ Purpose: Temporarily disables Windows Defender real-time protection.

πŸ“Œ Use Case: Useful when installing trusted third-party software.

9️⃣ Enable Windows Defender Again

βœ… PowerShell:

πŸ“Œ Purpose: Re-enables Windows Defender after temporary disabling.

πŸ”Ÿ One-Click Full System Cleanup

βœ… PowerShell:

πŸ“Œ Purpose: Runs a disk cleanup, empties the Recycle Bin, and deletes temp files.

πŸ“Œ Use Case: Automates cleanup tasks for better performance.

πŸ“Œ How to Use These Scripts

1. For CMD: Open Command Prompt (cmd.exe) as Administrator and paste the command.

2. For PowerShell: Open PowerShell as Administrator and paste the script.

3. For Automation: Add PowerShell scripts to Task Scheduler to run them automatically.

πŸ”₯ These automation scripts save time, optimize performance, and improve system efficiency! Let me know if you need more! πŸš€

Last updated