I created an window application for which I need to create setup.For creating setup i am using NSIS. I had written script to create setup file I need to link this setup file to Add/remove program. For add link to add/remove program I am using following code:
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\appName" "DisplayName" "Name"
WriteRegExpandStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\appName" "AppName" '"$INSTDIR\UninstallApp.exe"'
To delete the link from add/Remove program I am using following code :
DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\appName"
But this is not working.
Except for the fact that "AppName" is wrong and should be "UninstallString" it looks like the code should work.
You should inspect it with Process Monitor and see why the delete fails. My only guess at this point is that your real code has a typo...
Related
According to the docs, Inno Setup uses AppName or AppId to allow you to create an update program that will automatically put its files in the same path which the user installed the initial application to.
I need to be able to determine where Inno Setup installed files to based on AppId, but NOT from within Inno Setup. For example, I need to be able to determine this from a Python script.
One use case: patching a file in the installed program location. It would be overkill to package an entire installer just to, say, conditionally add or edit a line in a text file. A simple Python script could accomplish this, plus the user could review the script if they desired. I cannot and should not assume the user just installed to the default location, hence why I need to be able to see where the user installed the program.
Inno Setup obviously stores this somewhere since it is able to make its own patches, but I can't seem to find it in the registry. I've searched the Registry for my app ID but I only see it in the Uninstall section. I can probably pull it from there, but I think you can also create installers without uninstallers – where would this end up in that case?
The path is stored to registry to HKLM (administrative install mode) or HKCU (non administrative install mode) to a subkey named after the AppId with _is1 suffix, stored under a key SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall (as you alraedy know). The value name is Inno Setup: App Path. The path is also stored to InstallLocation with additional trailing slash, as that's where Windows reads it from. But Inno Setup reads the first value.
An example for HKLM:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\appid_is1]
"Inno Setup: App Path"="C:\\Program Files\\My Program"
"InstallLocation"="C:\\Program Files\\My Program\\"
You can see this in dozens questions, that show how to read the value in Inno Setup code. For example:
How to get path of installation of target game/application from registry when installing mod/plugin using Inno Setup?
If you create an installer what cannot be uninstalled (CreateUninstallRegKey=no or CreateUninstallRegKey=no), then the path is not store anywhere. In such case you would have to explicitly code your installer to store the path for you somewhere.
I am working on an installer for the application written using electron and electron-builder. I was able to manage most of the issues but one. During uninstall process i have to remove registry key previously set outside of nsis installer. I already found a way to do that:
DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "APP_NAME_GOES_HERE"
The problem i am having is, i would like to avoid hard coding the name of app and get it instead from some variable already defined by electron or electron builder.
This is how installer looks:
As you can see there is application name in a title of window KIOSKMEGA-JS and its also set at the bottom of page along with the version and its also visible in a path string. I did not define the name anywhere aside from package.json file. Which means that electron is somehow passing this name to nsis.
Does anyone know how i can access this value in my installer.nsh custom script? I tried things like $APPNAME or $NAME, without luck.
Use $(^Name) to access the standard language string set by the Name attribute in a script.
It looks like electron-builder has a define named ${PRODUCT_NAME}.
I am creating an NSIS Installer package sample for a project I am working on. I need certain MS Access and Excel files to be automatically placed in the documents folder directory; "C:\User\MyName\Documents\PexApp\Storage", instead on my application having to connect to a network sharefolder to get the files. I want offline installation to be possible.
There are three excel files that are supposed to go to the PexApp folder and two Access database files that are supposed to go to the Storage folder inside the PexApp folder.
How do I add the files inside the installer package (if it is possible) so that they may be available for offline placement through the installer and what scripts or methods should I use or consider?
OutFile "MySetup.exe"
Name "MySetup"
RequestExecutionLevel user
Section
SetOutPath "$DOCUMENTS\PexApp"
File "Excel1.xls"
File "Excel2.xls"
File "Excel3.xls"
SetOutPath "$DOCUMENTS\PexApp\Storage"
File "Access1.db"
File "Access2.db"
SectionEnd
Is it possible to change the icon of the uninstaller shortcut in the Start menu without storing a separate icon file (to the app folder)?
I see this: Using Resource Hacker for changing the icon after the build, but I cannot implement it.
My code:
[Icons]
Name: {group}\{cm:UninstallProgram,{#MyAppName}}; Filename: {uninstallexe}
An icon of a Windows shell shortcut can be set by an external icon file (what you do not want) or by the file the shortcut points to. So you have to modify the icon of the uninstaller.
You have to modify the uninstaller icon on a compile time.
You cannot do this on install time, as the uninstaller includes its own checksum. If you modify the uninstaller, it with refuse to start, claiming it is corrupted. Unless you find out how to also fix the checksum stored in the uninstaller.
But Inno Setup does not really allow modifying the uninstaller icon on a compile time.
What you can do, is to abuse the SignTool "callback". The command set to SignTool processes even the uninstaller. And it can actually do anything with the uninstaller, not only "sign" it. But it has to "sign" it in any case (Inno Setup explicitly checks that the executable was signed after the "tool" finishes).
You can achieve that by setting SignTool to a batch file (or other script) that will run the actual signtool.exe in the end, but before that, it will modify the icon (e.g. using Resource Hacker command-line).
For an example of such batch file that both modify the uninstaller and signs it, see Microsoft SmartScreen - suspended using Inno Setup installer?
So this is doable, only if you do code signing (what you should anyway). You need a code signing certificate for that.
Disclaimer: Adding a shortcut to an uninstaller to Start menu is against Windows guidelines (and creating Start menu groups is against Windows guidelines for Windows 8 and above at least).
I have an add-in in Excel that needs to store some data in the HKEY_LOCAL_MACHINE registry. because of the UAC control in Windows Vista and earlier versions, I added a manifest file. But it is just not working. I even added the manifests in each of the projects of my solution. I have 5 projects in my solution (3 VB projects, 1 c++ and 1 deployment).
I am using VS2005. I added the manifest file to the project (with the requestedExecutionLevel set to "requireAdministrator" and embedded the manifest using mt.exe in a post-build command.
Even with that, I am still getting an access denied to the HKEY_LOCAL_MACHINE. The only thing that is working is when I start Excel as "Run as administrator".
Any clue what the problem might be? Thanks.
Manifests in DLL do not affect the execution level of the application, in this case it's excel.exe.
Here are the options you have:
to run Excel as administrator;
to modify the add-on to write to HKCU rather than HKLM.
If you need to store data available to other users, consider using ProgramData folder (CSIDL_COMMON_APPDATA or FOLDERID_ProgramData). Then your add-on creates a subdirectory inside ProgramData and modifies its permission so that this new directory is writable by anyone (by default, only the user account that created the folder has write permissions, other users can only read).
There are some other options:
You can write a service that your add-on will communicate to write data into HKLM but it's not.
You can create an elevated COM object which will write the data into HKLM.
Although users don't expect Excel to require elevation when run, therefore consider changing your logic so that your add-on does not require elevation at all.