Skip to content

utils.elevate(...) breaks if path contains Unicode characters #55

@robinwassen

Description

@robinwassen

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.

windows_registry_unicode

(The error message says "Could not find file X. Check the name and try again")

Steps to reproduce

  1. Create a folder containing Unicode characters
  2. Add a .bat script to that folder
  3. 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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions