cancel
Showing results for 
Search instead for 
Did you mean: 

Including Related Drives when adding image job with vb script

jfhaley99
Level 2

Is there a way to inlude the System Reserved Related Drive when adding an image job with vb script?  The file is created when defining the back-up job manually.


    '-----------------------------------------------------------------------------------------
    ' Step 7: Create an image job.
    ' Parameters used:  DisplayName - specify a display name for the image job
    '                   Description - specify a description for the image job
    '                   IncrementalSupport -  true/false
    '                   RunOnce - true/false
    '                   Compression types
    '                        IMAGE_COMPRESSION_LOW    
    '                        IMAGE_COMPRESSION_MEDIUM    
    '                        IMAGE_COMPRESSION_HIGH    
    '                        IMAGE_COMPRESSION_NEWMEDIUM
    '-----------------------------------------------------------------------------------------
    
    Set oImageJob = CreateObject("Symantec.VProRecovery.ImageJob")
    oImageJob.DisplayName = "Backup of C"
    oImageJob.Description = "Regular backup image of my system volume."
    oImageJob.IncrementalSupport = false
    oImageJob.RunOnce = false
    oImageJob.Compression = oImageJob.Constants.ImageCompressionLow
    oImageJob.Reason = oImageJob.Constants.ImageReasonAutomatic
    oImageJob.Volumes = Array(pVolume)
    'oImageJob.Volumes = Array(arr)
    oImageJob.Task = oTask
    oImageJob.Location(oVolumeSys.ID) = oLocation
    oImageJob.Location(oVolumeC.ID) = oLocation
    oImageJob.Quota=1

    '-----------------------------------------------------------------------------------------
    ' Step 8: Add the image job to the list of jobs.
    '-----------------------------------------------------------------------------------------
    
    Call v2iAuto.AddImageJob(oImageJob)
    WScript.Echo "Image Job added successfully."

  

1 ACCEPTED SOLUTION

Accepted Solutions

Markus_Koestler
Moderator
Moderator
   VIP   

The problem is that the system reserved partition has no mountpoint. So you need to filter by another criteria, e.g. the label of the volume.

View solution in original post

6 REPLIES 6

Markus_Koestler
Moderator
Moderator
   VIP   

This VBS does not include the system reserved partiton? Where is the code that populates pVolume?

jfhaley99
Level 2

Thanks for your response. Here is the code to populate pVolume. I have attached the full code and images of the file I'm missing when creating the image with vb. 

'-----------------------------------------------------------------------------------------
    ' Step 6: Find the volume to image.
    '-----------------------------------------------------------------------------------------
    Set oVolume = Nothing
     pVolume = ""
    For Each oTempVol in v2iAuto.Volumes(false)
        'wscript.echo "vol: "+ oTempVol.MountPoint
        If (oTempVol.MountPoint = sVolume) Then
            Set oVolumeC=oTempVol
            pVolume = pVolume & ",oVolumeC.ID"
            
            'Exit For
        End If
        If (oTempVol.MountPoint = tVolume) Then
            Set oVolumeSys=oTempVol
            pVolume = "oVolumeSys.ID"
            'Exit For
        End If
    Next

 

Markus_Koestler
Moderator
Moderator
   VIP   

The problem is that the system reserved partition has no mountpoint. So you need to filter by another criteria, e.g. the label of the volume.

jfhaley99
Level 2

Thanks for your help. The system reserved partition did have a mount point.  I used the link below and modified it. I'm really suprised symantec does not provide any support for or provide more documentation for working with the API.

https://www-secure.symantec.com/connect/forums/vbscript-create-jobs

