@@ -33,6 +33,11 @@ string findOne(string[] arr, string key, string defaultVal)
3333 return one == null ? defaultVal : one ;
3434 }
3535
36+ bool isFalsy ( string str )
37+ {
38+ return str == "no" || str == "0" || str == "false" ;
39+ }
40+
3641 public Main ( )
3742 {
3843 Application . UseWaitCursor = false ;
@@ -99,31 +104,37 @@ public Main()
99104 }
100105
101106 //MessageBox.Show(args.ToString());
102- runExe ( args . ToString ( ) , exePath , getKey ( "window" , null ) , getKey ( "style" , null ) , getKey ( "dir" , runDir ) , null , null ) ;
107+ runExe ( args . ToString ( ) , exePath , getKey ( "shell" , null ) , getKey ( " window", null ) , getKey ( "style" , null ) , getKey ( "dir" , runDir ) , null , null ) ;
103108 }
104109
105110
106- Process runExe ( string arg , string exePath , string strWindow , string strShow , string workingDir , Action < object , EventArgs > onExit , StringBuilder outputBuilder )
111+ Process runExe ( string arg , string exePath , string strShell , string strWindow , string strShow , string workingDir , Action < object , EventArgs > onExit , StringBuilder outputBuilder )
107112 {
108113
109114 Process myProcess = new Process ( ) ;
110115
111116 ProcessStartInfo startInfo = new ProcessStartInfo ( ) ;
112117
113- startInfo . UseShellExecute = true ;
118+ bool useShell = strShell != null ? ! isFalsy ( strShell )
119+ : true ;
120+
121+ startInfo . UseShellExecute = useShell ;
122+
114123 startInfo . FileName = exePath ;
115124
116125 string style = findOne ( new string [ ] { "Normal" , "Minimized" , "Maximized" , "Hidden" , "Hide" } , strShow , "Normal" ) ;
117126 //MessageBox.Show(style);
118- startInfo . WindowStyle = style == "Hidden" || style == "Hide" ? ProcessWindowStyle . Hidden
127+ bool isHide = style == "Hidden" || style == "Hide" ;
128+ startInfo . WindowStyle = isHide ? ProcessWindowStyle . Hidden
119129 : style == "Minimized" ? ProcessWindowStyle . Minimized
120130 : style == "Maximized" ? ProcessWindowStyle . Maximized
121131 : ProcessWindowStyle . Normal ;
122132
123- // ignored here, since UseShellExecute = true
124- startInfo . CreateNoWindow = strWindow == "no" || strWindow == "0" ;
133+ // when UseShellExecute = true will be ignored
134+ startInfo . CreateNoWindow = isHide || isFalsy ( strWindow ) ;
135+
136+ //MessageBox.Show("" +workingDir+ startInfo.WindowStyle + useShell+ isHide + isFalsy(strWindow));
125137
126- //MessageBox.Show(workingDir);
127138 if ( workingDir != null ) startInfo . WorkingDirectory = workingDir ;
128139 startInfo . Arguments = arg ;
129140
0 commit comments