1

I have a batch file calling a vbscript. The VBscript return the current date time stamp. Can anyone please tell me how I can pass the datestamp value to the batch script . I am currently using Wscript.Echo which I dont want to use :

batch file :

wscript "C:\Script.vbs"  "C:\Log.txt"

vb script :

Set objArgs = Wscript.Arguments

Dim objFSO, objFile, LogFile

LogFile = WScript.Arguments(0)
Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.GetFile(LogFile)
Wscript.Echo objFile.DateLastModified

End If

Can any one tell me what I can do in the above script to pass the datelastmodified to the batch file ? I do not want to use Wscript.Echo ...

CodeNinja
  • 3,188
  • 19
  • 69
  • 112

1 Answers1

2
@for /f "tokens=* delims=" %%# in ('cscript /nologo "C:\Script.vbs"  "C:\Log.txt"') do @set "result=%%#"

Now you can use %result% variable.

Wscript will pop-up the result.From command line/bat is better to use cscript.

You can also embed the vbscript code into the batch

Community
  • 1
  • 1
npocmaka
  • 55,367
  • 18
  • 148
  • 187