How to hard remove uninst.exe that is generated by NSIS? - nsis

I am using NSIS to write an installer for my windows application. After installing the application, an uninst.exe is also generated in my program directory. Later on I need to uninstall my program but I failed to do that in control panel. Therefore I went to the file system and tried to delete the directory. Everything other than that uninst.exe was removed. I've tried changing permission of this file and other methods but it doesn't work.

WriteUninstaller does not set file permissions or any other attribute that might prevent you from deleting it. It sounds like the file might still be in use by something on your machine.
Things to try:
Use Task Manager or Process Explorer to see if there is a uninst.exe process still running.
Use the find handle feature in Process Explorer to find any open handles to the file.
Use Process Monitor to get detailed information about the failed delete operation.
Check %LOCAL­APP­DATA%\Virtual­Store to make sure UAC Virtualization is not tricking you with "ghost" files.
Disable your Anti-Virus.
Reboot the machine and try to delete the file again.

Related

Python Windows Explorer Force Refresh

I have code, but it doesn't do what I want. I'm trying to delete thumbnail cache via Python script. If I have cache and explorer's open, some of the .db files won't delete because they're in use by explorer. Anyway, in my experimenting, the only way to do it is to change the advanced folder setting for displaying icons/thumbnails, and then restarting explorer. I can change the setting via script in the registry and then restart explorer. BUT, restarting explorer halts the script. So, I don't know. I also tried changing the setting and then sending the WM_SETTINGCHANGE message via SendMessageTimeout(). That didn't do the trick.
So, anyone have any idea how to unlock files (that are safe to delete) from explorer (this could also pertain to other in-use files) without restarting it? Also, I understand this is a sort of dumb project, but I have my reasons for doing it and it's what I want to do.
If I have cache and explorer's open, some of the .db files won't
delete because they're in use by explorer.
Because thumbcache.dll still has an open handle to the local thumbs.db file and does not currently implement a mechanism to release the handle to the file in a more dynamic and timely fashion.
They are only generated for compatibility with outdated applications, and are not required for Windows operations.
To work around the issue, enable User Group Policy setting for "Turn off the caching of thumbnails in hidden thumbs.db files":
Refer: http://support.microsoft.com/kb/2025703?
Also, you can directly edit the registry. Refer:Let me fix it myself
Related: "The action can't be completed because the file is open in Windows Explorer"

Unable to download sdk components

Whenever I try to start android studio, I get this:
What should I do?
It doesn't download and just keeps repeating this!
Refer: SO query
You can try the solution to avoid Downloading Components at startup so that AS launches and later on proceed manually.
To disable "Downloading Components" at startup,
Go to the installation directory of Android Studio. There you will
find a folder named "bin". Inside this folder there is a file named
"idea.properties". Open this file and add the following line to the
end of the file:
disable.android.first.run=true What this will do is disable the check
that Android Studio performs on first run and decides to download all
that stuff.
If it asks to save the file at some different place instead of
overwriting the original one, please check the access permissions to
the file.
I ran into this and it was actually working fine, despite looking broken. Wait and see if the filename changes after a while.
I think that is some bug, but it's just process of downloading.
Just wait for end of downloading and all will be ok.

Needing to raise and lower privileges as necessary in order to access network share, edit registry, then copy shortcuts on network share

I need to access a network share during the install process, and I also need to edit some registry keys. And finally, I'd like to add some shortcuts to a program that is over the network share.
To edit registry keys, I run the installer with elevated privileges. However, if I do that, I won't be able to see the network share as it is usually created without admin privileges.
There is a way to kill the installer and restart it with admin privileges, and this is fine for copying necessary files, but in order to create shortcuts that point to the network share, I would then need to downgrade my privileges again, in the middle of the Inno Setup step where it copies file, a step which I can't do anything in the middle of.
Any other options for a workaround? The only one that I found was this, which requires a registry edit (fine) and a restart (not as fine).
You can create the shortcut using some command and run it from [Run] section with runasoriginaluser flag.
See How do I create a shortcut via command-line in Windows?
Or do not kill the unelevated installer. Run it only to copy the files. And continue with the unelevated installer.
Also note that you can create a shortcut pointing to a nonexisting file.

SelfDeleting application in VC++?

I want to delete a folder which contains the currently running application. How can i do it..? is there any way of doing it ? i.e the folder which contains the application should delete after the application has finished running ?
Your best bet is probably to use the Win32 API MoveFileEx. It has a flag that can be set for deleting files when they are in use on the next reboot called MOVEFILE_DELAY_UNTIL_REBOOT. Set the new filename parameter of MoveFileEx to NULL to perform this type of delete.
If dwFlags specifies
MOVEFILE_DELAY_UNTIL_REBOOT and
lpNewFileName is NULL, MoveFileEx
registers the lpExistingFileName file
to be deleted when the system
restarts.
Note: Normal files that are in use can be deleted normally using the Win32 API DeleteFile depending on if they were opened (Using the Win32 API CreateFile) with FILE_SHARE_DELETE permission. I don't think running programs by default on Windows have that permission though. When a file is specified to be deleted that is in use but that was opened with this flag, then the file will be removed when the last file handle is closed.
This is hairy. I had to implement this once for a self-patching app, where the patcher had to (by client request) delete itself after installing the patch. You can do this by launching a helper DLL which deletes your process, along with itself.
The full method for deleting your process can be found here: http://www.handcraftedbytes.com/articles/writing-install-and-uninstall
As others have pointed out, you're not going to be able to delete the folder that your executable resides in while it exists there. My suggestion is to:
Use MoveFileEx to move your executable off to a temporary directory,
delete your application's directory,
delete your executable using the self-deleting DLL method described in the link above.
You cannot delete an executable file that is currently running, however you can delete a batch file that is currently running (cmd.exe loads the whole file into memory and then you can delete it).
So the simplest solution would be to launch a batch that tries to delete the .exe in a loop (because it may not work the first time - until your .exe has been unloaded) and then exit your process - with the batch file still running.

Getting the Windows CE uninstaller to work properly

On some of the devices that I am working on, the \Windows directory is not on permanent storage. That is, once the device is rebooted, whatever was written to \Windows is lost. This is particularly problematic for uninstalling programs since wceload.exe (the Windows CE CAB installer program) generates a .unload file and places it in \Windows. The application can be uninstalled before the device is rebooted, but afterward it can't (the "Remove Programs" tool in the control panel comes back with an error about not being able to open the unload file). So how can I get the .unload file to persist across reboots? Is there any way to control where the uninstaller (I believe it is called unload.exe) looks for the .unload file?
I haven't been able to find any good info on this still. It looks like the path to the unload file is hardcoded so the best I can do is make a backup of the unload file. If the user wishes to uninstall they will have to manually copy the file to the \windows directory and then use the uninstall tool in the control panel. Here is more info:
http://www.generation-nt.com/us/answer/wince5-force-wceload-install-unload-into-nonvolatile-memory-help-87676002.html
You can probably keep the .unload file across reboots by copying it to a persistent directory after installing. This directory may vary per device, e.g. \Hard Disk\ramroot\Windows or \Backup\Windows. It will then automatically be copied to the \Windows on reboot. (Although I am not sure whether such a directory and behavior exist for every device.)
To copy this file you need to execute a copy-statement from a custom setup-dll after the install completes. This codeproject-site has a very comprehensive explanation, with screenshots and code.
Simply re-Install application and then un-install from remove programs in control panel.

Resources