Skip to content

Instantly share code, notes, and snippets.

@valda
Created September 9, 2009 05:25
Show Gist options
  • Save valda/183495 to your computer and use it in GitHub Desktop.
Save valda/183495 to your computer and use it in GitHub Desktop.
RamDisk に Desktop を置いてる場合の logout スクリプ㌧
'' logoff_robocopy_desktop.vbs
'' RamDisk に Desktop を置いてる場合の logout スクリプ㌧
'' 要 robocopy
Set objShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
desktop = "Z:\DESKTOP"
desktop_bak = "C:\Documents and Settings\valda\DESKTOP_BACKUP"
commdesktop = "Z:\COMMONDESKTOP"
commdesktop_bak = "C:\Documents and Settings\All Users\DESKTOP_BACKUP"
Call Backup(desktop, desktop_bak)
Call Backup(commdesktop, commdesktop_bak)
Sub Backup(srcdir, destdir)
If Not fso.FolderExists(destdir) Then
fso.CreateFolder destdir
End If
If fso.FolderExists(srcdir) Then
Call objShell.Run("robocopy """ & srcdir & """ """ & destdir &""" /MIR /B /R:2 /W:10", 0, True)
End If
End Sub
'' logon_robocopy_desktop.vbs
'' RamDisk に Desktop を置いてる場合の logon スクリプ㌧
'' 要 robocopy
'' 60分に1回同期 (/MOT:?? の数字で調整)
Set objShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
desktop = "Z:\DESKTOP"
desktop_bak = "C:\Documents and Settings\valda\DESKTOP_BACKUP"
commdesktop = "Z:\COMMONDESKTOP"
commdesktop_bak = "C:\Documents and Settings\All Users\DESKTOP_BACKUP"
Call Restore(desktop_bak, desktop)
Call Restore(commdesktop_bak, commdesktop)
Call RunPeriodicBackup(desktop, desktop_bak)
Call RunPeriodicBackup(commdesktop, commdesktop_bak)
Sub Restore(srcdir, destdir)
If Not fso.FolderExists(destdir) Then
fso.CreateFolder destdir
End If
If fso.FolderExists(srcdir) Then
Call objShell.Run("robocopy """ & srcdir & """ """ & destdir &""" /E /B /R:2 /W:10", 0, True)
End If
End Sub
Sub RunPeriodicBackup(srcdir, destdir)
If Not fso.FolderExists(destdir) Then
fso.CreateFolder destdir
End If
If fso.FolderExists(srcdir) Then
Call objShell.Run("robocopy """ & srcdir & """ """ & destdir &""" /MIR /MOT:60 /B /R:2 /W:10", 0, False)
End If
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment