Skip to content

Commit

Permalink
fix nonascii path problam
Browse files Browse the repository at this point in the history
  • Loading branch information
URenko committed Dec 8, 2018
1 parent b891504 commit 7085978
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions utils/win32elevate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import os
import sys
import subprocess
import locale

sysencoding = locale.getpreferredencoding()

import ctypes
from ctypes.wintypes import HANDLE, BOOL, DWORD, HWND, HINSTANCE, HKEY
Expand Down Expand Up @@ -138,7 +141,7 @@ def elevateAdminRights(waitAndClose=True, reattachConsole=True):
# this is host process that doesn't have administrative rights
params = subprocess.list2cmdline(sysargv + [ELEVATE_MARKER])
executeInfo = ShellExecuteInfo(fMask=SEE_MASK_NOCLOSEPROCESS, hwnd=None, lpVerb=b'runas',
lpFile=sys.executable.encode('ascii'), lpParameters=params.encode('ascii'),
lpFile=sys.executable.encode(sysencoding), lpParameters=params.encode(sysencoding),
lpDirectory=None,
nShow=SW_HIDE if reattachConsole else SW_SHOW)
if reattachConsole and not all(stream.isatty() for stream in (sys.stdin, sys.stdout,
Expand Down Expand Up @@ -186,7 +189,7 @@ def elevateAdminRun(args=sysargv, executable=sys.executable,
args = subprocess.list2cmdline(args)
executeInfo = ShellExecuteInfo(fMask=SEE_MASK_NOCLOSEPROCESS, hwnd=None,
lpVerb='' if areAdminRightsElevated() else b'runas',
lpFile=executable.encode('ascii'), lpParameters=args.encode('ascii'),
lpFile=executable.encode(sysencoding), lpParameters=args.encode(sysencoding),
lpDirectory=None,
nShow=SW_HIDE if reattachConsole else SW_SHOW)

Expand Down

0 comments on commit 7085978

Please sign in to comment.