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
- :
- Basic .ism how to start a service before installation and then restart it after
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
‎Oct 09, 2015
01:06 PM
Basic .ism how to start a service before installation and then restart it after
We need to stop a number of pre-exxisting Windows services before we install our product.
After the installation, these services need to be restarted.
Can this be done with a Basic .ism project?
After the installation, these services need to be restarted.
Can this be done with a Basic .ism project?
(6) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 13, 2015
09:21 AM
The answer is yes, you can. I do this within my basic MSI package.
If your 'basic' ism is a Basic MSI setup then you most likely only need to add the services to your setup and set them to stop when upgrading and start on install.
If you are like me, I needed to find something to handle a special situation where the services needed to stop sooner than the typically scheduled event. So I created a new InstallScript custom action to stop services.
With installscript you can simply call ServiceStopService. Here is code that I use within my basic MSI setup.
I setup my custom action for as:
Function Name: StopACServices
Return Processing: Synchronous (Ignores exit code)
In-Script Execution: Deferred Execution in System Context
...
Install Exec Sequence: After StopServices
I did not set any conditions since this should run always and if the services do not exist then the code handles not running. But you can customize the conditions to meet your requirements.
If your 'basic' ism is a Basic MSI setup then you most likely only need to add the services to your setup and set them to stop when upgrading and start on install.
If you are like me, I needed to find something to handle a special situation where the services needed to stop sooner than the typically scheduled event. So I created a new InstallScript custom action to stop services.
With installscript you can simply call ServiceStopService. Here is code that I use within my basic MSI setup.
export prototype StopACServices(HWND);
prototype Service_Stop(STRING);
prototype WriteMSILog(STRING);
...
function StopACServices(hMSI)
begin
ServiceInitParams ();
Service_Stop("AmazingChartsAdminService");
Service_Stop("AmazingChartsService");
end;
function Service_Stop(szServiceName)
STRING szMsg;
begin
if (ServiceExistsService(szServiceName)!=TRUE) then;
Sprintf ( szMsg , "Service_Stop: WARNING - Service *%s* does not exist. Ignoring.....", szServiceName );
WriteMSILog(szMsg);
return 0;
endif;
if (ServiceStopService(szServiceName)Sprintf ( szMsg , "Service_Stop: ERROR - Unable to stop service *%s*!", szServiceName );
WriteMSILog(szMsg);
return -1;
endif;
Sprintf ( szMsg , "Service_Stop: Service *%s* has been stopped successfully", szServiceName );
WriteMSILog(szMsg);
return 0;
end;
function WriteMSILog(szLogStr)
begin
SprintfMsiLog ( "%s" , szLogStr );
end;
I setup my custom action for as:
Function Name: StopACServices
Return Processing: Synchronous (Ignores exit code)
In-Script Execution: Deferred Execution in System Context
...
Install Exec Sequence: After StopServices
I did not set any conditions since this should run always and if the services do not exist then the code handles not running. But you can customize the conditions to meet your requirements.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 13, 2015
05:10 PM
Thanks for your answer.
But...
[LIST=1]
I need to stop and start services that I am not installing. They are third party services that use our software as a component
One cannot add InstallScript to a Basic MSI project. Or am I missing something?
But...
[LIST=1]
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 13, 2015
06:41 PM
My code would work for any service, just as long as you have the service name correct. Starting the service uses the same code.
We have been able to create InstallShield custom MSI actions for years, I am fairly certain that InstallShield 2012 uses it as well.
For that matter you can add the third party services to the services view of InstallShield. You just need to make sure that you have the name correct. You have to associate the settings with some component that includes files that get installed so that the action executes. Just make sure that you are not 'creating' the service in the settings.
We have been able to create InstallShield custom MSI actions for years, I am fairly certain that InstallShield 2012 uses it as well.
For that matter you can add the third party services to the services view of InstallShield. You just need to make sure that you have the name correct. You have to associate the settings with some component that includes files that get installed so that the action executes. Just make sure that you are not 'creating' the service in the settings.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 13, 2015
07:07 PM
Thanks again.
For adding third party services as components: have thought about it, but these services need to stopped first, before the installation of our product, then restarted. I could not figure out a way to do this.
For using custom actions: from what I see there is no way to add InstallScript here or any other sort of script.
BTW, we are using InstallShield 2010, not 2012, but there was no 2010 topic in this forum.
However, I believe 2010 has most of the same capabilities as 2012.
Best,
Marius Matioc
Senior Software Engineer
3VR
For adding third party services as components: have thought about it, but these services need to stopped first, before the installation of our product, then restarted. I could not figure out a way to do this.
For using custom actions: from what I see there is no way to add InstallScript here or any other sort of script.
BTW, we are using InstallShield 2010, not 2012, but there was no 2010 topic in this forum.
However, I believe 2010 has most of the same capabilities as 2012.
Best,
Marius Matioc
Senior Software Engineer
3VR
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 13, 2015
07:13 PM
I just did a quick search for 'InstallShield 2010 Help custom action' and found information.
http://helpnet.installshield.com/installshield16helplib/IHelpCustomActions.htm
I would avoid using the vbscript or jscript because anti-virus programs may have problems with the script executing.
You can sequence the custom action to run after Cost Finalize if you want and have it run immediately. This will take care of any problems with installing your files.
I think the link above plus my code sample should get you going on the InstallScript. Just change function names to match your business requirements, change the name of the service you are stopping/starting, and test, test, test 🙂
http://helpnet.installshield.com/installshield16helplib/IHelpCustomActions.htm
InstallShield supports calling a .dll function; launching an .exe file; running VBScript, JScript, or InstallScript code; and running another installation package as custom actions.
I would avoid using the vbscript or jscript because anti-virus programs may have problems with the script executing.
You can sequence the custom action to run after Cost Finalize if you want and have it run immediately. This will take care of any problems with installing your files.
I think the link above plus my code sample should get you going on the InstallScript. Just change function names to match your business requirements, change the name of the service you are stopping/starting, and test, test, test 🙂
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 16, 2015
06:59 PM
Thanks, this worked.
Cannot use InstallScript, but wrote a .exe to start and stop services.
Thank you for your suggestions.
Marius
Cannot use InstallScript, but wrote a .exe to start and stop services.
Thank you for your suggestions.
Marius
DLee65 wrote:
I just did a quick search for 'InstallShield 2010 Help custom action' and found information.
http://helpnet.installshield.com/installshield16helplib/IHelpCustomActions.htm
I would avoid using the vbscript or jscript because anti-virus programs may have problems with the script executing.
You can sequence the custom action to run after Cost Finalize if you want and have it run immediately. This will take care of any problems with installing your files.
I think the link above plus my code sample should get you going on the InstallScript. Just change function names to match your business requirements, change the name of the service you are stopping/starting, and test, test, test 🙂