|
I would like execute a .bat file in the installation, how can I do it en deployment project?
Thanks in advance
|
| wakewakeup Thursday, January 17, 2008 3:42 PM |
Hi,
You'd need to create an installer and then in your MSI projectspecify that installer as a custom action. Not that difficult to do the installer is a class that inherits from System.Configuration.Installer andthere are basically four methods you can overload Install, Uninstall, Commit, etc. In these methods you'd need to write a file containingyour commands and the invoke it with the Process class.
http://msdn2.microsoft.com/en-us/library/system.configuration.install.installer.aspx
If you do a search for custom installers you'll get more information.
You'll might need two batch files, one that does things when you install the application and one that undoes that when the application is uninstalled.
|
| Derek Smyth Thursday, January 17, 2008 3:52 PM |
n general you could create a custom action that runs an executable (cmd.exe) and pass it the pth to the .cmd file on the command line. But I don't think you can do it in Visual Studio this way because you would have to run the existing cmd.exe on the target machine which VS doesn't support (a limitation of Visual Studio, not of Windows Installer). So you may need to write a DLL for that purpose. Yu can call MsiGetProperty to get the value of TARGETDIR which is the destination folder of your application files.
|
| Stefan Krueger Friday, January 18, 2008 5:00 PM |
Hi,
You'd need to create an installer and then in your MSI projectspecify that installer as a custom action. Not that difficult to do the installer is a class that inherits from System.Configuration.Installer andthere are basically four methods you can overload Install, Uninstall, Commit, etc. In these methods you'd need to write a file containingyour commands and the invoke it with the Process class.
http://msdn2.microsoft.com/en-us/library/system.configuration.install.installer.aspx
If you do a search for custom installers you'll get more information.
You'll might need two batch files, one that does things when you install the application and one that undoes that when the application is uninstalled.
|
| Derek Smyth Thursday, January 17, 2008 3:52 PM |
Well!
Now, I can execute the .bat file in a fix path. How can I get the installation path of my application in order to find the .bat file and run it?
Thanks |
| wakewakeup Friday, January 18, 2008 11:40 AM |
Well!
Now, I can execute the .bat file in a fix path. How can I get the installation path of my application in order to find the .bat file and run it?
Thanks
|
| wakewakeup Friday, January 18, 2008 11:40 AM |
Hi,
One option would be to write the batch file during installation to a temporary location and run it from there. The other option is to not allow the user to change the install path (which is ok if your running this in a company rather than inthe public domain). Another option is to have the application run the batch file when it is first executed, delay the running of the batch file (depends what it does) and not have it in the install package. |
| Derek Smyth Friday, January 18, 2008 11:57 AM |
n general you could create a custom action that runs an executable (cmd.exe) and pass it the pth to the .cmd file on the command line. But I don't think you can do it in Visual Studio this way because you would have to run the existing cmd.exe on the target machine which VS doesn't support (a limitation of Visual Studio, not of Windows Installer). So you may need to write a DLL for that purpose. Yu can call MsiGetProperty to get the value of TARGETDIR which is the destination folder of your application files.
|
| Stefan Krueger Friday, January 18, 2008 5:00 PM |
Thanks to all, Finally the most easy solution was to run it when It is first executed.
|
| wakewakeup Tuesday, January 22, 2008 10:08 AM |
If you are using Wix, I think it is easy to do it. Add this file to one of the component. Then define the custom action to call that batch file. I have the experience to create my own custom action exe and launch it.
|
| Jenniflower Zhao Tuesday, January 22, 2008 10:23 AM |
Personally, I don't like the installer class. Or it is because I am not good at it. I don't know how to define rollback for install, uninstall and removeexistingproducts respectively.
|
| Jenniflower Zhao Tuesday, January 22, 2008 10:31 AM |
Hi, Can u post how did u executed the .bat file in the installation? |
| Nagendra032 Sunday, July 19, 2009 12:44 AM |