'-----------------------------------------------------------------------------------------
'
' Symantec System Recovery 2011 Automation
'
' Copyright (c) 2011 by Symantec Corporation
' All Rights Reserved
'
' THIS SCRIPTING EXAMPLE IS PROVIDED IN CONJUNCTION WITH YOUR LICENSE FOR SYMANTEC
' SYSTEM RECOVERY SOFTWARE PRODUCTS, AND MAY BE USED ONLY IN CONJUNCTION WITH
' THAT SOFTWARE, UNDER THE TERMS OF THE END USER LICENSE AGREEMENT THAT ACCOMPANIED
' THE SOFTWARE. THIS SCRIPTING EXAMPLE IS PROPRIETARY SYMANTEC PROPERTY.  YOU MAY NOT
' COPY, DISTRIBUTE, LICENSE OR SUBLICENSE THE SCRIPTING DOCUMENTATION.
'
'-----------------------------------------------------------------------------------------
'
'   Modified for HCSC by Geno Erickson 7-3-13
'-----------------------------------------------------------------------------------------


    Option Explicit

    
    Dim v2iAuto
    Dim oNet
    Dim oVolume
    Dim oVolumeC
    Dim oVolumeSys
    Dim pVolume
        Dim sVolumesArray    ' 08/06/2014
    Dim oTempVol
    Dim oTask
    Dim oLocation_C_Image
        Dim oLocation_SystemReserved_Image
    Dim oImageJob
    Dim sFolder
    Dim sVolume
    Dim tVolume
        'Dim sysLabel        ' 08/06/2014 for System Reserved Volume


        '-----------------------------------------------------------------------------------------
        'Set the volume that you want to restore.  
    '-----------------------------------------------------------------------------------------
        sVolume="C:\"
    tVolume="*:\"
    sFolder = "D:\symantec_image\"
        'sysLabel = "System Reserved"    ' 08/06/2014 to capture the System Reserved Label    


    '-----------------------------------------------------------------------------------------
    ' Step 1: Process command line arguments.
    '-----------------------------------------------------------------------------------------
    If (WScript.Arguments.Count > 1) Then
        WScript.Echo "Usage: cscript.exe AddImageJob.vbs "
        WScript.Quit
    End If
        

    '-----------------------------------------------------------------------------------------
    ' Step 2: Create a VProRecovery automation object.
    '-----------------------------------------------------------------------------------------
    Set v2iAuto = CreateObject("Symantec.ProtectorAuto")

    '-----------------------------------------------------------------------------------------
    ' Step 3: Connect to the local agent.
    '-----------------------------------------------------------------------------------------
    WScript.Echo "Connecting..."
    Set oNet = CreateObject("Wscript.Network")
    Call v2iAuto.Connect(oNet.ComputerName)

    '-----------------------------------------------------------------------------------------
    ' Step 4: Define the location for saving the image.  
    '-----------------------------------------------------------------------------------------
        'Set oLocation = CreateObject("Symantec.VProRecovery.FolderLocation")
    'oLocation.Path = "D:\symantec_image\"
    ''oLocation.FileSpec = "SystemBackup"
        'oLocation.FileSpec = oNet.ComputerName     ' modified 8/4/2014 to name the file after the computer name


        Set oLocation_C_Image = CreateObject("Symantec.VProRecovery.FolderLocation")
        oLocation_C_Image.Path = "D:\symantec_image\"
        oLocation_C_Image.FileSpec = oNet.ComputerName & "_C"

        Set oLocation_SystemReserved_Image = CreateObject("Symantec.VProRecovery.FolderLocation")
        oLocation_SystemReserved_Image.Path = "D:\symantec_image\"
        oLocation_SystemReserved_Image.FileSpec = oNet.ComputerName & "_SystemReserved"

 

    '-----------------------------------------------------------------------------------------
    ' Step 5: Create a task to schedule the image job.
    ' Parameters used:
    '                   Description - specify a description for the image job
    '                   StartDateTime - set a start date
    '                   RepeatInterval - set an interval to repeat, such as, weekly, monthly, etc
    '                   AddRepeatDay(0) , AddRepeatDay(3) - set the days to repeat, such as Sunday, Monday, etc
    '-----------------------------------------------------------------------------------------
    
    Set oTask = CreateObject("Symantec.Scheduler.Task")
    oTask.Description = "Full Image Schedule"
    'oTask.StartDateTime = CStr(Date()) +" 8:00" ' GMT
    oTask.StartDateTime = CStr(Date()) +" 7:00" ' GMT - changed 7/28/2014 per Windows Admin team
    oTask.RepeatInterval = oTask.Constants.IntervalWeekly
    'oTask.StartDateTime     ' set the start date time
    'oTask.AddRepeatDay(0)    ' Sunday
    oTask.AddRepeatDay(4)    ' Thursday - changed 7/28/2014 per Windows Admin Team
    Call oTask.Validate()    ' Make sure we built the task correctly


    '-----------------------------------------------------------------------------------------
    ' Step 6: Find the volume to image.
    '-----------------------------------------------------------------------------------------
       

        Set oVolume = Nothing
    'pVolume = ""
    sVolumesArray = ""
        For Each oTempVol in v2iAuto.Volumes(false)
        
                'wscript.echo "vol: "+ oTempVol.MountPoint
                'wscript.echo "label: "+ oTempVol.Label    ' 08/06/2014 Testing to try and get the System Reserved volume          

                 Select Case oTempVol.MountPoint
                 
                 Case "*:\"                                                   

                     Set oVolumeSys = oTempVol
                     sVolumesArray = "oVolumeSys.ID"
                 
                 Case "C:\"
               
                     Set oVolumeC = oTempVol
                     If sVolumesArray = "oVolumeSys.ID,oVolumeC.ID" Then
                     WScript.Sleep 0
                     Else
                        sVolumesArray = sVolumesArray & ",oVolumeC.ID"
                     End If

                 Case Else
                     
                    WScript.Sleep 0

                 End Select
         
 

    Next


    'If (pVolume Is Nothing) Then _
        'Call Err.Raise(vbObjecterror+1, "AddImageJob.vbs", "Cannot find requested volume")

    '-----------------------------------------------------------------------------------------
    ' Step 7: Create an image job.
    ' Parameters used:  DisplayName - specify a display name for the image job
    '                   Description - specify a description for the image job
    '                   IncrementalSupport -  true/false
    '                   RunOnce - true/false
    '                   Compression types
    '                        IMAGE_COMPRESSION_LOW    
    '                        IMAGE_COMPRESSION_MEDIUM    
    '                        IMAGE_COMPRESSION_HIGH    
    '                        IMAGE_COMPRESSION_NEWMEDIUM
    '-----------------------------------------------------------------------------------------
    
    Set oImageJob = CreateObject("Symantec.VProRecovery.ImageJob")
    oImageJob.DisplayName = "Backup of C and System Reserved Drives"
    oImageJob.Description = "Regular backup image of my system volume."
    oImageJob.IncrementalSupport = false
    oImageJob.RunOnce = false
    oImageJob.Compression = oImageJob.Constants.ImageCompressionLow
    oImageJob.Reason = oImageJob.Constants.ImageReasonAutomatic
    'oImageJob.Volumes = Array(pVolume)
        oImageJob.Volumes = Array(sVolumesArray)   ' 08/06/2014
        oImageJob.Task = oTask
    'oImageJob.Location(oVolume.ID) = oLocation   '08/06/2014
        'oImageJob.Quota=1
        oImageJob.Quota=0                            ' 08/06/2014
        oImageJob.Location(oVolumeC.ID) = oLocation_C_Image
        oImageJob.Location(oVolumeSys.ID) = oLocation_SystemReserved_Image

 


    '-----------------------------------------------------------------------------------------
    ' Step 8: Add the image job to the list of jobs.
    '-----------------------------------------------------------------------------------------
    
    Call v2iAuto.AddImageJob(oImageJob)
    WScript.Echo "Image Job added successfully."

 

    
    '-----------------------------------------------------------------------------------------
    ' Step 3: Connect to the agent.
    '-----------------------------------------------------------------------------------------
    
    
        

    '-----------------------------------------------------------------------------------------
    ' Step 4: Get the image job object from the agent.
    '-----------------------------------------------------------------------------------------
    
    Set oImageJob = v2iAuto.ImageJob(oImageJob.ID)

    '-----------------------------------------------------------------------------------------
    ' Step 5: Execute the job immediately.
    '-----------------------------------------------------------------------------------------
    
    WScript.Echo "Running job " & oImageJob.DisplayName & "..."
    Call v2iAuto.DoImageJob(oImageJob.ID, oImageJob.Constants.ImageTypeBase)

       

 

 

 

 

Markus_Koestler
Moderator
Moderator
   VIP   

You're right, API Documentation is very poor. Some is included on the product CD.

Markus_Koestler
Moderator
Moderator
   VIP   

May I ask you to mark your post as solved?