Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Can anyone suggest a method whereby I can call a dos batch file with a parameter from a macro?
Wow, this is a tricky one. You can use a QlikView trigger to execute an external file. You may get a prompt if you're not overriding Launch security (Security tab of User Preferences).
I tried setting this up with a simple bat file, but QlikView does not seem to be passing the parameters correctly to that file. I also tried creating a Wscript Shell inside a macro, but QlikView doesn't seem to allow that. I created a separate vbs (VBScript) file and that allowed me to create the shell. With the vbs, I set it up to take a parameter and then call my batch file, passing that parameter. I tried launching the vbs directly from within QlikView but it didn't work.
I finally came up with a solution and it seems to be a lot of work:
1. Create your batch file as normal to take a parameter. For my testing, I used:
@echo %1
pause
Dim obj
Set obj = CreateObject("WScript.Shell")
Set oArgs = wscript.Arguments
obj.Run "c:\test.bat " & oArgs(0), , TRUE
That Trigger should pass the parameter, fun, to the vbs file, which will pass the parameter to the batch file and execute. Note: You can make the Filename an expression if your parameter needs to be dynamic. Here's a screenshot of the Trigger using a QlikView variable, vParam, for the parameter:
* Cscript info from Microsoft: http://technet.microsoft.com/en-us/library/bb490816.aspx
Thanks for that comprehensive answer. Much appreciated.
Will try it tomorrow and let you know how I got on.
Cheers
Question: will the call to the batch command in Qv script help?
It will be much easier to call batch with parameter in QV.