Search code examples
windowsbatch-filecmd

How do I make a batch file run strings as commands?


I want to make a batch file to circumvent some cmd problems on my computer, but for that I need to be able to take String user input and run it as a command.

Basically what I want to be able to do is type in a command when the batch file asks for input, and have the computer run that command, similar to python's os module (class?)


Solution

  • Simply assign the string to a variable, then "execute" the variable as though it was a program

    eg

    set  myvar=ECHO Hello, World!
    %myvar%