Singha22
Singha22

Reputation: 1

Is there a way to move arrow key to left on Windows Popup?

I am writing a script which will allow PowerShell to run in admin mode but when I run Set-ExecutionPolicy Bypass, Windows displays a popup and I use my left arrow key to move to the yes button and press enter.

The problem I am facing is that it does not move to the left or press enter when I run the script as follows.

RunWait PowerShell.exe -ExecutionPolicy Bypass -NoExit -Command "C:\Users\%A_UserName%\Desktop\Script.ps1";
Send {Left}
Sleep, 5000
Send {Enter}

I am expecting it to actually move to the OK button on the left and press enter but nothing actually happens.

Upvotes: 0

Views: 111

Answers (1)

Relax
Relax

Reputation: 10568

  • If you run PowerShell in admin mode your script needs also to be run in this mode.
  • Unlike Run, RunWait will wait until the program (in this case PowerShell.exe) finishes before continuing (= sending commands to the popup window). To bypass this problem use SetTimer.

Upvotes: 1

Related Questions