Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7767655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:43:50+00:00 2026-06-01T15:43:50+00:00

I’m using CScript to run a VBScript file, and I need to pass a

  • 0

I’m using CScript to run a VBScript file, and I need to pass a command line to the script where the parameter includes both spaces and quotes. The entire command needs to be passed as one parameter to the script. For example:

C:\> CScript myscript.vbs //Nologo "cmd.exe /c "dir && del /q *.txt""

Note the specific command line above is just an example, but it does touch on what I’m trying to do (i.e. pass a command line that involves running cmd.exe). I’m trying to solve for the general case, however.

The issue is that CScript appears to be getting confused trying to determine where quotes are opening and closing. At least sometimes.

The following script may help explain. It just outputs the passed in arguments as it sees them:

Dim count
For count = 0 To WScript.Arguments.Count-1
    WScript.Echo CStr(count) & " = " & WScript.Arguments.Item(count)
Next

Often times, it works as expected:

C:\> cscript myscript.vbs //Nologo "1 2 3"
0 = 1 2 3

But when there are quotes inside the quoted parameter, things change:

C:\> cscript myscript.vbs //Nologo "1 "2 3""
0 = 1 2
1 = 3

I understand there is an introduced ambiguity about whether each quote is opening or closing a parameter in the above example, so next I tried escaping the internal quotes so the command processor will treat them as literal strings:

C:\> cscript myscript.vbs //Nologo "1 ^"2 3^""
0 = 1 ^2
1 = 3

Hmmm, looks like that only works when the shell does your globbing and such for you. I doubt cscript understands ^ as an escape character like cmd.exe does.

Using single quotes inside the double-quoted command (e.g. “cmd.exe /c ‘dir && cd \'”) properly parses as a single parameter but won’t work because for the case of invoking cmd.exe with the /c parameter, single quotes are not sufficient. For example:

C:\> cmd /c 'dir && cd \'
''dir' is not recognized as an internal or external command,
operable program or batch file.

I suppose I could just iterate over all the arguments in the script and join them back to one long string, but I’ll lose the internal quotes and context that they provide doing that. Or maybe I do use single quotes inside the the double-quoted param and map those back to double quotes inside the script. But what if the intention was single quotes for some future case I’m not considering? Since I’m attempting to solve for the general case, I can’t make that determination.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T15:43:51+00:00Added an answer on June 1, 2026 at 3:43 pm

    It appears like you are trying to delineate values in your parameters. I suggest using something besides quotes and adding back the quotes. For example using tildes:

    Dim count
    For count = 0 To WScript.Arguments.Count-1
        WScript.Echo CStr(count) & " = " & replace(WScript.Arguments.Item(count),"~",chr(34))
    Next
    

    Passing:

    cscript myscript.vbs //Nologo "1 ~2 3~"
    0 = 1 "2 3"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my XML file chapters tag has more chapter tag.i need to display chapters
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.