Windows 1909 - Macro - System.Execute no longer working

The Virtual Audio Mixer discussions and support...
Post Reply
cattywampus
Posts: 15
Joined: Fri Nov 23, 2018 3:25 am

Windows 1909 - Macro - System.Execute no longer working

Post by cattywampus »

Hi

Reformatted and updated my computer from Windows 1903 to 1909 - but now one of my macros that I use to switch default audio device in the background isn't working.

Have tried all sorts and can't fix it.

I use a VBS file triggered from wscript.exe to execute a bat file in the background so that the game I am in doesn't lose focus and tab me out. It seems I am unable to use System.Execute to do anything such as execute files?

This is the code:

Code: Select all

System.Execute("%windir%\System32\wscript.exe","S:\Dropbox\Streaming\OBS Assets\Overlay Assets","/C StuPC_Set_Default_Audio_Device_-_Game_(Realtek_Optical_Out).vbs 36 1");

Code: Select all

System.Execute("%windir%\System32\wscript.exe","S:\Dropbox\Streaming\OBS Assets\Overlay Assets","/C StuPC_Set_Default_Audio_Device_-_Voicemeeter_Aux_Input.vbs 36 1");
One is for the ON and the other OFF - and when the macro button is pressed, the VBS launches a bat file that points to a nircmd script to change the default audio device.

As I say, it worked flawlessly before re-installing. Any help appreicated.
xcasxcursex
Posts: 173
Joined: Tue Feb 18, 2020 12:04 am

Re: Windows 1909 - Macro - System.Execute no longer working

Post by xcasxcursex »

Works here:

Code: Select all

System.Execute("%windir%\System32\wscript.exe","C:\Users\xcasxcursex\Downloads","/C foo.vbs");
I suspect that either you've made a typo, put the command in the wrong field, or most likely - something's missing. I goofed and put this into the 'initial state' box at first ;) Then I typed the filename as foo.vba XD Changing the working directory to an invalid one, doesn't just make it fail to find the file. You can fully specify the file to run, and have an invalid working dir, as such:

Code: Select all

System.Execute("%windir%\System32\wscript.exe","Z:\Users\xcasxcursex\Downloads","/C C:\Users\xcasxcursex\Downloads\foo.vbs");
And it won't work. But since you have a relative path and a working directory, this all says to me that "S:\Dropbox\Streaming\OBS Assets\Overlay Assets\StuPC_Set_Default_Audio_Device_-_Game_(Realtek_Optical_Out).vbs" Doesn't actually exist.
cattywampus
Posts: 15
Joined: Fri Nov 23, 2018 3:25 am

Re: Windows 1909 - Macro - System.Execute no longer working

Post by cattywampus »

Hey, thanks for the reply...

I double and triple checked and the file path is sound - I even tried doing what you did, having an absolute path in the 3rd argument and changing "S:\" to "Z:\" for the start dir and it does the same.

I've tried different file names too and putting the files on different drives - it seems that for whatever reason the Macro app will not excute my bat or VBS files.

I've even tried on a computer running Windows 1903 as all my other computers are 1909...same. I think I am missing a key component somewhere.

I am trying to execute a bat file in the background without losing focus - and the way I found this to work was by actually using a VBS script that then executes the bat file silently:

The VBS Script:

Code: Select all

'HideBat.vbs
CreateObject("Wscript.Shell").Run "StuPC_Set_Default_Audio_Device_-_Game_(Realtek_Optical_Out).bat", 0, True
The bat file:

Code: Select all

nircmd setdefaultsounddevice "Game Realtek Optical GoXLR Opt In" 1
I have another set of 2 files that selects a different audio device. I can double click the files in Windows explorer and both sets change the default audio device - so the files themselves work.

When i try and execute either of them though from VM Macros, they don't work. If I try execute the bat file using the cmd prompt, the prompt will open but not actually execute the file. It's so weird. I think I am missing a component of Windows - something along the lines of a .NET framework? Something like that that is needed to tie things together and allow Macros to execute?

So confused...any help welcomed thanks.
xcasxcursex
Posts: 173
Joined: Tue Feb 18, 2020 12:04 am

Re: Windows 1909 - Macro - System.Execute no longer working

Post by xcasxcursex »

cattywampus wrote: having an absolute path in the 3rd argument and changing "S:\" to "Z:\" for the start dir and it does the same.
Well, I did that to try and break it, and it worked, and broke it, so that's expected :) The takeaway from this is that the working directory has to be valid, or the script won't run, even if the path to the script is valid.
If I try execute the bat file using the cmd prompt, the prompt will open but not actually execute the file.
Nice one, I was going to suggest this and then I read you'd already tried it. So, you're getting closer to the problem here. What you've discovered is that this problem is actually nothing to do with voicemeeter or macro buttons. The problem is that the script just won't work, period....so, naturally it's not working in macrobuttons either :)

So, drill deeper on that one. Rather than trying to run the batch file from the command prompt, copy the command from the batch file, and paste that into the shell.... so from what you've said this would mean trying

Code: Select all

wscript /C "hidebat.vbs"
In that vein, try making sure the bat file actually works

Code: Select all

"StuPC_Set_Default_Audio_Device_-_Game_(Realtek_Optical_Out).bat"
And that nircmd is actually working, by pasting those commands from the batch file into cmd.exe:

Code: Select all

nircmd setdefaultsounddevice "Game Realtek Optical GoXLR Opt In" 1
All of this is intended to be more specific in your knowledge of where it's broken. You can go the other way, too, to confirm what is not broken.
When I tested this I just made a quick test script so you may like to try that, too:

Code: Select all

foo.vbs
MsgBox("Hello, World!") ' Display message on computer screen.
This will pop up a message on screen. You can use this to make sure vbscripts are working, and if you want, you can set a macrobutton to execute this script to confirm that they are working via VM.

I also tried with a batch file:

Code: Select all

foo.bat
echo >> foo.txt
This will create a file named foo.txt in the current directory and put some text in it. Then I guess you could try your vbscript bat file hider on that:

Code: Select all

'HideBat.vbs
CreateObject("Wscript.Shell").Run "foo.bat", 0, True

Those last three I think will just work out of the box, and confirm that there's no problem with your PC like missing components or whatever.

Not sure just yet. But you're getting close
Post Reply