Page 1 of 1

Card to exectute multiple actions

Posted: Sun Jun 28, 2020 2:59 am
by slimjim69
I am new to this all and am having trouble creating a card that will a do number of things. I wish for the command to 1) switch to secondary monitor, 2) open Steam Big Picture mode, 3) switch audio output to TV. I have already written a working .BAT file that works when clicked on but doesn't work when executed through Push2Run. The .BAT file is written below.

start C:\Windows\System32\DisplaySwitch.exe /external
start "C:\Program Files (x86)\Steam\Steam.exe" steam://open/bigpicture -fulldesktopres"
nircmd setdefaultsounddevice "TV" 1
exit

This is the error I get when executing the command through Google Assistant/Push2Run
https://imagehost.com.au//icB4D

Any help on this would be extremely appreciated!!

Re: Card to exectute multiple actions

Posted: Sun Jun 28, 2020 8:09 am
by RobLatour
Well, I would say you've done very well.

I think you're just getting tripped up by one of those "gotta love Windows" things.

In your bat file, please try changing:

start C:\Windows\System32\DisplaySwitch.exe /external
to
start start "" "C:\Windows\system32\DisplaySwitch.exe" /external

for more information please see:
https://stackoverflow.com/questions/154 ... ed-program

Also, another potential trip up if have a 64-bit version of Windows (which most people do these days), is that if you want to execute the DisplaySwitch command directly from a Push2Run card, then you have to use the Sysynative folder in place of the System32 folder as shown below:
sysnative.png
sysnative.png (13.02 KiB) Viewed 7152 times

ref: https://www.samlogic.net/articles/sysna ... indows.htm

Again, gotta love Windows.

Hope this helps!

Re: Card to exectute multiple actions

Posted: Sun Jun 28, 2020 8:53 pm
by slimjim69
Hi Rob!

Thanks so much your your reply, I really appreciate your help. I tried your recommendations but unfortunately still no improvement... :cry:

The .BAT file currently reads:

start start "" "C:\Windows\system32\DisplaySwitch.exe" /external
start "C:\Program Files (x86)\Steam\Steam.exe" steam://open/bigpicture -fulldesktopres"
nircmd setdefaultsounddevice "TV" 1
exit


And the Pusgh2Run card is setup with the Start Directory as "C:\Windows\Sysnative"
https://imagehost.com.au//Hp045

Unforuntately still getting the same error: https://imagehost.com.au//icB4D

The .BAT file still works perfectly when clicked by a mouse but it seems like Push2Run is still struggling to access system32\DisplaySwitch.exe. There was another post in the forums with a working card to switch monitors through Push2Run so it is possible. I just wanted to be able to swich monitors, open Big Picture and switch audio output all in once voice command instead of multiple. I don't personally understand any of the below code but this is the working monitor switch .p2r file here. Any clues?

<?xml version="1.0" encoding="utf-8"?>
<Card xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" DateTimeValue="2019-04-09T00:10:00.4874157+01:00">
<Description>win 2nd monitor</Description>
<ListenFor>2nd monitor
tv</ListenFor>
<Open>DisplaySwitch.exe</Open>
<StartDirectory>C:\Windows\Sysnative</StartDirectory>
<Parameters>/external</Parameters>
<StartWithAdminPrivileges>false</StartWithAdminPrivileges>
<StartingWindowState>3</StartingWindowState>
<KeysToSend />
</Card>

Thanks again for your help!!

Re: Card to exectute multiple actions

Posted: Mon Jun 29, 2020 6:30 am
by RobLatour
Does your .bat file really read:

start start "" "C:\Windows\system32\DisplaySwitch.exe" /external

if yes, it should read:

start "" "C:\Windows\system32\DisplaySwitch.exe" /external

also

As you have fully qualified (including both path and filename) the .bat file in your Push2Run card's 'open' field, you should leave the 'Start directory' field on your Push2Run card blank.

Re: Card to exectute multiple actions

Posted: Mon Jun 29, 2020 7:48 pm
by slimjim69
https://imagehost.com.au//icB4D
Unfortunately still getting the same error :( P2R Start Directory is blank and BAT file reads:

start "" "C:\Windows\system32\DisplaySwitch.exe" /external
start "C:\Program Files (x86)\Steam\Steam.exe" steam://open/bigpicture -fulldesktopres"
nircmd setdefaultsounddevice "TV" 1
exit


Any other ideas would be greatly appreciated :D

Re: Card to exectute multiple actions

Posted: Mon Jun 29, 2020 9:41 pm
by RobLatour
ok - so I did some testing and I seem to have found a workaround.

For some reason, DisplaySwitch.exe cannot be run out of the C:\Windows\system32 folder,

Accordingly, I copied the file DisplaySwitch.exe into a directory I created called c:/temp

it would then work when run out of the temp directory.

Because of my screen configuration, in testing DisplaySwitch kinda messed up my screens, but I was able to manually put things back in place.

In my testing my bat file contained the following:

c:
cd \
cd temp
DisplaySwitch /external

but my guess is the start command will work as well (as you have above) - I just don't want to mess up my screens again to test it further.

Please let me know if this helps.

Re: Card to exectute multiple actions

Posted: Tue Jun 30, 2020 8:03 pm
by slimjim69
Rob you are my absolute hero! It works a charm!
My computer desk/couch gaming setup is now fully automated with my Google Home and it's all thanks to you!! :D

Re: Card to exectute multiple actions

Posted: Tue Jun 30, 2020 10:45 pm
by RobLatour
glad to have helped