Results 1 to 4 of 4

Thread: Pass variables from .bat file to vbscript

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2012
    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 2012
    Location
    West Virginia
    Posts
    14,206

    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
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Pass variables from .bat file to vbscript

    Moved to the VBScript Forum.

  4. #4
    Addicted Member
    Join Date
    Jul 2009
    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
  •  



Click Here to Expand Forum to Full Width