How to start batch file using nsis script? - nsis

I have successfully created exe file using NSIS.I have installed my application as windows service using following code:
Exec "$INSTDIR\bin\batch.bat"
I have checked this path
Start Menu -> Control Panel -> Administrative Tools -> Services.
My service name successfully installed.
Final step of my installation process start the application using following code:
!define MUI_FINISHPAGE_RUN net start servicename
But this code did not working well.If i select the checkbox it does not start the services.
My scenario is:
Final step of my installation process is, I have one checkbox.If the user select checkbox then the service started immediately.else dont start the service.but both the cases the service must be installed.How to solve this?
How to start the service using nsis scrit?

The correct code would be:
!define MUI_FINISHPAGE_RUN net
!define MUI_FINISHPAGE_RUN_PARAMETERS "start servicename"
or if you want to put the net command in a batch file or otherwise hide the console window, see this answer to one of your old questions...

Related

Is RestartManager required for Inno Setup CloseApplications?

I'm using Inno Setup 5.5.9. My installer includes the settings:
[Setup]
RestartApplications=no
CloseApplications=force
When I run the installer it identifies an application as still running and correctly shows the "The following applications are using files..." page. I choose to "Automatically close...", but nothing happens - the application remains running. I see these in my log file:
RestartManager found an application using one of our files: {redacted}
Can use RestartManager to avoid reboot? Yes (0)
CurStepChanged(1) called
Must the application register with the restart manager to auto close, even though I have specified 'no' for RestartApplications?

NOICONS switch in Inno setup tool not working

I am have installed innosetup-5.5.9-unicode.exe on windows 8.
I wrote an application say demo
when I try to install
c:\demo-2.0-x86.exe /NOICONS <== It is getting installed with out any issue, but as per Inno tool documentation
/NOICONS
Instructs Setup to initially check the Don't create a Start Menu folder check box on the Select Start Menu Folder wizard page.
But its still creates shortcuts and is visible in Start Menu Folder.
Do we have any workaround for this ? or need to write some extra code ?

Windows 10 cannot associate file to clickonce application

I have a clickonce application which works fine on windows 7.
When it's being installed on a windows 10 machine, it seems that the specific file for our application cannot be properly associated to the clickonce application.
If I click right on the file, and choose "open with", I can see in the list "ClickOnce Application Deployment Support Library". But if I choose this option, I get a message saying "this application cannot be executed on your PC". If I decide to choose directly the .exe file of the clickonce application (C:\Users\xxx\AppData\Local\Apps...), it will not work properly (version & update detection).
I am able to install my application and I am able to run it properly from the start menu. The only thing not working is the file association. I have tried to uninstall, and reinstall, but it doesn't change anything.
Edit :
I have installed the application on another windows 10 machine, and everything works fine (including the file assocation "automatically when installed & when specifiying it manually"). So I think the problem is not "generic" for all windows 10 machines.
I was able to reproduce montueron's issue. After turning on logging (https://msdn.microsoft.com/en-us/library/dd996997.aspx) and setting the logging location (https://msdn.microsoft.com/en-us/library/ms404265.aspx), I was able to determine that the file association was being skipped: File association for ".tiff" skipped, since another application is using it.
Here is what I did to solve my problem on Windows 10. My goal is to associate my ClickOnce program, "Tif2PDF", with .TIF and .TIFF image files.
Create a unique file association in the ClickOnce Publish settings in Visual Studio 2017. I am not using .TIF at this time, we just want to create the appropriate registry entry under HKCU\Software\Classes\Tif2PDF which will get removed in the un-install process.
Properties->Publish->Options->File Associations.
extension=.tif2pdf
description=Tif2PDF
progID=Tif2PDF
icon=Resources\Tif2PDF.ico
In the Tif2PDF program startup process, we need to add registry settings when it is installed - only run when it is updated:
if ( System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed
&& ApplicationDeployment.CurrentDeployment.IsFirstRun )
Computer\HKEY_CURRENT_USER\Software\GuardTech\PDFTool\Capabilities\FileAssociations
.tif="Tif2PDF"
.tiff="Tif2PDF"
These two entries tell windows to use the HKCU\Software\Classes\Tif2PDF entry for TIF and TIFF file types.
Tell Windows this is a registered application. This value points to the key created in step 2.
Computer\HKEY_CURRENT_USER\Software\RegisteredApplications
Tif2PDF="Software\Tif2PDF\Capabilities"
At this point, you should see an option in Windows Explorer under "open with" called "ClickOnce Application Deployment Support Library". It will work at this point, but let's add a label and icon.
Create key and values below.
string iconSourcePath == Path.Combine(System.Windows.Forms.Application.StartupPath, #"Resources\Tif2PDF.ico");
Computer\HKEY_CURRENT_USER\Software\Classes\Tif2PDF\Application
ApplicationIcon=iconSourcePath
ApplicationName="Tif2PDF"
You program will need to handle command line arguments a little differently
//Get the normal command lines arguments in case the EXE is called directly
List<string> argList = new List<string>(Environment.GetCommandLineArgs());
argList.RemoveAt(0); //Remove the application.EXE entry
// this is how arguments are passed from windows explorer to clickonce installed apps when files are associated in explorer
if (AppDomain.CurrentDomain.SetupInformation.ActivationArguments?.ActivationData != null )
{
argList.AddRange( AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData);
}
We should try to cleanup these registry settings when we un-install the program by following thedracle's post Custom action on uninstall (clickonce) - in .NET
I just created a test application as Administrator (Windows Forms Application) using Visual Studio 2015 (< 5 minutes)
1) Under Properties/Publish/Options/File Associations added an entry:
Extension: .abcd
Description: test
ProgID: 2
Icon: An icon file
2) Under Properties/Publish I pressed Publish Now and ran Setup
3) Created a text file, renamed it to test.abcd
It is working as expected under Windows 10, so you could create a test application / verify that it's working and see what the differences are compared to your existing application.. 32/64 bit, framework, signing etc.

