Page 1 of 1

passing variable from vbscript to batch file

Posted: 2021-Jul-25, 8:55 am
by MigrationUser
08 Dec 2011 21:02
rene


Hello. I am very new to vbscripting so please be patient with me.

I am trying to create a script that will check the version of an exe file and post the info to a txt file.

I start with a batch file

gwver.bat

Code: Select all

IPCONFIG |FIND "IP" > %temp%\TEMPIP.txt
FOR /F "tokens=2 delims=:" %%a in (%temp%\TEMPIP.txt) do set IP=%%a
del %temp%\TEMPIP.txt
set IP=%IP:~1%

for /F  %%* in (c:\ver.vbs) do set ver=%%*


echo %date% ,  %username% , %computername% , %IP% , GW version = , %ver% , winxp  >> c:\install.txt 

for the value of %ver% - which would be the file version of the exe file I call on ver.vbs

Code: Select all

strComputer = "."
Dim ver
Set vbShell = CreateObject("WScript.Shell")

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_Datafile Where Name = 'c:\\novell\\Groupwise\\grpwise.exe'")

For Each objFile in colFiles
    ver = objFile.Version

batchFile = c:\gwver.bat

vbShell.run batchFile & ver
The result in the txt file is
Thu 12/08/2011 , rene , WLLB-RENE , 205.189.26.163 , GW version = , , winxp

This is not working. How do I get that variable of ver from the vbs script to the batch file.

Thank you.

Rene

----------------------------

#2 09 Dec 2011 02:25
jaffamuffin
rene wrote:

Hello. I am very new to vbscripting so please be patient with me.

I am trying to create a script that will check the version of an exe file and post the info to a txt file.

I start with a batch file

gwver.bat

Code: Select all

    IPCONFIG |FIND "IP" > %temp%\TEMPIP.txt
    FOR /F "tokens=2 delims=:" %%a in (%temp%\TEMPIP.txt) do set IP=%%a
    del %temp%\TEMPIP.txt
    set IP=%IP:~1%

    for /F  %%* in (c:\ver.vbs) do set ver=%%*


    echo %date% ,  %username% , %computername% , %IP% , GW version = , %ver% , winxp  >> c:\install.txt 
Rene
I'm going to guess that you might want to change you for to read

Code: Select all

for /F  %%A in ('c:\ver.vbs') do set ver=%%A
Offline

original thread: https://ss64.org/oldforum/viewtopic.php?pid=5357