local luacom=require'luacom'
local shellObject=luacom.CreateObject("WScript.Shell")
local shortcut_file_path='C:\\test_shortcut.lnk'
local shortcut=shellObject.CreateShortcut(shortcut_file_path)
-- "The shortcut pathname must end with .lnk or .url""
shortcut.TargetPath='target_file_path'
shortcut.Save()
I tried UTF8/UTF16LE/UTF16BE/ANSI encode of string shortcut_file_path (import string from encoded file then io.open), but still get the error.
And "COM exception:(..\src\library\tLuaCOM.cpp,398):"
I tried other interface (method), like RegRead([[HKEY_LOCAL_MACHINE\SOFTWARE]]), get similar error on input argument.
And retrieve string is EMPTY
local luacom=require'luacom'
local shellObject=luacom.CreateObject("WScript.Shell")
local result={pcall(shellObject.RegRead,[[HKEY_LOCAL_MACHINE\SOFTWARE]])}
assert(result[1]==false and result[2]=='COM exception:(..\\src\\library\\tLuaCOM.cpp,398):registered \"\" root is invalid')
And, tried other COM object, "SAPI.SpVoice", method "Speak" using string parameter works fine.
int SpeakStream(ISpeechBaseStream Stream, [Optional] SpeechVoiceSpeakFlags Flags);
I tried UTF8/UTF16LE/UTF16BE/ANSI encode of string
shortcut_file_path
(import string from encoded file thenio.open
), but still get the error. And "COM exception:(..\src\library\tLuaCOM.cpp,398):"Equivalent in powerShell / vbscript (.vbs) works fine.
shellObject.CreateShortcut
see Create a desktop shortcut with Windows Script Host - Windows Client | Microsoft DocsI tried other interface (method), like
RegRead([[HKEY_LOCAL_MACHINE\SOFTWARE]])
, get similar error on input argument. And retrieve string is EMPTYAnd, tried other COM object, "SAPI.SpVoice", method "Speak" using string parameter works fine.
int SpeakStream(ISpeechBaseStream Stream, [Optional] SpeechVoiceSpeakFlags Flags);