Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
qlikviewaf
Creator
Creator

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
Bill_Britt
Former Employee
Former Employee

Hi,

 

This will work

 

Sub Run_BAT

Set obj = createobject("Wscript.Shell")

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

End Sub

 

Bill

Bill - Principal Technical Support Engineer at Qlik
To help users find verified answers, please don't forget to use the "Accept as Solution" button on any posts that helped you resolve your problem or question.
qlikviewaf
Creator
Creator
Author

Ciao Bill,

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

Any idea?

Thanks

Bill_Britt
Former Employee
Former Employee

Hi,

It works for me. See attached video

 

Bill

Bill - Principal Technical Support Engineer at Qlik
To help users find verified answers, please don't forget to use the "Accept as Solution" button on any posts that helped you resolve your problem or question.
marcus_sommer

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
Creator
Creator
Author

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?

Bill_Britt
Former Employee
Former Employee

Hi,

Just tested moving files and saw no issues.

 

Can you post your batch file?

 

Bill

Bill - Principal Technical Support Engineer at Qlik
To help users find verified answers, please don't forget to use the "Accept as Solution" button on any posts that helped you resolve your problem or question.
qlikviewaf
Creator
Creator
Author

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