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
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)
Please log in to answer
Posted by:
an33th
13 years ago
Posted by:
anonymous_9363
13 years ago
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.
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
13 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.