This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Allow not to start the service
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 07, 2015
10:08 AM
Allow not to start the service
Hi,
I have created a Suite installer project, this installer contains some .exe packages. This exe packages is Installscript MSI projects. The first exe package has a service . I am passing the property value from suite installer to the individual packages as shown
Using this property value , if the value is "true", the Service should not start. If the property value is not equal to "true" the service should start as usual. .I have set the condition in InstallScript MSI project in Sequence where we have this service,as shown below
Thanks in advance
I have created a Suite installer project, this installer contains some .exe packages. This exe packages is Installscript MSI projects. The first exe package has a service . I am passing the property value from suite installer to the individual packages as shown
Using this property value , if the value is "true", the Service should not start. If the property value is not equal to "true" the service should start as usual. .I have set the condition in InstallScript MSI project in Sequence where we have this service,as shown below
Thanks in advance
(5) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 09, 2015
08:03 AM
I there anyway that Suite installer can start/stop the services , and remove the start/stopping of services of its exe packages
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 09, 2015
09:10 AM
What happens if you change the case of the property to a PUBLIC PROPERTY. I suspect that the issue is that you are using a private property which cannot be passed in on a command line. Also look at your MSI log file because it lists what properties are passed in. But as I stated, you will find switching this to a public property will fix the issue.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 09, 2015
09:22 AM
Hi DLee65,
I tried to make it public and its working fine, but is there any way that Suite installer can start/stop the services , and remove the start/stopping of services of its exe packages
I tried to make it public and its working fine, but is there any way that Suite installer can start/stop the services , and remove the start/stopping of services of its exe packages
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 09, 2015
09:51 AM
Are you familiar with InstallScript? Add a custom InstallScript event to your suite. Below is what I used in 2013.
Note that I wrote mine for a basic MSI implementation but your implementation would be very similar.
If you are not comfortable with InstallScript, try another language that you like, C#, C++, vbscript, etc. I forget just how many other languages that they support for events in 2014, just look in the IS help for more information on what custom events you can use.
function Service_Start(szServiceName, szServiceArgs)
STRING szMsg;
begin
ServiceInitParams();
if (ServiceExistsService(szServiceName)!=TRUE) then
Sprintf ( szMsg , "Service_Start: WARNING - Service *%s* does not exist. Ignoring.....", szServiceName );
WriteMSILog(szMsg);
return 0;
endif;
if (ServiceStartService(szServiceName, szServiceArgs)Sprintf ( szMsg , "Service_Start: ERROR - Unable to start service *%s*!", szServiceName );
WriteMSILog(szMsg);
return -1;
endif;
Sprintf ( szMsg , "Service_Start: Service *%s* has been started successfully", szServiceName );
WriteMSILog(szMsg);
return 0;
end;
Note that I wrote mine for a basic MSI implementation but your implementation would be very similar.
If you are not comfortable with InstallScript, try another language that you like, C#, C++, vbscript, etc. I forget just how many other languages that they support for events in 2014, just look in the IS help for more information on what custom events you can use.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 09, 2015
10:13 AM
I just found this code in one of my custom actions. This is a CLR project so .NET would be a requirement for this.
[CODE]using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceProcess;
using System.IO;
namespace ModifyACServices
{
class Program
{
static void Main(string[] args)
{
string serviceCmd = args[0].ToUpper();
if (serviceCmd == "STOP")
{
StopService("AmazingChartsAdminService");
StopService("AmazingChartsService");
StopService("Amazing Charts Auth Service");
}
if (serviceCmd == "START")
{
StartService("AmazingChartsAdminService");
StartService("AmazingChartsService");
StartService("Amazing Charts Auth Service");
}
if (serviceCmd == "STOPSQL")
{
StopService("MSSQL$AMAZINGCHARTS");
}
if (serviceCmd == "STARTSQL")
{
StartService("MSSQL$AMAZINGCHARTS");
}
}
static void StopService(string pServiceName)
{
if (ServiceExists(pServiceName))
{
ServiceController service = new ServiceController(pServiceName);
if (service.Status.Equals(ServiceControllerStatus.Running))
{
try
{
service.Stop();
service.WaitForStatus(ServiceControllerStatus.Stopped);
service.Refresh();
}
catch (Exception e)
{
System.IO.File.WriteAllText(@"C:\Users\Public\InstallResults\ErrorReturn.txt", e.Message);
//If it fails we will not worry about it for the installer
}
}
}
}
static void StartService(string pServiceName)
{
if (ServiceExists(pServiceName))
{
ServiceController service = new ServiceController(pServiceName);
if (service.Status.Equals(ServiceControllerStatus.StopPending))
{
service.WaitForStatus(ServiceControllerStatus.Stopped);
service.Refresh();
}
if (service.Status.Equals(ServiceControllerStatus.Stopped))
{
try
{
service.Start();
service.WaitForStatus(ServiceControllerStatus.Running);
service.Refresh();
}
catch
{
//Sometimes the service will just not start for some reason due to installation errors, but do not want install to hang so inserting try catch
}
}
}
}
static bool ServiceExists(string pServiceName)
{
try
{
ServiceController[] scServices;
scServices = ServiceController.GetServices();
foreach (ServiceController scTemp in scServices)
{
if (scTemp.ServiceName == pServiceName)
{
return true;
}
}
}
catch (Exception e)
{
System.IO.File.WriteAllText(@"C:\Users\Public\InstallResults\ErrorReturn.txt", e.Message);
}
return false;
}
}
}
[/CODE]
To implement this you would build your C# custom action.
Add the EXE to your suite project as an event file.
Add the Argument STOP | START | etc
This implementation will allow the suite to stop services for uninstall, or patching, etc. And then after the update, install is complete, then start services.
[CODE]using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceProcess;
using System.IO;
namespace ModifyACServices
{
class Program
{
static void Main(string[] args)
{
string serviceCmd = args[0].ToUpper();
if (serviceCmd == "STOP")
{
StopService("AmazingChartsAdminService");
StopService("AmazingChartsService");
StopService("Amazing Charts Auth Service");
}
if (serviceCmd == "START")
{
StartService("AmazingChartsAdminService");
StartService("AmazingChartsService");
StartService("Amazing Charts Auth Service");
}
if (serviceCmd == "STOPSQL")
{
StopService("MSSQL$AMAZINGCHARTS");
}
if (serviceCmd == "STARTSQL")
{
StartService("MSSQL$AMAZINGCHARTS");
}
}
static void StopService(string pServiceName)
{
if (ServiceExists(pServiceName))
{
ServiceController service = new ServiceController(pServiceName);
if (service.Status.Equals(ServiceControllerStatus.Running))
{
try
{
service.Stop();
service.WaitForStatus(ServiceControllerStatus.Stopped);
service.Refresh();
}
catch (Exception e)
{
System.IO.File.WriteAllText(@"C:\Users\Public\InstallResults\ErrorReturn.txt", e.Message);
//If it fails we will not worry about it for the installer
}
}
}
}
static void StartService(string pServiceName)
{
if (ServiceExists(pServiceName))
{
ServiceController service = new ServiceController(pServiceName);
if (service.Status.Equals(ServiceControllerStatus.StopPending))
{
service.WaitForStatus(ServiceControllerStatus.Stopped);
service.Refresh();
}
if (service.Status.Equals(ServiceControllerStatus.Stopped))
{
try
{
service.Start();
service.WaitForStatus(ServiceControllerStatus.Running);
service.Refresh();
}
catch
{
//Sometimes the service will just not start for some reason due to installation errors, but do not want install to hang so inserting try catch
}
}
}
}
static bool ServiceExists(string pServiceName)
{
try
{
ServiceController[] scServices;
scServices = ServiceController.GetServices();
foreach (ServiceController scTemp in scServices)
{
if (scTemp.ServiceName == pServiceName)
{
return true;
}
}
}
catch (Exception e)
{
System.IO.File.WriteAllText(@"C:\Users\Public\InstallResults\ErrorReturn.txt", e.Message);
}
return false;
}
}
}
[/CODE]
To implement this you would build your C# custom action.
Add the EXE to your suite project as an event file.
Add the Argument STOP | START | etc
This implementation will allow the suite to stop services for uninstall, or patching, etc. And then after the update, install is complete, then start services.