Frosthaven / voicemeeter-windows-volume

Tray app that allows you to sync windows volume and mute state to Voicemeeter volume controls
303 stars 13 forks source link

Automatically Start With Windows doesn't work #41

Open LucasOe opened 1 year ago

LucasOe commented 1 year ago

When I uncheck and check the settings Automatically Start With Windows no task is created. When I try to manually import the task created by autoStartManager.js with the following XML, I get an error "The specified account name is not valid":

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.3" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Description>Runs Voicemeeter Windows Volume app at login</Description>
    <SecurityDescriptor></SecurityDescriptor>
  </RegistrationInfo>
  <Triggers>
    <LogonTrigger>
      <Enabled>true</Enabled>
    </LogonTrigger>
  </Triggers>
  <Principals>
    <Principal>
      <GroupId>BUILTIN\Administrators</GroupId>
      <RunLevel>HighestAvailable</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <Duration>PT10M</Duration>
      <WaitTimeout>PT1H</WaitTimeout>
      <StopOnIdleEnd>false</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
    <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions>
    <Exec>
      <Command>powershell.exe</Command>
      <Arguments>-ExecutionPolicy Bypass -WindowStyle Hidden -File $dir/auto-start-task.ps1 -FFFeatureOff</Arguments>
    </Exec>
  </Actions>
</Task>

I think the reason autostart doesn't work for me is because of the GroupId BUILTIN\Administrators. Changing it to my User name fixes the problem.

Frosthaven commented 1 year ago

This makes sense - it uses administrative level access to ensure it can start a hidden window. I'll see if we can add some logic to have it inject the current windows username instead when I next open it up. Thanks for the submission.

genderneutralnoun commented 1 year ago

I've been having a similar problem, though I don't have the technical knowledge to know if it's the exact same problem. Any way I can manually add a startup task for this applet until the dev updates it to fix the issue?

Frosthaven commented 1 year ago

I've been having a similar problem, though I don't have the technical knowledge to know if it's the exact same problem. Any way I can manually add a startup task for this applet until the dev updates it to fix the issue?

Yeah you can absolutely do that! Enable the automatically start option for now so that you can open windows task scheduler and investigate the task for it if you need to see exactly what it calls - but beyond that you can certainly make your own task based on it and disable the built-in autostart feature.

ISAKEM commented 11 months ago

I am having the same problem and I just cant seem to get it to work

tetriskillerh commented 9 months ago

I found a solution for that Problem.

Cred: SimplyCoded Vid REF: https://www.youtube.com/watch?v=Jg2UFoMWDB4

Code REF: https://gist.github.com/codeartery/1252670806e4b7d8993a38be448f58f0

Code:

REM:<RunAsAdminNoUAC>
With CreateObject("WScript.Shell")
  If WScript.Arguments.Named.Exists("CreateTask") Then
    .Run "schtasks /Create /SC ONCE /TN """ & WScript.ScriptName & """ /TR ""wscript.exe \""" & WScript.ScriptFullName & "\"" /AsAdmin"" /ST 00:01 /IT /F /RL HIGHEST", 0, True
  ElseIf Not WScript.Arguments.Named.Exists("AsAdmin") Then
    If .Run("schtasks /Query /FO CSV /NH /TN """ & WScript.ScriptName & """", 0, True) = 0 Then
      .Run "schtasks /Run /TN """ & WScript.ScriptName & """", 0, True
    Else
      CreateObject("Shell.Application").ShellExecute "wscript.exe", """" & WScript.ScriptFullName & """ /CreateTask", "", "runas", 1
    End If
    WScript.Quit
  End If
End With
REM:</RunAsAdminNoUAC>

I edited C:\Program Files (x86)\Voicemeeter Windows Volume\app-launcher.vbs and put this code before the code that is already in there:

'NEW CODE

REM:<RunAsAdminNoUAC>
With CreateObject("WScript.Shell")
  If WScript.Arguments.Named.Exists("CreateTask") Then
    .Run "schtasks /Create /SC ONCE /TN """ & WScript.ScriptName & """ /TR ""wscript.exe \""" & WScript.ScriptFullName & "\"" /AsAdmin"" /ST 00:01 /IT /F /RL HIGHEST", 0, True
  ElseIf Not WScript.Arguments.Named.Exists("AsAdmin") Then
    If .Run("schtasks /Query /FO CSV /NH /TN """ & WScript.ScriptName & """", 0, True) = 0 Then
      .Run "schtasks /Run /TN """ & WScript.ScriptName & """", 0, True
    Else
      CreateObject("Shell.Application").ShellExecute "wscript.exe", """" & WScript.ScriptFullName & """ /CreateTask", "", "runas", 1
    End If
    WScript.Quit
  End If
