-2

i want to write some codes in cmd by batch file

{CreateObject("WScript.Shell").Run "%comspec% /c start /wait cmd.exe", 0, True }

this code opens cmd.exe ..

How can I edit this file with my own dos commands ? i dont want use it in txt file? my question is to write some command lines to cmd.exe not to txt file by "echo > & echo >> " i need to open cmd and start write instructions with a batch file and how i get some information from the cmd and place it in another script to use it later

  • possible duplicate of [How can I use a batch file to write to a text file?](http://stackoverflow.com/questions/19878136/how-can-i-use-a-batch-file-to-write-to-a-text-file) – Ken White May 03 '15 at 04:30
  • i dont want use it in txt file? my question is to write some command lines to cmd.exe i.e open cmd and start write instructions – Omar Ahmed May 03 '15 at 10:08
  • A ..cmd file is a .txt file with a different extension. All content in a .cmd file is plain text. So you write text to the .cmd file, just as you would write text to a .txt file. It's the same thing. – Ken White May 03 '15 at 13:24
  • { START cmd.exe /k "netsh wlan show profiles" } this is code if i use < such as text file it will be transfer the instruction to the txt file and i didn't want that ? – Omar Ahmed May 03 '15 at 17:19

2 Answers2

0

Wscript.shell.run uses shell32 to start files. You ask it to specifically start cmd.exe (%comspec%), which you ask that cmd.exe to ask shell32 (the start command) to start cmd.exe. Put the commands you want to run in a batch file (that's a text file).

Wscript.shell.run "c:\folder\batchfile.bat"

or if you prefer

Wscript.shell.run "cmd /c c:\folder\batchfile.bat"

or if only one command

Wscript.shell.run "cmd /k dir"

see

cmd /?
Trigger
  • 135
  • 3
0

I wanted to start cmd, then start write code which was saved in batch file

The code will be like this:

  {    START cmd.exe /k "netsh wlan show profiles"    } 

This code will open cmd and show you the saved profiles