Link to home
Create AccountLog in
Avatar of farmers1
farmers1Flag for United States of America

asked on

VBscript to take the date from within a DAT file and insert into a batch file!

I need a script to take the date from within a DAT file  say  "08/05/2008"
and use that date inside of the  batch file below,whatever date is in the dat file i need to use in the bat file!


  "c:\program files\ips\pro\pro.exe" OpenWindow[30062,TEST,08/05/2008] Authentication[P] AppUserID[admin] AppPassword[Abc] DBProfile[Prologue] AutoLogin[]
Avatar of asawatzki
asawatzki

Try this.  Change the DatFileName and BatFileName at the beginning.  Also this assumes that the test you posted is the whole batch file, and that the dat file only contains the date and no other text.
DatFileName = "C:\DatFileName.dat"
BatFileName = "C:\BatFileName.bat"
 
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
 
set oDate = fso.OpenTextFile(DatFileName)
sDate = oDate.ReadAll
oDate.close
set oDate = nothing
 
set oBatFile = fso.CreateTextFile(BatFileName, true)
oBatFile.writeline """c:\program files\ips\pro\pro.exe"" OpenWindow[30062,TEST," & sDate & "] Authentication[P] AppUserID[admin] AppPassword[Abc] DBProfile[Prologue] AutoLogin[]"
oBatFile.close
 
set oBatFile = nothing
set FSO = nothing

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of sirbounty
sirbounty
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
How about right in your batch file?

for /f %%a in ("FILENAME.DAT") do for /f "delims= " %%c in ("%%~ta") do "c:\program files\ips\pro\pro.exe" OpenWindow[30062,TEST,%%c] Authentication[P] AppUserID[admin] AppPassword[Abc] DBProfile[Prologue] AutoLogin[]
Avatar of farmers1

ASKER

Thanks this worked good,just what i needed!