End With
REM:</RunAsAdminNoUAC>

'ORIGINAL CODE

scriptdir = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)
Set Shell = CreateObject("Shell.Application")

'{{INJECT_START:PKG}}
Shell.ShellExecute scriptDir & "\required\VMWV.exe", , , "runas", 0
'{{INJECT_END:PKG}}

At the last step i put the file Voicemeeter Windows Volume out from C:\Users\$YOUR_USER_NAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Voicemeeter Windows Volume in the shell:startup folder you can enter this folder by pressing Windows+R and enter shell:startup.

I hope this helps. At the first run after Adding the new code it will ask you the last time for UAC but after that one it will never ask again.

tetriskillerh commented 9 months ago

It may be possible to copy the Voicemeeter Windows Volume file autoimaticaly to the shell:startup folder but i dont know how so maby somone else is so kind and reply to this.

genderneutralnoun commented 8 months ago

It may be possible to copy the Voicemeeter Windows Volume file autoimaticaly to the shell:startup folder but i dont know how so maby somone else is so kind and reply to this.

Actually, you can just create a shortcut. I don't know how to implement this on the developer's end, but I know it's possible; I've found shortcuts for programs I've installed (and enabled start with Windows on) in the folder without me putting them there.

Disclaimer: I haven't tested this thoroughly, but it did work for at least one Windows restart.

The steps for an end user are as follows:

  1. Go to your Voicemeeter Windows Volume directory. You should be able to find it by right-clicking on it in the tray and clicking on "Open Application Folder".
  2. Go up one folder, so that you are in C:\Program Files (x86)\Voicemeeter Windows Volume.
  3. Right click on app-laucher.vbs and click "Create shortcut". (This is the same file the Start Menu shortcut runs, so it should be perfectly fine.)
  4. (Optional) Cut (right click menu or CTRL-X) the shortcut and paste (right click menu or CTRL-V) it to your desktop or somewhere else you can easily access it again.
  5. Open the shell:startup folder. You can do this by hitting Win-R and typing in "shell:startup", or by going to C:\Users[insert your user name]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.
  6. Cut and paste the shortcut from where you pasted it earlier (or the Voicemeeter Windows Volume folder if you skipped step 3) into the startup folder.
  7. Done!

Be aware that when typing in shell:startup to the Windows Run dialogue (what comes up with you press Win-R) it will open a new File Explorer window, which is handy if you have the folder your shiny new shortcut is in open in another File Explorer window. Of course, running shell:startup is much faster than finding the startup page in File Explorer manually, but the Windows Run dialogue can be intimidating for the less tech-saavy - it was certainly rather intimidating the first time I used it.

tetriskillerh commented 8 months ago

Yes of course you can do that but I focused on disabling the Windows UAC request. Which would not be necessary if the autostart of the program itself would work.

lucasogodoy commented 7 months ago

The solution was working perfectly, but suddenly it stopped working...

Now it gives an error asking me to insert the app-launcher.vbs in the Startup folder, then when I insert it, it asks for the VMWV.exe file - if I insert it (along with the folder required), when restarting the machine, it opens two instances of the application.

lucasogodoy commented 7 months ago

To whom it may concern: I was able to get the app to start automatically with Windows and bypass UAC using Task Scheduler. Just create a task with high privileges.

tetriskillerh commented 5 months ago

To whom it may concern: I was able to get the app to start automatically with Windows and bypass UAC using Task Scheduler. Just create a task with high privileges.

Can you show or tell us exactly what you put in. Because I tried that in several ways and it did not work for me.

lucasogodoy commented 5 months ago

To whom it may concern: I was able to get the app to start automatically with Windows and bypass UAC using Task Scheduler. Just create a task with high privileges.

Can you show or tell us exactly what you put in. Because I tried that in several ways and it did not work for me.

In the task created in Task Scheduler:

That's what worked for me.