Abdelmajeed
Abdelmajeed

Reputation: 11

Passing Variable from Batch to vbs file

simply i want to use a batch file to read from text file and then pass the string to vbscript the vbs will display the text information.

i am able to read but unable to display

here is the batch code

Option Explicit 
Dim InputFile 
Dim FSO, oFile 
Dim strData 
InputFile = "C:\Users\admin\Desktop\output.txt" 
Set FSO = CreateObject("Scripting.FileSystemObject") 
Set oFile = FSO.OpenTextFile(InputFile) 
strData = oFile.ReadAll 

SET AvayaContent1=strData
START c:\windows\system32\wscript.exe c:\users\admin\Desktop\ScreenPopMessage.vbs

and here is the vbs code

Set wshShell = CreateObject( "WScript.Shell" )

MemID = wshShell.ExpandEnvironmentStrings( "%AvayaContent1%" )

WScript.Echo MemID

any idea is welcomed :)

Upvotes: 0

Views: 1785

Answers (2)

Abdelmajeed
Abdelmajeed

Reputation: 11

Solved!! Thank you Sorceri for helping

in order to use the data passed from Avaya IP agent application in addition to the text file data, i have modified the codes as following

the BAT file

SET AvayaContent1=%1
START c:\windows\system32\wscript.exe c:\users\admin\Desktop\ScreenPopMessage.vbs

and the vbs script file

Set wshShell = CreateObject( "WScript.Shell" )

UserID = wshShell.ExpandEnvironmentStrings( "%AvayaContent1%" )

Dim InputFile 
Dim FSO, oFile 
Dim strData 
InputFile = "c:\users\admin\Desktop\output.txt" 
Set FSO = CreateObject("Scripting.FileSystemObject") 
Set oFile = FSO.OpenTextFile(InputFile) 
strData = oFile.ReadAll 
oFile.Close

set FSO = nothing
set oFile = nothing

intButton = WshShell.Popup ("User ID: " + UserID + "  Agent ID: " + strData, 0, " Avaya Caller Screen Pop ", 0 + 64)

Upvotes: 0

Sorceri
Sorceri

Reputation: 8033

This can all go into one vbs script.

'bat file

call "c:\users\admin\Desktop\ScreenPopMessage.vbs"

'vbs file

Option Explicit 
Dim InputFile 
Dim FSO, oFile 
Dim strData 
InputFile = "C:\Users\admin\Desktop\output.txt" 
Set FSO = CreateObject("Scripting.FileSystemObject") 
Set oFile = FSO.OpenTextFile(InputFile) 
strData = oFile.ReadAll 
oFile.Close


WScript.Echo strData


set FSO = nothing
set oFile = nothing

Upvotes: 1

Related Questions