

AtStartup - indicates that a trigger starts a task when the system is started. AtLogOn - indicates that a trigger starts a task when a user logs on.


$onCreated = Register-ObjectEvent $fsw Created -SourceIdentifier FileCreated -Action \System32\WindowsPowerShell\v1.0\powershell.exe" -Argument "-WindowStyle Hidden -Command `"& 'C:\PATH\TO\FILE.ps1'`"") -RunLevel Highest -Force $fsw = new-object System.IO.FileSystemWatcher $folder, $filter -Property = 'FileName, LastWrite' Here's my PowerShell script: $folder = "C:\\Doc\\Files" %SystemRoot%\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -File "C:\Doc\Files\FileMonitor.ps1" Use msconfig and add the PowerShell script to startup, but I cannot find the PowerShell script on that list.Ĭreate a shortcut and drop it to startup folder. I already tried the following methods, but I couldn't get it working. I need to find a way to automatically run this script after the computer starts. I have a PowerShell script that monitors an image folder.
