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

  • Home
  • SEARCH
  • 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 8374367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:54:25+00:00 2026-06-09T14:54:25+00:00

I trying to go from cmd script to vbscript in MS window xp cmd

  • 0

I trying to go from cmd script to vbscript in MS window xp

cmd code yes works

set home_=%~dp0

set part001=part001
set part002=part002
set part003=part003
set part004=part004

::get the dir in part001
for /f "delims=" %%A in ('dir /s/b/o:n/a:d ^"%home%%part001%\^"') do (
echo show have dir path
echo %%A
pause
)
echo to the end
pause
goto :eof

to vbscript

the part I do not know to convert are those that are foramtted as cmd{cmd codeing}

dim strHome as strimg =cmd{[%~dp0]}

dim strPart001 as sting = part001
dim strPart002 as sting = part002
dim strPart003 as sting = part003
dim strPart004 as sting = part004

'get the dir in part001
Dim objFSo, objFile
Set objFSo = CreateObject("Scripting.FileSystemObject")

set objDirPart001list = objFS.getfolder(strHome&strPart001\)
set subDirPart001list = objDirPart001list.SubFolders
for each  subDirPart001Name in subDirPart001list
    WScript.Echo show dir path
    WScript.Echo part
    cmd{pause}
    )
cmd{pause}

what are the corresponding vbscript commands for:

  • %~dp0
  • pause
  • 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-09T14:54:27+00:00Added an answer on June 9, 2026 at 2:54 pm

    The %~dp0 is a so-called magic command but more technically this method is known as variable substition. The %n variables are used to reference the command line parameters of the script. The most common, %0 will return the full path to the script that is executing. The d and p are special modifiers that will return the drive and path portion of that path, respectively. There is also n which returns the filename portion as well as others. These modifiers can be combined as necessary. So the %~dp0 command will return the full drive and path to the directory where the executing script resides. To do this in VBScript, you can use any of the following that rely on the WScript Object’s ScriptFullName method:

    Set objShell = CreateObject("WScript.Shell")
    Set objFso = CreateObject("Scripting.FileSystemObject")
    strPath = objFso.GetParentFolderName(WScript.ScriptFullName)
    

    Or

    strPath = Left(WScript.ScriptFullName, Len(WScript.ScriptFullName) - Len(WScript.ScriptName))
    

    Or my favorite:

    Replace(WScript.ScriptFullName, WScript.ScriptName, "")
    

    The pause command is used to stop the command interpreter and prompt the user to press any key to continue. This is typically done so that the user has time to read the information in the command window before it closes. Here’s a subroutine to do that in CScript. (For WScript, you would just use a simple MessageBox.)

    Sub Pause
        WScript.StdOut.Write "Press any key to continue . . . "
        WScript.StdIn.Read(1)
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to test some code. The main script requires imports from a
I am trying to open Weka from cmd line, using C#. This is the
Trying to abort from a before_request handler (in Flask) with that code gives the
I'm trying to migrate from C2DM to GCM, and it mostly works just fine.
I am trying to log the output from cmd tree command using ant with
I'm trying to execute iisvdir from an ant script to clean and create a
I'm trying to write a VBScript (.vbs) script that uses the WScript.Shell Run() method,
I'm trying to port a script from BASH to ASH (Almquist SHell) and am
I am trying to run a command from a bash script. The command itself
I'm starting a shell script (.cmd) from my .NET application. I'd like the console

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.