#How to run a bat script directly on cmd?

1 messages · Page 1 of 1 (latest)

nova haven
#
@echo off 
set "obj[0].source=C:\Users"
set "obj[0].dest=C:\Users\a"
set "obj[0].file=x.txt" 

set "obj[1].source=C:\Users"
set "obj[1].dest=C:\Users\b"
set "obj[1].file=y.txt" 

setlocal enableDelayedExpansion  
for /l %%i in (0,1,1) do (   
  robocopy "!obj[%%i].source!" "!obj[%%i].dest!" "!obj[%%i].file!" 
)
pause

how i could run this script directly on cmd without creating a .bat file?

indigo kiln
#

i don't think you can. why do you want to do that?

ebon pilot
#

you just use one % for each variable

#

if you want type the commands directly into cmd prompt

#

for lines that can be separated into new lines e.g. that "for" line, cmd will prompt "More?" when you press Enter

hybrid aspen
#

well this is the hardest way but

#

you dont need to do that

#

just make bat file

#

or do
echo command >> batfile.bat

#

replace command with each line of your commands