cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Rachelbaskaran
Level 5

Restart an application- Installshield 2009

Hey,

I'm building a installer where I have the Apache exe file. I wrote a couple of script to control few aspects of my installer.

Now I have one issue, I need to delete the httpd.conf( hope so the extension is .conf) which is in the apache and copy my http.conf to apache\\apache2\\conf and RESTART my apache monitor.

Hope I can do the delete part with the below script:

if(DeleteFile(DEL_DIR ^ DEL_FILE) < 0) then
MessageBox("Delete failed.", SEVERE);
else
MessageBox("File Deleted.", INFORMATION);
endif;


Is there a script that helps me to RESTART apache monitor once the httpd.conf is copied to apache?

Thanks
Rachel
Labels (1)
0 Kudos
(22) Replies
g_noyer
Level 4

Custom Action allows executing these actions, you can have a look on the documentation.
:confused: But be careful Apache is protected by the Apache License
0 Kudos
Rachelbaskaran
Level 5

Could you be more specific of which Custom Action am I to use?

My installer is of Installscript project type. At first, I self extract the apache exe and then go for delete httpd.conf and copy my httpd.conf and finally I want to RESTART my apache monitor.


Thanks much
Rachel
0 Kudos
g_noyer
Level 4

If you use InstallScript, thinks are differents but the standard is to use MSI.
In InstallScript you have a function LaunchAppAndWait
You can use it to run the appropriate command to restart apache.
Regards.
0 Kudos
Rachelbaskaran
Level 5

Oh No.

Alright, is there a script to run a batch file?

Will BatchFileLoad script do the work? or do we have any other script?

Thanks
Rachel
0 Kudos
Rachelbaskaran
Level 5

Since there's no specific script to RESTART apache, I wrote a batch file for apache.

net stop Apache2
net start Apache2.

This works fine in my cmd.exe but when I try it on my installer using installscript it doesn't. The script I used was BatchFileLoad, like the one below.

#define TARGET_BATCH "C:\\Program Files\\Company Name\\services.bat"

if(BatchFileLoad(TARGET_BATCH) < 0) then
MessageBox("Unable to load batch file.", SEVERE);

else
MessageBox("Batch file loaded successfully.", INFORMATION);


endif;

So I go by launching the apache.exe first and finally go for restarting the service through batch file. The issue is I couldn't see the Apache stop for a sec and again start like the cmd.exe. Just the message "Batch file loaded successfully" shows up.


What I need to do with the script, to see the apache monitor stop and then start again and then finish my installer.

Any help would be appreciated!

Thanks
Rachel
0 Kudos
gavin_landon
Level 6

So are you saying that it does actually stop and start the service, it's just you can't see it?
0 Kudos
Rachelbaskaran
Level 5

YES, I couldn't actually see it. I'm not very sure about the stop and start thing. I just get this messagebox displayed.
0 Kudos
gavin_landon
Level 6

Could you do this in VBS just to test and make sure you are seeing what you want to see? Inbetween the stop and start you can do a wscript.sleep(5000) to give you a 5 second wait.
0 Kudos
Rachelbaskaran
Level 5

Gavin,

Won't these two lines do the job of Stop and Start.

ServiceStopService(szServicename) and

ServiceStartService(szServicename,"")


I did see the change of what I should.
Am I on the right track?

Thanks
Rachel
0 Kudos
gavin_landon
Level 6

That is most defiantly the best way. I have a tendency to forget InstallShied most likely has API to do everything needing done.

This is why I keep asking them for an API list.. 😛
0 Kudos
RobertDickau
Flexera Alumni

If by API list you mean a list of built-in functions, the help section Reference > InstallShield Language Reference > Built-in Functions... is what you want. (When you mentioned API functions in a separate thread, I thought you meant pre-prototyped Windows API functions.)
0 Kudos
gavin_landon
Level 6

When I say API List, I'm meaning both.. Anything that can be called within IS. However, 😮 I hadn't see this list somehow. I must of looked past this several times. This will allow me to quit asking so many questions.
0 Kudos
Rachelbaskaran
Level 5

Hey,

I find this kinda weird. The below script works fine

ServiceStopService(szServiceName);
MessageBox("Application stopped.", INFORMATION);


ServiceStartService(szServiceName, "");
MessageBox("Application Restarted.", INFORMATION);


But not this one:
ServiceStopService(szServiceName);

ServiceStartService(szServiceName, "");
MessageBox("Application Restarted.", INFORMATION);


Does it mean I need to have the msgBox displayed? Coz I don't want display the msgbox for stop service but only for start service. When I run my 2nd script it stops but doesn't start.


Is the msgbox for stop so important? If YES, why?

Thanks
Rachel
0 Kudos
MichaelU
Level 12 Flexeran
Level 12 Flexeran

While sometimes there's something special about showing some UI, generally the important effect of a message box would be the delay. Try calling Delay instead of MessageBox.
0 Kudos
gavin_landon
Level 6

Sounds like a timing issue.. Try putting a Sleep(100); in between them. May just need a cycle, which can possibly be done with Sleep(0);
0 Kudos
Rachelbaskaran
Level 5

No didn't work.

I seriously couldn't understand :confused: , why it's not actually starting the application but just displays the msgbox.

It stops the application after a Delay of 2 seconds, it displays the msgbox "Application restarted" but it actually doesn't, my application remains in the stop state. The application I'm using here is Apache.


Thanks
Rachel
0 Kudos
gavin_landon
Level 6

Michael mentioned Delay.. I didn't realized Delay was in there. In some software there is a small difference between Sleep and Delay. So I would give that a try.

Delay is used just like Sleep. Delay(100);
0 Kudos
Rachelbaskaran
Level 5

What's the solution for this problem of mine?


I'll brief what my installer does. At first it extracts the exe's in the installer and then goes for copying few files from the installer to few target locations on the client system, finally after the file httpd.conf being copied to conf folder in Apache, I want the application to stop and again start.

Why the application doesn't start even though the msgbox displays that "Application started"? Am I missing any parameters?:(


Any help would be appreciated!

Thanks
Rachel
0 Kudos
gavin_landon
Level 6

I did a test with 2009 and 2010. I didn't use any Delay or Sleep and it worked fine. I'm unsure what the problem could be.

The API is synchronous so you shouldn't have to use any Sleeps or Delays in between them.
0 Kudos
Rachelbaskaran
Level 5

But I want this working for me.

Will the following parameters do any help,

dwcheckpoint. dwWaitHint,dwControlsAccepted.

or

SERVICE_IS_PARAMS.nStopServiceWaitCount(1000)

ServiceStopService(szServiceName);

SERVICE_IS_PARAMS.nStopServiceWaitCount(1000);

ServiceStartService(szServiceName,"");



Also I read that if I use the ServiceStartService built-in, it stops the running service and restarts. So it may be enough if I use ServiceStartService.

Thanks
Rachel
0 Kudos