Change cwd to %USERPROFILE% before executing command.

This commit is contained in:
zlsun
2014-07-01 17:07:13 +08:00
parent 9e874b241a
commit fad796f834

View File

@@ -297,6 +297,9 @@ namespace Wox.Infrastructure
int driveId = -1; int driveId = -1;
if (PromptForMedia(cmd, out driveId)) if (PromptForMedia(cmd, out driveId))
{ {
string oldCwd = Environment.CurrentDirectory;
string home = Environment.GetEnvironmentVariable("USERPROFILE");
Environment.CurrentDirectory = home;
ShellExecCmdLine( ShellExecCmdLine(
IntPtr.Zero, IntPtr.Zero,
errorDialogHwnd, errorDialogHwnd,
@@ -305,6 +308,7 @@ namespace Wox.Infrastructure
global::System.Diagnostics.ProcessWindowStyle.Normal, global::System.Diagnostics.ProcessWindowStyle.Normal,
ShellExecCmdLineFlags.SECL__IGNORE_ERROR | ShellExecCmdLineFlags.SECL_USE_IDLIST | ShellExecCmdLineFlags.SECL_LOG_USAGE | (showErrorDialog ? 0 : ShellExecCmdLineFlags.SECL_NO_UI) ShellExecCmdLineFlags.SECL__IGNORE_ERROR | ShellExecCmdLineFlags.SECL_USE_IDLIST | ShellExecCmdLineFlags.SECL_LOG_USAGE | (showErrorDialog ? 0 : ShellExecCmdLineFlags.SECL_NO_UI)
); );
Environment.CurrentDirectory = oldCwd;
} }
else else
{ // Device not ready 0x80070015 { // Device not ready 0x80070015