Freitag, 30. März 2012

Backup using Robocopy, Dropbox and Javascript


  • Stoppen eine Prozeses

  • Kopieren der Daten

  • Den Prozess erneut starten



Robocopy, or "Robust File Copy", is a command-line directory replication command. It has been available as part of the Windows Resource Kit starting with Windows NT 4.0, and was introduced as a standard feature of Windows Vista, Windows 7 and Windows Server 2008. Robocopy is notable for capabilities above and beyond the built-in Windows copy and xcopy commands, including the following: • Ability to tolerate network interruptions and resume copying. • Ability to copy file data and


 var objWMIService = GetObject("winmgmts:\\\\.\\root\\CIMV2");  
var colitems = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE name = 'notepad.exe'");
var e = new Enumerator(colitems);
for (; !e.atEnd(); e.moveNext())
{
e.item().Terminate();
}
try {
var objShell = new ActiveXObject("wscript.shell");
var oExec = objShell.Exec("robocopy c:\Daten g:\Daten /MIR /LOG:robocopy.log");
while (oExec.Status == 0)
{
WScript.Sleep(100);
}
WScript.Echo("finished robocopy");
try {
objShell.Run("C:\\WINDOWS\\system32\\notepad.exe");
//Warte-Schleife ist an dieser Stelle nicht erforderlich
WScript.Echo("launched Notepad");
}
catch (e){
WScript.Echo('Can not find '+"C:\\WINDOWS\\system32\\notepad.exe")
}
objShell = null;
}
catch (e){
WScript.Echo('Can not find '+"robocopy c:\Daten g:\Daten /MIR /LOG:robocopy.log")
}