I'm trying to automate a script that runs to enable system restore upon startup (yes, every time my PC boots). I found this PowerShell script that seems to work when entered directly into a PowerShell terminal window.

Enable-ComputerRestore -Drive "C:"

But I want to turn it into a script file to run by placing in the Startup folder. I've tried entering this script into notepad, saving as "All Files" as a ".ps1" and then set that file extension to open with PowerShell as the default app. But it loads a red error that quickly vanishes as the terminal window closes.

I usually place .bat files in the startup to launch programs, and I understand this can be done to launch a .ps1 file, but right now the .ps1 doesn't even work when launched by PowerShell that I set as its default app.

Is there an easier way to automate Enabling system restore silently preferably through a .bat script?

2 Answers 2


The error you see in the pop-up will be around your PowerShell execution policy.

You have a few options;

  1. Wrap your Powershell code in a batch file to bypass it so

PowerShell -ExecutionPolicy Bypass -Command "Enable-ComputerRestore -Drive 'C:'"

  1. Unblock the script with something like
Unblock-File -Path pathhere\script.ps1
  1. Change your execution policy to RemoteSigned or Unrestricted like so

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

For more info on PowerShell execution policy you can refer to this page https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.3

  • Thanks! But I'm confused, if the powershell code is bypassed by inserting within a batch file, why would I need to add another script to unblock it? Mar 8 at 16:12

The following command enables System Restore on the C:\ drive.

wmic.exe /namespace:\\root\default Path SystemRestore Call enable "C:\"

Alternatively, use the PowerShell.exe command-line suggested to you by @Kuypotta.

Note: In either case, you must create a scheduled task for one of the commands and configure it to run at login. It won't work from the Startup folder.

  • Thanks. Is your version a purely .bat-compatible script, without any needs to change permissions or other prerequisites other than task scheduler? Mar 8 at 16:13
  • Of course. It can be run from a Batch file as an administrator. Without admin rights, it's impossible to enable or disable System Restore. Also, you may need to use the full path to wmic.exe (C:\Windows\System32\wbem\WMIC.exe) if WBEM is not in the Path.
    – w32sh
    Mar 8 at 16:18
  • I use Windows Pro 11 at Home, so I guess no WBEM. Does that mean the full script looks like this? C:\Windows\System32\wbem\WMIC.exe /namespace:\\root\default Path SystemRestore Call enable "C:\" Mar 9 at 17:33
  • Why not run the command instead of guessing something? It should work on Home as well as Pro. Yes, the command-line you posted is correct. WMIC component is installed by default. Unless you removed the WMIC FOD manually via Settings → Apps, WMIC.exe should be present in the computer.
    – w32sh
    Mar 10 at 6:50
  • I don't just run commands because I always get errors and then have to back track because I didn't know something that I should have. This is why I asked here, because I want to learn in advance, instead of unnecessary hindsight. Mar 11 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.