
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Execute batch file with input defined by variable from script
Hi,
I am trying to launch a bat file from my load script using the execute command. Problems rise when I try to add some input defined by a variable.
I write in my qlikview load script:
execute "path to my -bat file" $(input_variable);
where input_variable contains three inputs separated by a space, e.g input variable = 1 2 3. For some reason the input defined by the variable is not passed on to the .bat file. If instead I write:
execute "path to my -bat file" 1 2 3;
my .bat file correctly takes the input 1 2 3. So it seems that I can't define it by a variable which is a problem as I would like to define it dynamically.
can anybody tell me what I am doing wrong?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you want to change the variable on the BAT file that needs to be executed, you need to write a Macro:
Execute Command:
EXECUTE cmd.exe /C C:\QVD\test.bat;
EXIT SCRIPT;
Macro:
SUB BatTest
SET d = ActiveDocument.Variables("vTest")
vTest = d.GetContent.STRING
Set obj = CreateObject("WScript.Shell")
obj.Run "C:\QVD\test.bat "&vTest, , TRUE
End Sub
---vTest is a variable with whatever number I need to populate, example, 1, 2, 3, etc...
My BAT File:
"c:\Program Files (x86)\qlikView\QV.exe" /VvReloadMacro=%1 /NoSecurity "C:\QVD\Test.qvw"
--Use the %1 where you want to have your variable be pushed to..
You can have any amount of variables, in your macro you can change the following:
SUB BatTest
SET d = ActiveDocument.Variables("vTest")
vTest = d.GetContent.STRING
Set obj = CreateObject("WScript.Shell")
obj.Run "C:\QVD\test.bat "&vTest&" 20", , TRUE
End Sub
And your BAT file:
"c:\Program Files (x86)\qlikView\QV.exe" /VvReloadMacro=%1 /VvReloadMacro2=%2 /NoSecurity "C:\QVD\Test.qvw"
Please ensure that the variables exist vReloadMacro & vReloadMacro2 in your document.
ETC...
Hope this helps!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It works when I set the variable (input_variable = 1 2 3) with a button clik front end and then initiate a reload with another button. This is the solution I'll go with.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your time and answer. Unfortunately I did not get to test if your solution works, as I prefer not to go the 'macro-way'.
