Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
Hi,
This will work
Sub Run_BAT
Set obj = createobject("Wscript.Shell")
obj.Run "C:\test\test.bat"
End Sub
Bill
Ciao Bill,
is not working - i click run macro but nothing happen.
Any idea?
Thanks
Hi,
It works for me. See attached video
Bill
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
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?
Hi,
Just tested moving files and saw no issues.
Can you post your batch file?
Bill
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