Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

qlikviewaf
Contributor

run .bat using Macro

Hi All,

i'm trying to run a .bat file using a macro on my local pc.

How can i do this?

 

 

i used this script but nothing happen when i run the macro.


Sub Run_BAT

Set obj = createobject("Wscript.Shell")

obj.Run chr(34) & "C:\ExportMacro\BatchSubstitutetoPickup.bat" & chr(34), 0

Set obj = Nothing

End Sub

Labels (1)
7 Replies
Support
Support

Re: run .bat using Macro

Hi,

 

This will work

 

Sub Run_BAT

Set obj = createobject("Wscript.Shell")

obj.Run "C:\test\test.bat"

End Sub

 

Bill

Bill - Designated Support Engineer at Qlik
If a post helps to resolve your issue, please mark the appropriate replies as CORRECT.
qlikviewaf
Contributor

Re: run .bat using Macro

Ciao Bill,

is not working - i click run macro but nothing happen.

Any idea?

Thanks

Support
Support

Re: run .bat using Macro

Hi,

It works for me. See attached video

 

Bill

Bill - Designated Support Engineer at Qlik
If a post helps to resolve your issue, please mark the appropriate replies as CORRECT.
MVP & Luminary
MVP & Luminary

Re: run .bat using Macro

Are you sure that the macro and the bat didn't run? Including a msgbox with the file-path (and checking if it's really valid) and a pause statement in the bat would be useful to see what happens.

If the path is valid and the bat runs if it's executed manually check if the macro has system-access (about the mid in the left panel within the macro-editor), the user had not disabled the macro-execution and also that ActiveX is enabled on the machine.

- Marcus

qlikviewaf
Contributor

Re: run .bat using Macro

with button is running fine - the only thing is that i think the .bat is running without admin privileges indeed is not mooving file from one folder to another as expected.

 

Any idea?

Support
Support

Re: run .bat using Macro

Hi,

Just tested moving files and saw no issues.

 

Can you post your batch file?

 

Bill

Bill - Designated Support Engineer at Qlik
If a post helps to resolve your issue, please mark the appropriate replies as CORRECT.
qlikviewaf
Contributor

Re: run .bat using Macro

This is the bat

 

"C:\Users\asaperi\Downloads\fnr.exe" --cl --dir "c:\ExportMacro" --fileMask "*.txt" --excludeFileMask "*.dll, *.exe" --find """" --replace ""

@echo off

For /f "tokens=1,2,3,4,5 delims=/. " %%a in ('date/T') do set CDate=C:\ExportMacro\FattureOrdine%%a%%b%%c%%d.txt

setlocal enabledelayedexpansion

for /f "delims=" %%A in ('findstr /v "Company#Company Address#CAP#City#State#Country#VAT#ORD|Bill#ORD|BillDescription#Address#PostalCode#ORD|Bill|City#Blank#ORD|Bill|Country#TaxID#Bill#Description#Address1#CAP#City#Blank#Country#ORD|OrderNumber#ORD|OrderType#InvoiceDate#InvoiceDate#LineNumber#Remark#InvoiceNumber#InvoiceType#InvoiceDate#DueDate#CodiceUfficio#Blank#Tipo#Descrizione1#Descrizione2#Unit#Qty#UnitPrice#Taxable#Lot#DataScad Testo#VAT %#VAT#Taxable#Total VAT#Gross#Text#DDT#RDM#PEC#CodiceFiscale#RiferimentoAmministrazione#Natura#Tipo Pagamento#Final" "dataOrdine.txt"') do (
echo %%A >>%CDate%
)

:break