We currently have a script that runs at startup written in .vbs that
works perfect, it uses something similar to the following. where if
the date is more than 12 months old it runs.

dim startdate
dim duration

startdate = #11/01/2004#
duration = 12

if dateadd("m",duration,startdate) < date() then

where after then it runs the script perfectly.. at the end of the
script we have it run another .vbs which has something similar to the
following

Const ForReading = 1
Const ForWriting = 2

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("backup.vbs", ForReading)

strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "startdate = #11/01/2004#", "startdate =
#11/01/2005#")

Set objFile = objFSO.OpenTextFile("backup.vbs", ForWriting)
objFile.WriteLine strNewText
objFile.Close

And again this works great!, but what I am wondering, to basically make
it seamless, is if there is a way to replace
strNewText = Replace(strText, "startdate = #11/01/2004#", "startdate =
#11/01/2005#")

with something like

strNewText = Replace(strText, "startdate = #11/01/2004#", "startdate =
current date variable")

so I wouldn't have to manually change the file once a year, and worry
about a silly mistake.

I have tried toying around with the %date% variable, but it seems to
write in mm-dd-yy, which I am not sure if the script can understand
with the previous mm/dd/yyyy format.. Does anyone have a suggestion as
to how I might be able to write the current date format in the 2nd part
as mm/dd/yyyy using a variable of sorts?


Matthew Rice
Rice Computer Solutions
www.ricecs.com

Re: replace text with date variable? by Matthew

Matthew
Sat Dec 31 08:51:08 CST 2005

actually echoing the %date% gave me Sat 12/31/2005 which is good if I
could kill the day


Re: replace text with date variable? by Matthew

Matthew
Sat Dec 31 09:03:04 CST 2005

hmm thought this would work

Set WshShell = WScript.CreateObject("WScript.Shell")
Set objEnv = WshShell.Environment("PROCESS")
objEnv("Year") = Year(now())
objEnv("Month") = Right("0" & Month(now()), 2)
objEnv("Day") = Right("0" & Day(now()), 2)

and then echoing my new variables %month% %date% etc

Will give it a another tweak


Re: replace text with date variable? by Matthew

Matthew
Sat Dec 31 09:30:03 CST 2005

%date:~4% is perfect! any suggestions on how to print thta in the
replace line?