Friends, I'm writing a script which does a lot of stuff - install my application + other opensource software, set up s/w as service, execute batch files to do some stuff etc.
How do I execute this batch file after installation is complete, using Inno? It can be immediately after user finishes the install process or run once at system restart. Is it achievable through Inno script?
Or is there a way for my environment variables to take effect so that my batch file can run ?
I know there are installation programs that do part of installation after user has finished install process and system has restarted. Does Inno support that kind of functionality?
I'm not sure if CurStepChanged
+ ssPostInstall
method will work here as it will essentially be the same environment that Inno began with and my variables are not yet in effect.
If this cannot be achieved through Inno script, I will place the batch file at system startup - in that case I will need to check if the service is already installed/running and take appropriate action. But that would be crude.
Please help with any pointers/suggestions.
Thanks.
To schedule a batch file to be run on the next Windows start/logon, add a value to HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce
key:
[Registry]
Root: HKCU; Subkey: "Software\Microsoft\Windows\CurrentVersion\RunOnce"; \
ValueType: string; ValueName: "MyProg"; ValueData: """{app}\MyBatch.bat"""
A value in RunOnce
key is automatically deleted by Windows, when the program/batch is run.
Read about Run and RunOnce Registry Keys :
By default, the value of a RunOnce key is deleted before the command line is run. You can prefix a RunOnce value name with an exclamation point (!) to defer deletion of the value until after the command runs. Without the exclamation point prefix, if the RunOnce operation fails the associated program will not be asked to run the next time you start the computer.
Execution order:
If more than one program is registered under any particular key, the order in which those programs run is indeterminate.
Actually the programs run in parallel. Some of the entries can easily be an application that runs until the end of the Windows session. So Windows cannot wait for the program to finish before starting another.
If you need to run the batch files in a particular order, create just one entry pointing to a master batch file that runs the other batch files in the order you need.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.