Option Explicit
dim wsh
set wsh = CreateObject("WScript.Shell")
dim fso
set fso = CreateObject("Scripting.FileSystemObject")
dim cfg
cfg = fso.BuildPath( _
fso.GetParentFolderName(WScript.ScriptFullName), _
"サーバとローカルのパス.txt" )
ExecuteGlobal fso.OpenTextFile(cfg).ReadAll
dim arg
for each arg in WScript.Arguments
dim s
s = Replace(arg, sroot, lroot)
call CreateFolder(fso.GetParentFolderName(s))
call CopyFile(arg, s)
wsh.Run "rundll32.exe url.dll , FileProtocolHandler " & s, vbNormalFocus, false
next
sub CreateFolder(path)
if not fso.FolderExists(path) then
call CreateFolder(fso.GetParentFolderName(path))
fso.CreateFolder path
end if
end sub
sub CopyFile(src, dst)
if fso.FileExists(dst) then
dim s
dim d
set s = fso.GetFile(src)
set d = fso.GetFile(dst)
select case Sgn(CDate(s.DateLastModified) - CDate(d.DateLastModified))
case -1
dim ret
ret = msgbox( _
"ローカルに新しいファイルが存在します。上書きしますか?" & vbCrLf & _
"" & vbCrLf & _
"↓サーバのファイル" & vbCrLf & _
s.DateLastModified & " " & s.Size & vbCrLf & _
d.DateLastModified & " " & d.Size & vbCrLf & _
"↑ローカルのファイル" & vbCrLf & _
"" , vbOKCancel, fso.GetFileName(dst))
if ret <> vbOK then
exit sub
end if
case 0
exit sub
case 1
end select
end if
call fso.CopyFile(src, dst)
end sub