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 6255021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:17:15+00:00 2026-05-24T14:17:15+00:00

I have a VBScript which list drives’ letters. I want to get the drives’

  • 0

I have a VBScript which list drives’ letters. I want to get the drives’ letters in a batch script and use it somewhere. For example think the output of VBScript is “C:\;D:\;F:\”, then I want to tell batch script to get this info remove C:\ from it and write D:\;F:\ in a text file. I want to do it only via batch script.

Here is a VBScript for a example:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colDisks = objWMIService.ExecQuery _
    ("Select * from Win32_LogicalDisk")

drives = ""
For Each objDisk in colDisks
  if drives > "" then
    drives = drives & chr(13)
  end if
  drives = drives & objDisk.DeviceID & "\"
Next

So How to do that?
Thanks,
Majid Pasha

  • 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-05-24T14:17:16+00:00Added an answer on May 24, 2026 at 2:17 pm

    Not sure if this works for you but you can execute the batch file from the vb script and pass the list of drives as a parameter.

    Example VB Sript:

    dim sh
    dim drives
    drives = "C:\;D:\;F:\"
    set sh = CreateObject("wscript.shell")
    sh.run "test.bat " & Chr(34) & drives & Chr(34)
    

    And you can test it by creating the file test.bat as:

    @echo off
    echo %1
    pause
    

    Otherwise, if it has to be the batch file that kicks it off, you can start the vb script with the Start command, but not sure how you return a value to the batch file so the only way I can think of right now would be for the vb script to write the drives to a file using the FileSystemObject (FSO) and then you can read that in the batch file using code similar to:

    start c:\test.vbs 
    set /p drives= < test.txt
    echo %drives%
    pause
    

    The documentation I link to for FSO includes a very simple sample for writing to a text file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a VBScript file which makes a GET request to a URL: Dim
I have a VBScript which detects local hard drive letters and it will store
I have to write something in vbscript that need to use a unique set.
I have a little problem with a simple vbScript. The script has to run
In my asp.net page I have a VBScript method which is doing some tasks
I have an old vbscript the runs the command, foo = CreateObject(x.y). I want
Context: Windows7, VBScript, ADODB and ADOX. I have written some VBScript code which creates
I'm running a simple batch file which is generated by a vbscript to delete
Today I have just thrown together this PowerShell script which takes a tab-delimited text
I have a type mismatch in my VBScript script. I know that the value

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.