You are not logged in.

#1 08 Dec 2011 21:02

rene
Member
Registered: 08 Dec 2011
Posts: 1

passing variable from vbscript to batch file

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

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

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

Offline

#2 09 Dec 2011 02:25

jaffamuffin
Member
Registered: 21 Mar 2009
Posts: 19

Re: passing variable from vbscript to batch file

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

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

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

Offline

Board footer

Powered by