How to automatically run a third party Windows 10 Store App on Windows-Start-Up after log in

What I want to achieve is: To run a third party Windows 10 Store App, after a user logged in into his Windows 10.
I've discovered already how to start “Bing News” Store app at start up after user logged in 3 steps. Thanks to instantfundas.
Shortly explained the 3 steps:
1: Locate in Windows Registry - HKEY_CURRENT_USER\Software\Classes[app-name]
and check if it contains a “URL Protocol” in the format “URL:appname”.
for example: HKEY_CURRENT_USER\Software\Classes\bingnews
2: Create a Shortcut on the desktop to that app: %windir%\System32\cmd.exe /c start "" "App's URL Protocol name:"
for example: %windir%\System32\cmd.exe /c start "" "bingnews:"
3: Copy the Shortcut into the startup folder:
C:\Users{the user}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
Unfortunately, the third party apps are not shown in this Windows Registry...
*HKEY_CURRENT_USER\Software\Classes*
I want to start the third party app Nu.nl
(I know about Kiosk mode, but this is not the solution I want to end up.)
Anybody any ideas?
Open File Explorer
In the file address bar type shell:AppsFolder.
This will show all apps installed on your PC. Right click one of them and select "create Shortcut".
It will create a shortcut on the the desktop.
Finally copy the shortcut to the startup folder.

How to run something just before the files are installed?

I would like to know how to run something just before files are installed using NSIS.
I know about the .onInit function. That function runs when the installer is first starting. That is not what I want. I would like to run something after the user has clicked the install button but before the files actually get installed.
To be more specific. I have a windows service. When the installer is upgrading the windows service, I need it to stop the service - but only once the user is committed to the install - not when first starting the installer. Then it can upgrade the files and finally (re)start the service again. This seems like it should be a common requirement, but I haven't been able to find anything.
If it matters I'm using the MUI instead of classic.
All sections are executed on the instfiles page and they are executed in the same order as your source .nsi so you can just add another (hidden) section:
Section
# Do service stuff...
SectionEnd
Section "Required Files"
File xyz.abc
SectionEnd
Section
# Do service stuff...
SectionEnd
As Anders said - create invisible (hidden) section which is very first of all sections in your script and stop the service there.
When the other sections will be executed the service will be stopped.
Tip: maybe you should wait few seconds to let service manager time to stop the service.

Resources