0

How to delete my windows application app.exe in program files on uninstalling in c#....On uninstalling my exe its not getting removed from program files...I gave the administrative rts as follows for my app.exe...Also under which event i should write the code to do so...
Collapse | Copy Code
`

Inline Code Example HereProcessStartInfo proc = new ProcessStartInfo();
proc.UseShellExecute = true;
proc.FileName = Application.ExecutablePath;
proc.Verb = "runas";



try
            {

                Process.Start(proc);

            }

            catch

            {

                // The user refused the elevation.

                // Do nothing and return directly ...

                return;

            }

            Application.Exit();  // Q

`

and also added app.manifest with requireadministrator option...Still its not going from program files on uninstalling...

2
Contributors
1
Reply
13
Views
4 Years
Discussion Span
Last Post by Ketsuekiame
0

A program can't delete itself because it's currently running. You need to create a Windows Scheduled task to delete the file on the next boot up/shut down.

You need to P/Invoke MoveFileEx which will mark the file/folder for deletion upon the next boot up.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.