2

I have two Windows batch file. Both work when called from command prompt. Only one of the two run runs when double clicked. How come?

The following script (named CopyToStation9.bat) runs with a double-click:

@echo off

for /R "C:\Users\XXX\Documents\XXX" %%f in (*.csv) do copy "%%f" "\\192.168.0.10\c\X"

The following script (named CleanUp.bat) doesn't run with a double-click

@echo off
set delFileList=.\test\
for %%A in (%delFileList%) do (
    del /Q %%A
    echo file %%A  deleted
)
  • What are their names? – Ben N Sep 12 '16 at 22:36
  • Can you show the scripts? – DrMoishe Pippik Sep 12 '16 at 23:00
  • I've updated my question. – John Scarn Sep 13 '16 at 0:11
  • 1
    Add pause command as very last line of CleanUp.bat; I think it should run on a double-click… – JosefZ Sep 13 '16 at 1:06
  • 1
    John - How about making the set delFileList=.\test\<filename>.txt like so, etc. and make it point to an actual file for the filelist, and then perhaps using for /f "usebackq tokens=*" %%A in ("%delFileList%") do ( to ensure the file list path or filename or list values can handle spaces if it has any then this should then work more reliably than what you have I would think but I'd also change del /q %%A to be DEL /Q /F "%%~A"... Give that a shot and then report back your results and if that works, I'll then be glad to add this as an answer with further detail. – Pimp Juice IT Sep 13 '16 at 5:33
0

It looks like you are try to use a UNC path, try using pushdand popd.

https://stackoverflow.com/questions/9013941/how-to-run-batch-file-from-network-share-without-unc-path-are-not-supported-me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.