none
Vbs script pass variables to batch file RRS feed

  • General discussion

  • Hello guys I want to pass two variables from vbscript to a batch file

    Vbscript

    Dim obj ,a,b
    a=1
    b=2
    set obj=CreateObject("wscript.shell")
    obj.run"C:\Users\Administrator\Desktop\script\echo.bat " &a?&b
    set obj=nothing

    Batch

    @echo off
    echo %1
    echo %2
    pause

    this way in the batch file in variable %1 are shown 12 connected 
    I want variable a to be shown in %1 and b in %2

    • Changed type Bill_Stewart Friday, March 15, 2019 3:08 PM
    • Moved by Bill_Stewart Friday, March 15, 2019 3:09 PM This is not VBScript training forum
    Wednesday, December 12, 2018 12:43 PM

All replies

  • We would advise not to use VBScript and batch and use PowerShell instead.


    -- Bill Stewart [Bill_Stewart]

    Wednesday, December 12, 2018 4:00 PM
  • You have to use correct syntax:

    cmd = "C:\Users\Administrator\Desktop\script\echo.bat " & a & b
    obj.run cmd

    Since you don't know VBScript you should not be trying to learn it. Use PowerShell.


    \_(ツ)_/

    Wednesday, December 12, 2018 7:58 PM