RamonUnch / AltSnap

Maintained continuation of Stefan Sundin's AltDrag
GNU General Public License v3.0
1.91k stars 60 forks source link

Fix scheduled task batch script #512

Closed VladKappa closed 2 months ago

VladKappa commented 3 months ago

The scheduled task batch script did not work so I adjusted it & added a note to edit the path from the XML file.

It seems that /TR (task run program path) can't be used with /XML

also, /XML seems to require /TN (task name)

Fixes https://github.com/RamonUnch/AltSnap/issues/505

RamonUnch commented 3 months ago

Thanks for your effort. I do not know in which context but I am sure /TR was working fine on my PC with an xml file. I guess it was Win7/XP...

So you actually need to edit the xml file before starting the batch? I guess you should prompt the user to do that instead of saying it in an invisible comment.

RustyPedrosa commented 3 months ago

Especially considering the script probably runs from same dir as altsnap.exe, it would be nice for the path to be set automatically.

That said, this commit does fix the problem for me on Win11. Does that mean this breaks the script for Win7/XP?

This was the error on win11 before the commit:

PS C:\Users\rusty\AppData\Roaming\AltSnap> .\sch_On.bat
=============================================================================
= Setup Scheduled task for elevated AltSnap auto-start without UAC prompt   =
= If you do not want to continue, close the window or hit Ctrl+C            =
=============================================================================
Going to run command:
schtasks.exe /CREATE /XML .\AltSnap.xml /TR "C:\Users\rusty\AppData\Roaming\AltSnap\AltSnap.exe"
Press any key to continue . . .

C:\Users\rusty\AppData\Roaming\AltSnap>schtasks.exe /CREATE /XML .\AltSnap.xml /TR "C:\Users\rusty\AppData\Roaming\AltSnap\AltSnap.exe"
Invalid syntax. Mandatory option 'tn' is missing.
Type "CREATE /?" for usage.
Press any key to continue . . .
PS C:\Users\rusty\AppData\Roaming\AltSnap>

Hope that helps. Thank you both for everything.

RamonUnch commented 3 months ago

Your pach seems fine, I was just saying you should add the :: Make sure to adjust the path to the AltSnap executable in the AltSnap.xml file. line into an @echo line..

Also maybe %APPDATA%\AltSnap\AltSnap.exe would work? if it did it would be a good default for the AltSnap.xml file...

VladKappa commented 3 months ago

Perhaps task scheduler behaves differently on Win 10/11?

Checked with path %APPDATA%\AltSnap\AltSnap.exe in XML and it works.

But in case AltSnap is installed in a custom location then the user should adjust the XML.

RamonUnch commented 2 months ago

Thank a lot for your help!