Using command line from VBscript RRS feed

  • Question

  • So I'm trying to make function for a larger script to use the command line from a VBscript. I've worked out this script to attempt a basic command line function. Simply create a directory using a variable as the name. Except I can't seem to get the command line function to work with a variable, the script executes without error, but the directory is not made. 

    This works:

    Dim oshell 
    Set oShell = WScript.CreateObject ("WScript.Shell")  "cmd.exe /C mkdir c:\rtlassets" 
    Set oShell = Nothing 
    But as soon as I try to use a variable:
    Dim oshell 
    Set oShell = WScript.CreateObject ("WScript.Shell") 
    Dim ECHO 
    ECHO = "mkdir c:\rtlassets" "cmd.exe /C & ECHO &"  
    Set oShell = Nothing 
    It stops working. Any idea what is wrong with the syntax?

    Friday, May 9, 2014 9:57 PM


  • This line: "cmd.exe /C & ECHO &" "cmd.exe /C " & ECHO

    You cannot concatenate inside of quotes.

    Please read the VBScript tutorial to learn how to use VBScript syntax.

    Take Bill's advice, don't shell if at all possible. VBScript has nearly all commands.


    Friday, May 9, 2014 11:20 PM

All replies