From 6870e03ffe8cbeef469fe3c8852f14105fb4dcc9 Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Tue, 1 Jul 2014 18:04:35 +0800 Subject: [PATCH] Add Empty Check for GetEnvironmentVariable Method. --- Wox.Infrastructure/WindowsShellRun.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Wox.Infrastructure/WindowsShellRun.cs b/Wox.Infrastructure/WindowsShellRun.cs index 0d3649ce89..9a6e84d747 100644 --- a/Wox.Infrastructure/WindowsShellRun.cs +++ b/Wox.Infrastructure/WindowsShellRun.cs @@ -299,7 +299,7 @@ namespace Wox.Infrastructure { string oldCwd = Environment.CurrentDirectory; string home = Environment.GetEnvironmentVariable("USERPROFILE"); - Environment.CurrentDirectory = home; + if(!string.IsNullOrEmpty(home)) Environment.CurrentDirectory = home; ShellExecCmdLine( IntPtr.Zero, errorDialogHwnd, @@ -308,7 +308,7 @@ namespace Wox.Infrastructure global::System.Diagnostics.ProcessWindowStyle.Normal, ShellExecCmdLineFlags.SECL__IGNORE_ERROR | ShellExecCmdLineFlags.SECL_USE_IDLIST | ShellExecCmdLineFlags.SECL_LOG_USAGE | (showErrorDialog ? 0 : ShellExecCmdLineFlags.SECL_NO_UI) ); - Environment.CurrentDirectory = oldCwd; + if (!string.IsNullOrEmpty(home)) Environment.CurrentDirectory = oldCwd; } else { // Device not ready 0x80070015