Re: xcopy date problem
- From: "James Garringer" <jgarringer@xxxxxxxxx>
- Date: 13 Sep 2006 07:34:55 -0700
You're welcome SW, I'm glad you can use it!
James Garringer
SW wrote:
James,
That's a very useful bit of code.
Thanks,
SW
"James Garringer" <jgarringer@xxxxxxxxx> wrote in message
news:1157911507.862621.234790@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi SW,
Here is a solution that may work for you. The script below
includes a function to read the current shortdate setting from the
registry. Then the system date is split into an array and pieced back
together into US format if the shortdate setting in the registry is
d/m/yyyy format....or is left alone if that setting is already
m/d/yyyy.
--------------------------
Dim wshShell
Set wshShell = CreateObject("Wscript.Shell")
wshShell.Run "xcopy *.* S:\folder /d:" & UKToUSDateForXCopy & " /e"
Function UKToUSDateForXCopy
'Reads the shortdate format from the system registry
'If already set to m/d/yyyy it is returned as the current
'US date. If set to d/m/yyyy it is converted into the
'US equivalent.
Dim wshShell, dtmDate, strKey, strDateFormat, arrDate
Set wshShell = CreateObject("Wscript.Shell")
strKey = "HKEY_CURRENT_USER\Control Panel\International\sShortDate"
strDateFormat = wshShell.RegRead (strKey)
arrDate = Split(Date,"/")
Select Case LCase(strDateFormat)
Case "m/d/yyyy"
UKToUSDateForXCopy = Date
Case "d/m/yyyy"
For i = 0 To UBound(arrDate)
UKToUSDateForXCopy = arrDate(1) & "/" _
& arrDate(0) & "/" & arrDate(2)
Next
End Select
End Function
--------------------------
Hope this helps,
James Garringer
SW wrote:
Hi,
Apologies if this is the wrong group, my problem is with a batch file,
not
strictly a server script.
I want to make a batch file on a Windows Server 2003 machine with the
following command:
xcopy *.* s:\folder /d:%DATE% /e
The problem is, the %DATE% variable doesn't work, because it returns the
date in UK format (DD/MM/YYYY) (I'm in the UK!), and the xcopy command
only
seems to like the date being in US format (MM/DD/YYYY).
Is there anyone can help?
Thanks in advance,
SW
.
- References:
- xcopy date problem
- From: SW
- Re: xcopy date problem
- From: James Garringer
- Re: xcopy date problem
- From: SW
- xcopy date problem
- Prev by Date: VBS: ADSI script doesn't work
- Next by Date: Re: Start and Stop a program
- Previous by thread: Re: xcopy date problem
- Next by thread: get ad user list
- Index(es):
Relevant Pages
|