Results 1 to 4 of 4

Thread: Pass variables from .bat file to vbscript

  1. #1
    New Member
    Join Date
    Jun 12
    Posts
    1

    Post Pass variables from .bat file to vbscript

    Hi all, need a help Passing variables from .bat file to vbscript. I have .bat file that launches test.vbs. I need to pass variable defined in the batch file inside the .vbs file.

    the batch file contains the code

    set /p var= please enter the value:
    cscript test.vbs "%var%"


    Where as test .vbs has the following codes

    Dim StrText
    MsgBox StrText


    In my requirement value assigned to variable 'var' in batch should assign to StrText variable in the test.vbs and then it should display in VB message box.

    Thanks..
    Mithun

  2. #2
    PowerPoster
    Join Date
    Feb 12
    Location
    West Virginia
    Posts
    4,957

    Re: Pass variables from .bat file to vbscript

    I'm not sure about VBScript but in VB the command line parameters come in in the variable Command$

    Try

    Code:
    Dim StrText
    StrText=Command$
    MsgBox StrText

  3. #3
    Super Moderator Joacim Andersson's Avatar
    Join Date
    Jan 99
    Location
    Sweden
    Posts
    13,448

    Re: Pass variables from .bat file to vbscript

    Moved to the VBScript Forum.
    Joacim Andersson
    Microsoft MVP, MCSD, MCSE, Sun Certified Java Programmer
    If anyone's answer has helped you, please show your appreciation by rating that answer.
    I'd rather run ScriptBrix...
    Joacim's view on stuff.

  4. #4
    Addicted Member
    Join Date
    Jul 09
    Posts
    208

    Re: Pass variables from .bat file to vbscript

    Quote Originally Posted by Mithunkurian View Post
    Hi all, need a help Passing variables from .bat file to vbscript.
    Get command line arguments using WScript.Arguments within the .vbs file.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •