/build/static/layout/Breadcrumb_cap_w.png

Custom action to call a batch file

Hi,
I am trying to run a batch file automatically after the installation of my project setup. i had create a setup project and add my batch file at application, commands written in batch file is as follows
@ECHO ON
@SET PATH="%CD%\bin";%PATH%
@SET PGDATA=%CD%\data
@SET PGDATABASE=postgres
@SET PGUSER=postgres
@SET PGPORT=5432
@sET PGLOCALEDIR=%CD%\share\locale
%CD%\bin\initdb -D %CD%/data
%CD%\bin\pg_ctl -D %CD%/data -l logfile start

added a custom action install and commit and write a code in installer class like this
Public Overrides Sub Install(ByVal stateSaver As IDictionary)
MyBase.Install(stateSaver)
Dim dir As String = MyBase.Context.Parameters("dir").ToString()
'Change this string to the bat file name
Dim batFileName As String = "postgresql.bat"
'Execute the bat file.
System.Diagnostics.Process.Start(dir & batFileName)
End Sub

Public Overrides Sub Commit(ByVal savedState As IDictionary)
MyBase.Commit(savedState)
Dim dir As String = MyBase.Context.Parameters("dir").ToString()
'Change this string to the bat file name
Dim batFileName As String = "postgresql.bat"
System.Diagnostics.Process.Start(dir & batFileName)
End Sub

but problem is that during the installation process it only launches the black screen ( command screen ) for a while but doesn't execute the command written in batch file.

When this batch file is executed by double click, it works pefectly but from a setup custom action it is not working.

is i m doing the correct process or is ther some other way to run this batch file from custom action
Please help...its urgent

0 Comments   [ + ] Show comments

Answers (4)

Posted by: an33th 12 years ago
Orange Belt
0
@SET PATH="%CD%\bin";%PATH%


What does the Environmental variable %CD% point to?
Posted by: shilpa24 12 years ago
Yellow Belt
0
hi aneeth,
The %CD% returns the folder path of current directory
Posted by: anonymous_9363 12 years ago
Red Belt
0
Er...you have created one hell of a complex "solution" for what is a very simple operation.

Just call CMD.EXE in your CA and pass it the name of the batch file as the argument. Remember you should ALWAYS specify full paths in CAs (obviously you can use properties for that).

Also, this forum is designed for problems connected with errors returned by Windows Installer (see the link 'MSI Errors' fr examples). You ought to have posted in the 'Scripting' forum. A moderator may move the thread.
Posted by: kanthsri87 12 years ago
Senior Yellow Belt
0
Jus create a custom action and place it after InstallFinalize in Immediate execute custom action with the NOT INSTALLED condition will solve your problem.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