unifiedremote / Docs

Official API documentation.
149 stars 33 forks source link

os.start() not working for .lnk and .bat files? #35

Open Stackor opened 3 years ago

Stackor commented 3 years ago

I am trying to make a custom remote with buttons starting different Windows 10 apps.

Building upon the example files, I already defined appropriate functions using os.start() and a layout with buttons to trigger them on tap.

To keep things flexible, I do not want to hardcode the path to each app's executable in the .lua. Instead, I use os.start() to launch generic Windows .lnk files inside a subfolder of the remote which "point" to the executables:

actions.command1 = function ()
  os.start("\"C:\\ProgramData\\Unified Remote\\Remotes\\Custom\\WinApps\\Links\\Command1.lnk\"");
end

Unfortunately, the remote shows up on my client, but the buttons won't work. Tried to run a .bat file instead, to no avail either.

Is os.start() limited to .exe files only?

Or am I maybe doing something wrong with the string escapes? (I added surrounding escaped doublequotes to the string because I know that command prompt requires them if the path contains spaces.)

jamescalekdor commented 1 year ago

hey im not sure if you are still having this issue but this is my work around my .lnk file is called "documents.lnk"

my .bat file looks like this:

%SystemRoot%\explorer.exe "Documents.lnk"

my remote.lua line looks like this:

actions.designer = function () os.open("C:\Users\jimlo\Desktop\code\delayed startup\runner.vbs"); end

but i also have a .vbs script that sits in between that allows the .bat file to run in the background and it looks like this:

Dim shell Set shell = CreateObject("WScript.Shell") Shell.CurrentDirectory = "C:\Users\jimlo\Desktop\code\delayed startup" shell.Run "gem.bat", 0

I think that using "%SystemRoot%\explorer.exe" over "open" in .bat was the fix

hope that helped a bit.

Stackor commented 1 year ago

Thanks for sharing! I guess the explorer.exe will do the trick for me. Very helpful, thanks!

Am Fr., 9. Juni 2023 um 08:03 Uhr schrieb jamescalekdor < @.***>:

hey im not sure if you are still having this issue but this is my work around my .lnk file is called "documents.lnk"

my .bat file looks like this:

%SystemRoot%\explorer.exe "Documents.lnk"

my remote.lua line looks like this:

actions.designer = function () os.open("C:\Users\jimlo\Desktop\code\delayed startup\runner.vbs"); end

but i also have a .vbs script that sits in between that allows the .bat file to run in the background and it looks like this:

Dim shell Set shell = CreateObject("WScript.Shell") Shell.CurrentDirectory = "C:\Users\jimlo\Desktop\code\delayed startup" shell.Run "gem.bat", 0

I think that using "%SystemRoot%\explorer.exe" over "open" in .bat was the fix

hope that helped a bit.

— Reply to this email directly, view it on GitHub https://github.com/unifiedremote/Docs/issues/35#issuecomment-1584020479, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEZPIKNVI2FKUB7A62MDHCDXKK4BZANCNFSM432D553Q . You are receiving this because you authored the thread.Message ID: @.***>

jamescalekdor commented 1 year ago

no problem, i know how frustrating it is to try to find a fix for niche issues like this i hope it works for you.

aabeba commented 1 year ago

Any chance you can help me out with the same problem? I have a .bat running a .ps1:

The batch file: Powershell.exe -executionpolicy remotesigned -File

The PS script:

The lua file: --@help Command 1 actions.command1 = function () os.start(
jamescalekdor commented 1 year ago

@aabeba I'm sorry, I'm not sure I understand your problem. Maybe send a pic of the error message? my first guess would be (if it is the same error):

%SystemRoot%\explorer.exe "script path"

I would also note in the .lua file your path needs to have double slashes I.E:

"C:\\Users\\user\\Desktop\\code\\delayed startup\\runner.vbs"