Variable in a Batch script - 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!

Matt
Posts: 109
Joined: Tue Oct 19, 2010 4:54 pm

Variable in a Batch script

Hi,

I am trying to run a batch script that Copys the .config files in a destination defined by to another location. I have added a batch script to Advanced installer and got it to work ok. However I am having problems trying to get the Variable to work. The script is below:

Code: Select all

Cd "%1"
MKDir Entrader_Config_Backup
Copy *.Config Entrader_Config_Backup
I have also attached a screen shot of my test project.
Attachments
Screen shot of the custom action
Screen shot of the custom action
Capture001.PNG (67.09 KiB) Viewed 7028 times
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Variable in a Batch script

Hi Matt,

I'm afraid your approach of launching the bat has some incorrect settings. In the following article it is presented how you can correctly launch the BAT.

After you add the reference of the BAT file in the "Command Line" field, as described in the above article, you can add and its parameter, in the same field.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Matt
Posts: 109
Joined: Tue Oct 19, 2010 4:54 pm

Re: Variable in a Batch script

Hi,

So If I add [#Test.bat] into the command line before I input any variables this will solve the issue?

Matt
Matt
Posts: 109
Joined: Tue Oct 19, 2010 4:54 pm

Re: Variable in a Batch script

Hi,

I changed my variable to [TXTLOC] and the batch script completed properly. However when I changed the command line in advanced installer to:

[#Entrader_Config_Backup.bat] [TXTLOC] the problem occured again.

Is this what you meant and if so where have I gone wrong?

Matt
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Variable in a Batch script

Hi Matt,

Please note that you first need to add the custom action Launch File or Open URL. The only editing that you must do is in "Command Line" field, no other one.

The reference of the BAT file is added using the "Edit" button, not writing it manually.

The value from the field should be something like this ([#Entrader_Config_Backup.bat] [TXTLOC]), but you must use the "Edit" button, so that Advanced Installer
generates the correct identifier for the file.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Matt
Posts: 109
Joined: Tue Oct 19, 2010 4:54 pm

Re: Variable in a Batch script

Hi,

I have made the changes but the script still fails. The batch script is copied into the folder and files section and that is where I am trying to run it from and not as an attached script does this make any differnce?

I have attached a screen shot of my custom action setup

Matt
Attachments
Capture002.PNG
Capture002.PNG (75.19 KiB) Viewed 7014 times
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Variable in a Batch script

Hi,

Please try using this command line:

Code: Select all

"[#Entrader_Config_Backup.bat]" [TXTLOC]
Assuming "Entrader_Config_Backup.bat" is your BAT file ID, the [#Entrader_Config_Backup.bat] reference will be resolved to the full path of your BAT file. It is enclosed in quotes because that path may contain spaces.

Did you use the Edit button next to "Command line" field like Bogdan recommended? When using the Edit button you can select your BAT file. A valid file reference is added automatically and it's enclosed in quotes by default.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Matt
Posts: 109
Joined: Tue Oct 19, 2010 4:54 pm

Re: Variable in a Batch script

Hi,

This has worked now thank you for your help.

Matt

Return to “Common Problems”