WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples from Users

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Symantec ProtectorAuto OLE Script


Question:

I have some Visual Basic Symantec ProtectorAuto OLE code that I am trying to translate in to WinBatch Can you help?
Option Explicit

Dim v2iauto, oNet, oImageJob
Dim oArgs, sMode

set oArgs=Wscript.Arguments

if oArgs.Count < 1 then 
wscript.echo "Must provide /B or /I on command line. Exiting."
wscript.quit(1)
end if

if lcase(oArgs(0)) = "/i" then
sMode = "I"
elseif lcase(oArgs(0)) = "/b" then
sMode = "B"
else
wscript.echo "Must provide /B or /I on command line. Exiting."
wscript.quit(1)
end if

'' -------- Create a LiveStateRecovery Automation object --------
set v2iAuto = Nothing
Set v2iAuto = CreateObject("Symantec.ProtectorAuto")
If(v2iAuto Is Nothing) Then _
Call Err.Raise(vbObjecterror+1, "KraftExecute.vbs", "Cannot create v2iAuto object")

'' ------ Connect to the local agent ------
Set oNet = CreateObject("Wscript.Network")
Call v2iAuto.Connect(oNet.ComputerName) '' or any computer with agent

'' ------ Find the first Scheduled Job containing an Incremental ------
for each oImageJob in v2iauto.imagejobs
if oImageJob.IncrementalSupport=True then
if sMode=="B" then
oImageJob.Type=oImageJob.Constants.ImageTypeBase
else
oImageJob.Type=oImageJob.Constants.ImageTypeIncremental
end if

'' ---- Execute the Job! ----
oImageJob.Reason=oImageJob.Constants.ImageReasonManual
Call v2iAuto.DoImageJob(oImageJob.ID, oImageJob.Type)
end if
next 

Answer:

Note: No need to open Wscript.Network to get the computername, WinBatch can simply use the WinSysInfo function to get the computername.

Here is the code translated into WIL:


if Param0 < 1 then 
	Message("Notice","Must provide /B or /I on command line. Exiting.")
	exit
endif

if StrLower(Param1) == "/i" 
	sMode = "I"
else
	if StrLower(Param1) == "/b" then
		sMode = "B"
	else
		Message("Notice","Must provide /B or /I on command line. Exiting.")
		exit
	endif
endif

;; -------- Create a LiveStateRecovery Automation object --------
ErrorMode(@OFF)
objV2iAuto = CreateObject("Symantec.ProtectorAuto")
ErrorMode(@CANCEL)
if objV2iAuto == 0
	Message("Error", "Cannot create v2iAuto object")
	exit
endif
;; ------ Connect to the local agent ------
computername = ItemExtract(1,WinSysInfo(),@TAB)
objV2iAuto.Connect(computername); '' or any computer with agent

;; ------ Find the first Scheduled Job containing an Incremental ------
objImageJobs = objV2iAuto.imagejobs
foreach oImageJob in objImageJobs
	if oImageJob.IncrementalSupport==@True 
		if sMode="B" then
			oImageJob.Type=oImageJob.Constants.ImageTypeBase
		else
			oImageJob.Type=oImageJob.Constants.ImageTypeIncremental
		endif
		
		;; ---- Execute the Job! ----
		oImageJob.Reason=oImageJob.Constants.ImageReasonManual
		objV2iAuto.DoImageJob(oImageJob.ID, oImageJob.Type)
	endif
next 

objImageJobs = 0
objV2iAuto = 0

Article ID:   W16657
File Created: 2005:02:18:12:21:46
Last Updated: 2005:02:18:12:21:46