VBScript - Convert DOS Statement to VBScript

Posted on 2009-04-16
Last Modified: 2012-08-13
Greetings Experts,

I was wondering if you can help me convert a simple DOS statement into VBScript.    In the DOS statement, second file is created that is copied from the original and given a different name.  Once the two files are there, then they are copied to all user's desktop.


echo Creating second Passport session...

copy "c:\program files\passport\sessions\passport.zws" "c:\program files\passport\sessions\pp2.zws"

echo Copying shortcut to All Users desktop...

copy "C:\Program Files\Passport\sessions\*.zws" "C:\Documents and Settings\All Users\Desktop"

echo Opening 2nd session of Passport...

call "c:\program files\passport\session\pp2.zws"


Open in new window

Question by:aceklub97
    LVL 67

    Accepted Solution


    Dim objShell : Set objShell = CreateObject("Wscript.Shell")
    Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
    SourceFolder = "C:\Program Files\Passport\sessions\"
    SourceFile = "passport.zws"
    TargetFile = "C:\Program Files\Passport\sessions\pp2.zws"
    AllUsersDesktop = objShell.ExpandEnvironmentStrings ("%AllUsersProfile%\Desktop\")
    objFSO.CopyFile SourceFolder & SourceFile, TargetFile, True
    objFSO.CopyFile SourceFolder & "*.zws", AllUsersDesktop, True
    objShell.Run TargetFile

    Open in new window


    Author Closing Comment

    Thanks.  That works
    LVL 67

    Expert Comment

    Glad I could help - thanx for the grade! :^)

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
    I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now