Here, fullpath is the full path to the ARCbatch utility; server is the name of the server to run the specified script; and template is the full path and file name of a template file that
Trang 1dTemp = dTemp + 2
dEnd = tTemp - dTemp
objXL.Cells(Row,Column+3).Value = Mid(s, dTemp,dEnd)
tTemp = tTemp + 4
objXL.Cells(Row,Column+4).Value = Mid(s, tTemp)
ElseIf S = "Job Operation - Verify" Then
Verify = 1
ElseIf (Verify = 1) AND _
InStr(s, "Processed ") <> 0 Then
myarray = Split(s)
If IsNumeric(myarray(1)) Then
strSize = strSize + _
(LEFT((myarray(1)/1073741824),6))/1
End If
ElseIf InStr(s, "Job completion status: ") <> 0
Verify = 0
objXL.Cells(Row,Column+6).Value = strSize
objXL.Cells(Row,Column+5).Value = Mid(s, 24)
'If backup failed, bold and highlight red
If LCase(Mid(s, 24)) = LCase("Failed") Then
tRange = "A" & Row & ":G" & Row
objXL.Range(tRange).Select
objXL.Selection.Font.Bold = True
objXL.Selection.Font.ColorIndex = 3
'If backup not successful, bold
ElseIf LCase(Mid(s, 24)) <> LCase("Successful") Then
tRange = "A" & Row & ":G" & Row
objXL.Range(tRange).Select
objXL.Selection.Font.Bold = True
End If
End If
Loop
ts.Close 'Close log file
End If
Next
End Sub
Here, servername is the name of the server to connect to, and logpath is the administrative share and complete
path where the logs are stored (typically c$\Program Files\Veritas\Backup Exec\NT\Data)
Related solution: Found on page:
Creating Detailed Spreadsheets in Microsoft Excel 100
Controlling ARCserve 2000 from the Command Line
Trang 2ARCserve 2000 is an advanced backup utility from Computer Associates (www.cai.com) ARCbatch, included with ARCserve, is a command-line utility that runs backup script files or templates The basic syntax of the ARCbatch command is as follows:
ARCbatch /H=server /S=script
Here, server is the name of the server to run the specified script Script is the full name and path to the ARCbatch
script or template file ARCbatch scripts have an ASX extension and are created with the ARCserve manager ARCbatch templates are INI files you can create to perform or schedule backups and restores To immediately run a full backup using ARCbatch, proceed as follows:
1 Create a new directory to store all files included in this example
2 Start a command prompt and enter “fullpath\ARCbatch /H=server /S=template”
Here, fullpath is the full path to the ARCbatch utility; server is the name of the server to run the specified script; and template is the full path and file name of a template file that contains the following:
[GENERAL]
HOST=*
JOBTYPE=BACKUP
JOBDESCRIPTION=description
[SOURCE_BACKUP]
NODE_NUM=1
BKMETHOD=1
VERIFICATION=2
[NODE_1]
DOMAINNAME=*
NODENAME=$HOST$
NODETYPE=NTAGENT
[DESTINATION_BACKUP]
TAPENAME=tape
GROUPNAME=group
[MEDIA_OPTIONS]
FIRSTTAPEOPTIONS=2
Here, description is the comment to add to the job; tape is the name of the tape; and group is the name of the
device group
Tip
ARCbatch templates support numerous entries Visit www.cai.com for more information
Updating Emergency Repair Disk Information
An Emergency Repair Disk (ERD) contains a copy of critical system files for a particular machine These files are
stored in %windir% \repair and are copied to the ERD whenever one is updated or created Unfortunately, floppy
disks are small in size, prone to corruption, and easily misplaced To update these files without creating an ERD, start a command prompt and enter the following:
RDISK /S-
Here, the /S option specifies to skip the main dialog and copy the complete SAM (Security Account Manager) and SECURITY database files to the repair directory The - specifies to bypass creating an ERD
Trang 3Warning
You should only use the /S option when updating ERD information or creating an ERD on a
system with a small number of users and groups Systems such as a primary domain controller (PDC) have a large SAM that could not possibly fit on an ERD
Archiving Daily ERD Information to a Central Share
To automatically store ERD information to a central network share on a daily basis, proceed as follows:
1 Create a new directory to store all files included in this example
2 Select Start|Run and enter “scriptfile.bat”
Here, scriptfile is the full path and file name of a script file that contains the following:
@Echo Off
Set Server=%ComputerName%
Set Share=cshare
Set Drive=driveletter
Set RDrive=%Drive%\%ComputerName%\ERD
Set RLog=%RDrive%\ERD.log
NET USE %Drive% /DELETE > Nul
NET USE %Drive% \\%Server%\%Share% > Nul
If errorlevel 1 Goto End
REM *Create a time stamp variable to use in logs
For /F "Delims= Tokens=1" %%I in ('Date /T') Do Set Dtime=%%I
For /F "Delims= Tokens=1" %%I in ('Time /T')
Do Set Dtime=%Dtime%%%I
REM *Create a date variable to name new folders
For /F "Tokens=2" %%I in ('Date /t') Do Set DTemp=%%I
For /F "Delims=/,= Tokens=2" %%I in ('Set DTemp')
Do Set TDate=%%I
For /F "Delims=/,= Tokens=3" %%I in ('Set DTemp')
Do Set TDate=%TDate%%%I
For /F "Delims=/,= Tokens=4" %%I in ('Set DTemp')
Do Set TDate=%TDate%%%I
Set RDrive=%RDrive%\%TDate%
Set DTemp=
Set TDate=
Echo %Dtime%: Starting ERD Archving Process >> %RLog%
Set DTime=
If Exist %RDrive% Goto MKERD
MD %RDrive%
Trang 4:MKERD
Echo - Updating ERD Information >> %RLog%
%windir%\system32\rdisk.exe /s- > Nul
If %errorlevel% EQU 0 Goto Copy
Echo - Error running RDISK >> %RLog%
Goto End
:Copy
Echo - Copying ERD Information >> %RLog%
Copy %windir%\Repair\*.* %RDrive% > Nul
Echo - Archiving ERD Information Complete >> %RLog%
NET USE %Drive% /DELETE > Nul
:End
Set Server=
Set Share=
Set Drive=
Set RDrive=
Set RLog=
Note
The highlighted code above must be placed on one line
Tip
You can schedule this script to run regularly by calling with the code from the next example
Here, cshare is the central share to store archived ERD information, and driveletter is the temporary letter to use
while transferring ERD information
Scheduling Tasks with the AT Command
The AT command allows you to schedule tasks from the command line The basic syntax of the AT command is as
follows:
AT \\remote ID /COMMANDS "fullpath"
Tip
To display a list of schedule tasks from the command line, start a command prompt and enter “AT”
Here, remote is an optional name of a remote system of which tasks to control; ID specifies a task ID to modify; fullpath is the complete path and file name of the item to schedule; and the available commands are as follows:
/DELETE—Removes a scheduled job
/YES—Combined with /DELETE, suppresses all jobs cancellation prompt
/INTERACTIVE—Sets the job to interact with the desktop This switch must be set if you want the user to have
any interactivity with the scheduled task
/EVERY:x—Recurrently runs the command on the specified day (x)
/NEXT:x—Runs the command on the next specified date (x)
To schedule a script file to run at a specified time every work day, start a command prompt and enter the following:
AT \\remote time /interactive /every:M,T,W,TH,F scriptfile
Trang 5Here, remote is the name of the system to store the scheduled task; time is the time to run the task; and scriptfile is
the full path and name of the script to run
Tip
You can use the Resource Kit Utility WINAT to graphically control and view scheduled tasks
Creating Tasks with WMI
The Win32_ScheduledJob class allows you to create, delete, or view scheduled tasks This class is extremely
limited in functionality, incorrectly documented, and difficult to work with There is no method to modify an existing task and there are only a few available parameters when creating a task This class also only recognizes and can
create tasks compatible with the AT command For whatever reason, to create a scheduled task using WMI, proceed
as follows:
1 Create a new directory to store all files included in this example
2 Download and install the latest version of WMI and Windows Script Host, from www.microsoft.com, to the new directory
3 Select Start|Run and enter “cscript scriptfile.vbs”
Here, scriptfile is the full path and file name of a script file that contains the following:
On Error Resume Next
DTime = MilTime
Set TZone = GetObject("winmgmts:{impersonationLevel=
impersonate}!\\computer\root\cimv2").ExecQuery
("select * from Win32_TimeZone")
For each Zone in TZone
TBias = Zone.bias + 60 'Compensates for daylight savings
Next
STime = "********" & DTime & "00.000000" & TBias
Set ScheduledJob = GetObject("winmgmts:{impersonationLevel=
impersonate}!\\computer\root\cimv2:Win32_ScheduledJob")
Set method = ScheduledJob.Methods_("Create")
Set inParam = method.inParameters.SpawnInstance_()
inParam.Command = "fullpath "
inParam.StartTime = STime
inParam.RunRepeatedly = rp
inParam.DaysOfWeek = dow
Set outParam = ScheduledJob.ExecMethod_("Create", inParam)
Note
The highlighted code above must be placed on one line
Here, miltime is the time to schedule a task to run (in military format); fullpath is the full path and file name of the program to execute; rp is a binary entry (0 or 1) that specifies whether to create a reoccurring task; and dow are the days of the week to run the task Dow does not accept abbreviated day names (M,T,W,…), but must be entered in
binary format where the days of the week are as follows:
Monday—1
Trang 6Tuesday—2
Wednesday—4
Thursday—8
Friday—16
Saturday—32
Sunday—64
To schedule a task to run on a specific day, simply add up the day values and enter the total For example, to run a task on Tuesday, Friday, and Saturday, you would enter 50 (2+16+32)
Listing Tasks in Internet Explorer Using WMI
The Win32_ScheduledJob class can retrieve and display information on any task previously created using the Win32_ScheduledJob class or AT command To list these scheduled tasks within a formatted Internet Explorer
window, proceed as follows:
1 Create a new directory to store all files included in this example
2 Download and install the latest version of WMI and Windows Script Host, from www.microsoft.com, to the new directory
3 Select Start|Run and enter “cscript scriptfile.vbs”
Here, scriptfile is the full path and file name of a script file that contains the following:
On Error Resume Next
Set FSO = CreateObject("Scripting.FileSystemObject")
Set MSIE = CreateObject("InternetExplorer.Application")
Set ScheduledJob = GetObject("winmgmts:{impersonationLevel=
impersonate}!\\computer\root\cimv2").ExecQuery("select *
from Win32_ScheduledJob")
SetupMSIE
MSIE.Document.Write "<HTML><TITLE>Scheduled Jobs" & _
"</TITLE><BODY bgcolor=#ffffff><FONT FACE=ARIAL>"
MSIE.Document.Write "<B>Displaying tasks created " & _
"with WMI or the AT command:</B><BR><BR>" & _
"<table border=0 width=100% cellspacing=0 " & _
"cellpadding=0>"
For each ejob in ScheduledJob
IEWrite "Caption", EJob.Caption
IEWrite "Command", EJob.Command
IEWrite "Days Of Month", EJob.DaysOfMonth
IEWrite "Days Of Week", EJob.DaysOfWeek
IEWrite "Description", EJob.Description
IEWrite "Install Date" ,EJob.InstallDate
IEWrite "Interact With Desktop", EJob.InteractWithDesktop
IEWrite "Job ID", EJob.JobID
Trang 7IEWrite "Job Status", EJob.JobStatus
IEWrite "Name", EJob.Name
IEWrite "Notify", EJob.Notify
IEWrite "Owner", EJob.Owner
IEWrite "Priority", EJob.Priority
IEWrite "Run Repeatedly", EJob.RunRepeatedly
IEWrite "Start Time", EJob.StartTime
IEWrite "Status", EJob.Status
IEWrite "Time Submitted", EJob.TimeSubmitted
IEWrite "Until Time", EJob.UntilTime
IEWrite " ", " "
Next
MSIE.Document.Write "</table><BR><B>End of List</B>" & _
"</FONT></BODY>"
Sub SetupMSIE
MSIE.Navigate "About:Blank"
MSIE.ToolBar = False
MSIE.StatusBar = False
MSIE.Resizable = False
Do
Loop While MSIE.Busy
SWidth = MSIE.Document.ParentWindow.Screen.AvailWidth SHeight = MSIE.Document.ParentWindow.Screen.AvailHeight MSIE.Width = SWidth/2
MSIE.Height = SHeight/2
MSIE.Left = (SWidth - MSIE.Width)/2
MSIE.Top = (SHeight - MSIE.Height)/2
MSIE.Visible = True
End Sub
Sub IEWrite(Caption,Prop)
MSIE.Document.Write "<tr><td>" & Caption & "</td>" & _ "<td> </td><td align=right>" & Prop & _
"</td></tr>"
End Sub
Note
The highlighted code above must be placed on one line
Here, computer is the name of the computer containing the tasks to list
Related solution: Found on page:
Using Microsoft Internet Explorer as a Display Tool 96
Trang 8Deleting Tasks Using WMI
The Win32_ScheduledJob class can delete any task previously created with the Win32_ScheduledJob class or
AT command To delete all of these scheduled tasks using WMI, proceed as follows:
1 Create a new directory to store all files included in this example
2 Download and install the latest version of WMI and Windows Script Host, from www.microsoft.com, to the new directory
3 Select Start|Run and enter “cscript scriptfile.vbs”
Here, scriptfile is the full path and file name of a script file that contains the following:
On Error Resume Next
Set ScheduledJob = GetObject("winmgmts:{impersonationLevel=
impersonate}!\\computer\root\cimv2").ExecQuery
("select * from Win32_ScheduledJob")
For each ejob in ScheduledJob
ejob.Delete()
Note
Here, computer is the name of the computer containing the tasks to delete
Next
The highlighted code above must be placed on one line
Trang 9Chapter 14: Fun with Multimedia
In Brief
If you’re not having complete and utter fun yet, this chapter is for you In this chapter, you will learn how to use simple scripts to play and control multimedia files You will also learn how to script the Office Assistant and Microsoft Agent characters to interact with your users
The Dreaded Office Assistant
Office assistants are animated characters designed to help and entertain users of Microsoft Office These characters provide tips, accept natural language queries (such as “How do I hide the Office Assistant?”), and perform
animations based on the actions of the user In theory, these assistants sound like a good idea However, soon after the release of these assistants with Office 97, a flood of complaints followed denouncing them The main problem was the overinteraction of these assistants
To turn on the Office Assistant, choose Help|Show the Office Assistant Once the assistant is visible, right-click on it and choose Options Under the Options tab, you can disable the Office Assistant by unchecking Use the Office
Assistant Under the Gallery tab, you can choose which assistant you want to use The default assistant is called Clippit, a hyperactive paper clip that doesn’t know when to be quiet
The Office Assistant Object Model
The Office Assistant object model is a limited one At the top of the model is the assistant object An instance of the Office Assistant object model is created whenever an instance of an office application is created Once the instance
is created, you can make the assistant visible by setting the Visible property to True:
officeapp.Assistant.Visible = True
Once the assistant is visible, you can move, resize, or animate the assistant:
officeapp.Assistant.Left = 500
officeapp.Assistant.Top = 500
Office assistants display messages to users through the Balloon object You can use the NewBalloon property to create an instance of the Balloon object:
Set Balloon = officeapp.Assistant.NewBalloon
Once an instance of the Balloon object has been created, you can create text messages and check boxes, and then show these messages using the Show property:
Balloon.Heading = "Some Text Heading"
Balloon.Text = "Some Body Text"
Balloon.CheckBoxes(1).Text = "An example check box"
Balloon.Show
Tip
If you have Microsoft Office 2000 with the VBA help files installed, the complete Office Assistant object model can be found in the file VBAOFF9.CHM
Under Office 97, office assistants are stored in actor files, with an ACT (Actor) extension (typically located in
C:\Program Files\Microsoft Office\Office) Office 2000 uses the Microsoft Agent ActiveX technology and stores its assistants in ACS (Agent Character) files, allowing for more animations and interaction with the user
Microsoft Agent
Microsoft Agent, originally called Microsoft Interactive Agent, is an ActiveX technology that allows you to display and animate characters to interact with the computer user Agent characters are cartoon-like animations stored in agent character (ACS) files Each character contains its own set of animations and voice patterns You can use Microsoft Agent within Microsoft Office, script files, Web pages, and applications
Trang 10The Microsoft Agent Support Files
In order to run Microsoft Agent, you need to download and install the following items:
Microsoft Agent core components—These are the core components that allow you to access and control a
Microsoft Agent character
Microsoft Agent character files—These are the agent characters you can use to interact with the computer
user
Text-to-speech engines—These engines allow the Microsoft Agent characters to translate text to speech, giving
these characters the ability to “speak.”
You can obtain these components from the Microsoft Agent Web site,
msdn.microsoft.com/workshop/imedia/agent/
The Microsoft Agent Process
All agent character commands and requests are exposed through the agent object model, MSAgent.ocx After you create an instance of the object model, the character can be loaded and is ready to receive requests When a
request for a character animation is made, the data provider (AgentDPV.dll) decompresses the graphic and audio files, and passes them to the automation server (AgentSvr.exe) The automation server renders the files to use transparent backgrounds and borders, giving them the appearance of hovering on top of the screen
Scripting the Microsoft Agent Using
Windows Script Host
The first step to accessing the Microsoft Agent character methods is to create an instance of the Microsoft Agent Control:
Set ACTL = CreateObject("Agent.Control.2")
Once a connection has been established, you can load one of the preinstalled Microsoft Agent characters and set a reference to it:
ACTL.Characters.Load charactername, "charactername.acs"
Set CREF = ACTL.Characters(charactername)
Here, charactername is the name of the Microsoft Agent character, such as Merlin or Peedy After the character has
been loaded, you can make the character visible using the Show method:
CREF.Show
Once the character is visible, you can call on any of the character’s methods to perform an animation or to speak
Each agent contains a set of unique animations To make a character use a specific animation, you use the Play
method:
CREF.Play "animation"
Note
For a complete list of animations, consult the character’s animation reference file
Here, animation is the type of animation to perform, such as greet or sad You can use the Speak method to make
the character say a specific phrase:
CREF.Speak "text"
Finally, you can cause the character to move to a specific location using the MoveTo method:
CREF.MoveTo x,y
Here, x is the horizontal pixel location, and y is the vertical pixel location
Tip
Specifying 0,0 will move the characters to the upper left corner of the screen