I use Autohotkey to run from command line:1. You need to edit the script with Notepad and make double-sure the parameter values you set are correct
2. You need to run the scripts from command prompt, and in Vista/Windows 7 it needs to be opened "As Administrator"
3. You need to explictily tell Windows what scripting host to use. The default is wscript (used for GUI/Windows based scripts). You need to use cscript (command line type scripts). In other words, you need to use the syntax:
C:\Myscripts>cscript BackupJobExecute_FT.vbs
4. You can have the ShadowProtect GUI open if you want to doublecheck that the script is triggering the backup
Code: Select all
Runwait %comspec% /c "cscript BackupJobExecute.vbs", K:\Z Modifications\_VBS\, hide
Code: Select all
Set stdOut = WScript.Stdout
Set ShadowProtect = CreateObject ("ShadowStor.ShadowProtect")
StdOut.Write "Execute Backup job" & vbCrLf
Dim BackupJob, JobName
ON ERROR RESUME NEXT
JobName="AUTO"
Set BackupJob = ShadowProtect.Jobs.GetBackupJob(JobName)
if Err<>0 then
StdOut.Write "GetBackupJob failed" & vbCrLf
else
StdOut.Write "Execute " & JobName & vbCrLf
'1 = incremental
'2 = differential
'3 = full
BackupJob.Execute 3
end if
Code: Select all
; I:\Drive is the partition where I keep my backups
; auto is the name of the shadowprotect job and resulting spf file
; loop through the "auto" backups to find the oldest and the largest
loop, i:\auto*.spf
{
time := A_LoopFileTimeModified
if first =
{
first := time
path:= A_LoopFileFullPath
formattime, date, %first%, yyyy-MM-dd HH-mm-ss
}
if time <= %first%
{
first := time
path:= A_LoopFileFullPath
formattime, date, %first%, yyyy-MM-dd HH-mm-ss
}
if size < A_LoopFileSizeMB
size := A_LoopFileSizeMB
}
; if there is not enough space left on the drive delete the oldest "auto" backup
DriveSpaceFree, space, I:\
if space < %size%
filedelete %path%
; now find the number of existing "auto" backups
jobs = 0
loop, i:\auto*.spf
jobs++
; add 1 as going to make a new backup
jobs += 1
; execute the job, the /c switch closes the cmd window when it is finished
; the hide option hides the cnd window
; K:\Z Modifications\_VBS\ is the path to the folder containing BackupjobExecute.vbs
Runwait %comspec% /c "cscript BackupJobExecute.vbs", K:\Z Modifications\_VBS\, hide
; start a 10 second timer to check for when the job is complete
setTimer, backUp, 10,000
return
Close:
Progress, CW800000 CTFFFFFF m2 b fs18 zh0, Shutting Down, Process Complete
Sleep, 2000 ; 2 seconds
Progress, Off
;shutdown, 1
ExitApp
return
backUp:
new = 0
loop, i:\auto*.spf
new++
if (new - jobs = 0)
{
setTimer, backUp, off
goto Close
}
return
Chris