#1 28 Jul 2020 11:28

Tei_tsubaki
New Member
Registered: 28 Jul 2020
Posts: 4

I try to make a self-copy bat file.

I try to make a self-copy bat file.
but it only copy to the next folders.
here is the code.

@echo off
dir /b /a:d > tmp
for /f %%c in (tmp) do (copy /y "%0" "%%c")
for /f %%d in (tmp) do (start "%%d\%~n0.exe")
del /f /q tmp
exit

why it doesn't work in the below folder?
thanks smile

Offline

#2 28 Jul 2020 20:15

Simon Sheppard
Super Administrator
Registered: 27 Aug 2005
Posts: 1,074
Website

Re: I try to make a self-copy bat file.

In the third line you are starting a .exe file, but the batch script will have the extension .CMD

Offline

#3 29 Jul 2020 13:18

Tei_tsubaki
New Member
Registered: 28 Jul 2020
Posts: 4

Re: I try to make a self-copy bat file.

Yes. That's a wrong, but it still like the same

Offline

#4 29 Jul 2020 21:02

Simon Sheppard
Super Administrator
Registered: 27 Aug 2005
Posts: 1,074
Website

Re: I try to make a self-copy bat file.

Are the contents of tmp correct? is the copy working?
What do you see if you replace the START with ECHO?

Offline

Board footer

Powered by FluxBB