Re: xcopy date problem




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


.



Relevant Pages

  • Re: xcopy date problem
    ... together into US format if the shortdate setting in the registry is ... Set wshShell = CreateObject ... Dim wshShell, dtmDate, strKey, strDateFormat, arrDate ...
    (microsoft.public.windows.server.scripting)
  • Re: xcopy date problem
    ... together into US format if the shortdate setting in the registry is ... Set wshShell = CreateObject ... 'Reads the shortdate format from the system registry ... Dim wshShell, dtmDate, strKey, strDateFormat, arrDate ...
    (microsoft.public.windows.server.scripting)
  • Read a Registry Value when path contains Curly Braces
    ... Can anyone help me with reading a value from the registry when the path ... contains curly braces? ... Dim WshShell ... Set WshShell = WScript.CreateObject ...
    (microsoft.public.scripting.vbscript)
  • Re: Reading vs. Checking Registry Key
    ... Dim WshShell, bKey, sKey, sValueBad, sValueGood ... Set WshShell = WScript.CreateObject ... createobject.regRead sKeyPath ...
    (microsoft.public.scripting.vbscript)
  • How to pass values to a vbscript function?
    ... I pulled the following client-side script from an ASP page. ... Dim WshShell, oExec, HostIP ... Set WshShell = CreateObject ... Set oExec = WshShell.Exec("C:\Program Files\Netop Remote ...
    (microsoft.public.dotnet.framework.aspnet)