Open lastwespoke opened 1 month ago
Ensure your PowerShell script (Events.ps1
) is correctly placed in the desired directory. For this guide, we'll assume it's located at:
D:\sources\MonitorSwapAutomation\Events.ps1
Using Run Dialog:
Win + R
.taskschd.msc
and press Enter
.Using Start Menu:
MonitorSwapAutomation
Go to the "Actions" tab.
Click "New…".
Action: Select "Start a program".
Program/script: Enter powershell.exe
.
Add arguments (REQUIRED): Input the following command, adjusting the path as necessary:
-WindowStyle Hidden -ExecutionPolicy Bypass -Command "Set-Location 'D:\sources\MonitorSwapAutomation'; .\Events.ps1 -n MonitorSwapper; OnStreamEnd"
Example for a different script location:
-WindowStyle Hidden -ExecutionPolicy Bypass -Command "Set-Location 'C:\Scripts\MyAutomation'; .\Events.ps1 -n MonitorSwapper; OnStreamEnd"
Click "OK" to save the action.
You can manage and trigger your PowerShell scripts remotely using SSH from your smartphone. If you'd like a button on your phone to trigger the script, follow these steps.
Follow the guide to install OpenSSH on Windows:
Using SSH keys enhances security by allowing password-less authentication. Follow these steps to configure SSH keys:
authorized_keys
file.PasswordAuthentication no
in sshd_config
.Hey, thanks for you effort in helping me sorting that issue out. I modified your command to my path, so it look like this:
powershell.exe -ExecutionPolicy Bypass -Command "Set-Location 'C:\Scripts\MonitorSwapper'; .\Events.ps1 -n MonitorSwapper; OnStreamEnd"
(I have removed WindowStyle attribute for debug purposes)
However, when I try to run this command manually it fails with error:
The term 'OnStreamEnd' is not recognized as the name of a cmdlet, function, script file, or operable program
Could you check that? Thanks.
Hey, thanks for you effort in helping me sorting that issue out. I modified your command to my path, so it look like this:
powershell.exe -ExecutionPolicy Bypass -Command "Set-Location 'C:\Scripts\MonitorSwapper'; .\Events.ps1 -n MonitorSwapper; OnStreamEnd"
(I have removed WindowStyle attribute for debug purposes)However, when I try to run this command manually it fails with error:
The term 'OnStreamEnd' is not recognized as the name of a cmdlet, function, script file, or operable program
Could you check that? Thanks.
Try
Add a dot and a space before .\Events.ps1
like . .\Events.ps1
Syntax error is fixed now, thanks for the tip. Sadly, desired effect is still not there. Command executes but still hasn't same effect as disconnecting from stream from my mobile device. If i run command while on main monitor it outputs next string:
Primary monitor(s) have been successfully restored! True
No other effect, as expected.
However, if i switch to mobile device and run command it just outputs:
False
And doesn't switch to main monitor as expected.
Primary monitor defaults to virtual sink instead of my physical one sporadically, even if i quit session correctly and turn pc off by hand. I thought it would work if i call primary.cfg at system start, but can't achieve desired effect. Tried delayed start (1-10s) at logon of any user, command executes but has no effect. Command is:
C:\Scripts\MonitorSwapper\MultiMonitorTool.exe /LoadConfig "C:\Scripts\MonitorSwapper\primary.cfg"
Works well when called manually. Any ideas?