How do I run a PowerShell script when the computer starts?

前端 未结 15 1196
-上瘾入骨i
-上瘾入骨i 2020-11-30 19:24

I have a PowerShell script that monitors an image folder. I need to find a way to automatically run this script after the computer starts.

I already tried the follow

15条回答
  •  时光说笑
    2020-11-30 19:49

    You can see scripts and more scheduled for startup inside Task Manager in the Startup tab. Here is how to add a new item to the scheduled startup items.

    First, open up explorer to shell:startup location via start-button => run:

    explorer shell:startup

    Right click in that folder and in the context menu select a new shortcut. Enter the following:

    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -Command "C:\myfolder\somescript.ps1"

    This will startup a Powershell script without starting up your $profile scripts for faster execution. This will make sure that the powershell script is started up.

    The shell:startup folder is in:

    $env:APPDATA\Microsoft\Windows

    And then into the folder:

    Start Menu\Programs\Startup

    As usual, Microsoft makes things a bit cumbersome for us when a path contains spaces, so you have to put quotes around the full path or just hit tab inside Powershell to autocomplete in this case.

提交回复
热议问题