Hello everybody,
The question has already arisen about Run PowerShell in WinForms, which intrinsically is questionable, but sometimes gives a good help in giving a results quickly.
I proposed this :
I use it in a project of mine in .Net 6, and it runs pretty good.
Now, as discussed in another thread, it appears the Visual Studio toolbox stays empty in this project, representing a menace about maintaining the project.
I discover that in a .Net Framework 4.7.2, for the moment being there is still a toolbox.
I have a terrible tendency to accord some credit to people about not being completely stupid, so I think perhaps this will keep on working a little time.
Now, here is why I open a new thread about this. In the .Net 6 project the code works exactly as expected, the file is read without anything noticeable on the screen. But in .Net 4.7.2, the PowerShell window is opened. Of course it stays completely black except the title, as the scripts writes nothing on the console. .Net Framework seems to ignore
Does anybody have any idea about this difference of execution?
I copied/pasted the code from a project to the other, just increasing a little the delay as the execution seemed to take a little more time as appeared with not up-to-date data, and displaying a window on the screen can be what takes more time.
The question has already arisen about Run PowerShell in WinForms, which intrinsically is questionable, but sometimes gives a good help in giving a results quickly.
I proposed this :
Execute PowerShell from a C# code in a WinForms project:
Process p = new Process();
p.StartInfo = new ProcessStartInfo("PowerShell", @"D:\Scripts\ReduceDirWindows.ps1");
p.StartInfo.CreateNoWindow = true;
p.Start();
System.Threading.Thread.Sleep(1000);
I use it in a project of mine in .Net 6, and it runs pretty good.
Now, as discussed in another thread, it appears the Visual Studio toolbox stays empty in this project, representing a menace about maintaining the project.
I discover that in a .Net Framework 4.7.2, for the moment being there is still a toolbox.
I have a terrible tendency to accord some credit to people about not being completely stupid, so I think perhaps this will keep on working a little time.
Now, here is why I open a new thread about this. In the .Net 6 project the code works exactly as expected, the file is read without anything noticeable on the screen. But in .Net 4.7.2, the PowerShell window is opened. Of course it stays completely black except the title, as the scripts writes nothing on the console. .Net Framework seems to ignore
p.StartInfo.CreateNoWindow = true;
Does anybody have any idea about this difference of execution?
I copied/pasted the code from a project to the other, just increasing a little the delay as the execution seemed to take a little more time as appeared with not up-to-date data, and displaying a window on the screen can be what takes more time.