Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
khag_hs
Contributor II
Contributor II

running DOS command in Macro


Hallo,

how can I run a DOS command  in a Macro?

for exampel:

copy *.txt test_new.txt /b /y

1 Solution

Accepted Solutions
m_woolf
Master II
Master II

Set oShell = WScript.CreateObject("WSCript.shell")
oShell
.run "copy *.txt test_new.txt /b /y"

View solution in original post

2 Replies
m_woolf
Master II
Master II

Set oShell = WScript.CreateObject("WSCript.shell")
oShell
.run "copy *.txt test_new.txt /b /y"

khag_hs
Contributor II
Contributor II
Author

Sorry, it doesn’t work.

 

But if I create a BAT-file which contains the command (copy *txt test_new.txt /b/y) and starts the BAT-file with the macro it works:

  

Set oShell =
CreateObject("WScript.Shell")

oShell.Run "make_a_copy.bat"

Content of the BAT-File “make_a_copy.bat”:

 

start/MIN

 

copy *.txt test_new.txt /b /y

 

exit

So, thank You for Your help, even if it’s not the direct solution.