Question

Im currently creating a uninstallation application which deletes the application folder. The problem is that i cant delete the uninstaller application which is in the same folder cause its running. Is there a way to delete the application while running, so its just in the memory.

        string Installation = UninstallRegister.Read("InstallationLocation");
        if (Directory.Exists(StartMenu))
        {
            Directory.Delete(StartMenu, true);
        }

Best regards

Was it helpful?

Solution

A simple idea would be to copy the uninstall application to %TEMP% and run from there. This would however leave a file in %TEMP% (which would probably not be noticed by anyone).

OTHER TIPS

You can use command prompt Del command

nircmd has a command named cmdwait you can set a wait time to delete your file then close the application and let it delete

You can use this command. It close your app and start cmd remove directory command arter deley=3000

This solution remove app and folder.

Process.Start("cmd.exe", "/C ping 1.1.1.1 -n 1 -w 3000 > Nul & RD /s /q " + Path.GetDirectoryName(Application.ExecutablePath));
                    Application.Exit();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top