-
Notifications
You must be signed in to change notification settings - Fork 43
Description
utils.elevate(...) seems to translate paths badly if it contains Unicode characters, this is an issue for Electron applications since they are commonly installed in %AppData% and the Windows user folder is named after the user.
(The error message says "Could not find file X. Check the name and try again")
Steps to reproduce
- Create a folder containing Unicode characters
- Add a .bat script to that folder
- Try to elevate the bat script e.g.
require("windows-registry").utils.elevate("C:\\שךקכ\\test.bat", "", function(res, err) { console.log(error);})
Expected outcome
The script should be executed elevated.
Actual outcome
The path becomes broken an error prompt is shown that the file could not be found.
Research
Created a console application in C++ that performs a shell execute of the bat script, similar to how windows-registry does it. The Unicode are encoded differently since there are issues with using Unicode characters in the source file, but it is the exactly same path.
This works as intended.
SHELLEXECUTEINFO shExecInfo;
shExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
//shExecInfo.cbSize = SHELLEXECUTEINFO.size;
shExecInfo.fMask = NULL;
shExecInfo.hwnd = NULL;
shExecInfo.lpVerb = "runas";
shExecInfo.lpFile = "C:\\\u05E9\u05DA\u05E7\u05DB\\test.bat";
shExecInfo.lpParameters = "";
shExecInfo.lpDirectory = NULL;
shExecInfo.nShow = SW_SHOWNORMAL;
shExecInfo.hInstApp = NULL;
shExecInfo.lpIDList = NULL;
shExecInfo.lpClass = NULL;
shExecInfo.hkeyClass = NULL;
shExecInfo.dwHotKey = NULL;
ShellExecuteEx(&shExecInfo);
require("fs").statSync("C:\\שךקכ\\test.bat")
also works as intended, so there seems to be something that goes lost in translation when it comes to the path and elevate()