wants to run batch file hiddenly - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

shilpa
Posts: 2
Joined: Sat Jul 23, 2011 6:10 am

wants to run batch file hiddenly

hi,
i want to run a batch file hiddenly using custom action thats why i create a vb script ,my batch file name is postgresql.bat
below code are wrriten in vb script file
const WindowStyleStealth = &H20000000
set WSO = createobject("WScript.Shell")
WSO.run "%comspec% /c APPDIR\pgsqlnew\postgresql.bat", WindowStyleStealth, True

attachment shows how i add custom action , when i run this setup i got the error like this "script required for this install to complete cannot be run" (attach a snapshot of error msg)
is i m doing the correct steps to attach custom action or is there any other way to run batch file hiddenly

plz help :? :?
Attachments
error.png
error.png (348.82 KiB) Viewed 3394 times
pagepnew.png
pagepnew.png (229.42 KiB) Viewed 3394 times
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: wants to run batch file hiddenly

Hi,

Please note that APPDIR is an installer property. So in your script you need to retrieve it before using it. Also, since your are using a Commit custom action, you will need to pass APPDIR value through CustomActionData property. There is a similar discussion about this here:
http://www.advancedinstaller.com/forums ... =2&t=12014

Basically, for your custom action you can set Action Data field to the path you want to execute:

Code: Select all

[APPDIR]pgsqlnew\postgresql.bat
After that you can save it in a variable inside your VBScript from CustomActionData property:

Code: Select all

Dim batPath
batPath = Session.Property("CustomActionData")
This variable can then be used to launch the file. Make sure that this variable is enclosed by escaped quotes like in the thread I mentioned above. This way it the path can be executed even if it contains spaces.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
shilpa
Posts: 2
Joined: Sat Jul 23, 2011 6:10 am

Re: wants to run batch file hiddenly

Hi Cosmin,
i modified my vb script file as you mention

const WindowStyleStealth = &H20000000
set WSO = createobject("WScript.Shell")
Dim batPath
batPath = Session.Property("CustomActionData")
WSO.run "%comspec% /c batPath", WindowStyleStealth, true

and add [APPDIR]pgsqlnew\postgresql.bat in Action data

this code resolve the error message issue but my batch file(postgresql.bat ) is not running
i m not aware with vb script syntax ,below is attachment of custom action settings
plz help
Attachments
new.png
new.png (226.37 KiB) Viewed 3386 times
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: wants to run batch file hiddenly

Hi,

I'm sorry, I posted a link to the wrong thread. This is the correct one:
http://www.advancedinstaller.com/forums ... =2&t=12025

It's about your exact scenario. You need to use batPath as a variable, for example:

Code: Select all

WSO.run "%comspec% /c install-service.bat """& batPath &"""", WindowStyleStealth, false
If you use it directly, it's just a text string.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”