Tuesday 29 May 2007

Dealing with the csup.txt whql mda requirement

Microsoft slipped a very quiet reference to a file, csup.txt, into the mda2007 requirements. In fact, I only found reference to this file in ONE powerpoint slide.

Either way, the actual requirements are simple enough, the file should contain the "born on" date for the machine, so microsoft can use this for reference to check which windows critical updates should be installed. And if you jump through the hoop nicely, you may receive you mda money.

The file needs to contain the current date. Something like echo %date% > c:\windows\csup.txt should be ok, isnt it? Nope, date must be in american format.

So, if you DONT live in the states, and your machines regional settings arent in U.S. format, you will have to conjure up some magic. I searche donline and found some routines for batch files, and modified them a bit, and this works for me

----begin batch-----

rem get the day, date and month in a format we can work with
@For /F "tokens=1,2,3 delims=/ " %%A in ('Date /t') do @(
Set Day=%%A
Set Month=%%B
Set Year=%%C
)

@echo DAY = %Day%
@echo Month = %Month%
@echo Year = %Year%
rem this line reformats it to american date format, as required by ms
rem and then creates c:\windows\csup.txt using this information for whql
echo %month%-%day%-%year% > c:\windows\csup.txt

-----end batch------

first sections uses the date command to put the date into variables, %day%, %month% and %year%, we can then echo these variables in any format into csup.txt, as shown by the last line. This works great for me for grabbing UK date and reformatting as U.S, please experiment for your area to get the variables correct.

No comments: