I have set up a task on task scheduler to run a .bat file that runs a PowerShell script as admin which sets the DNS settings. I figured out how to make the .bat file run minimised, but the PowerShell window still pops up. Here is the script for the .bat file called "SetDNS". The PowerShell script's name is "DNS.ps1".
@ECHO OFF
SET ThisScriptsDirectory=%~dp0
SET PowerShellScriptPath=%ThisScriptsDirectory%DNS.ps1
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%C:\Users\Test\Downloads\DNS.ps1%""' -Verb RunAs}";
I want to change it so that the PowerShell script does not flash open while it runs. Is there something that I could add to the above code to make it run minimized? I tried to add "start /min" to the above code but it did not work.