Create differencing VHDs
'-----------------------------------------------------------------------------
'
' CreateDiffVHD.vbs
'
' WScript (using VBScript) used to create a WinTarget Disk using a file.
'
' USAGE:
'
' CreateDiffVHD <diff VHD filename> <parent VHD filename> [description]
'
' Return value:
' Success: Index of newly created WTD
' Failure: -1
'
'-----------------------------------------------------------------------------
Dim Usage
Usage = "USAGE:" & vbCrLf & _
" CreateDiffVHD <diff VHD filename> <parent VHD filename> [description]" & vbCrLf
'
' Make sure we have the correct number of arguments.
'
If ( WScript.Arguments.Count < 2 Or WScript.Arguments.Count > 3 ) Then
WScript.StdOut.Write Usage
WScript.Quit -1
End If
'
' Extract the arguments.
'
Dim DiffFileName
DiffFileName = WScript.Arguments(0)
Dim ParentFileName
ParentFileName = WScript.Arguments(1)
Dim Description
Description = ""
If ( WScript.Arguments.Count = 3 ) Then
Description = WScript.Arguments(2)
End If
'
' Turn off automatic error handling so we can check the error status.
'
On Error Resume Next
'
' Get the Wbem Services object.
'
Dim WbemServices
Set WbemServices = GetObject("WINMGMTS:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\.\root\wmi")
'
' Get the WT_Disk class.
'
Dim WtDiskClass
Set WtDiskClass = WbemServices.Get( "WT_Disk" )
'
' Create the differencing WTDisk.
'
Dim WTDisk
Dim RetCode
WScript.StdOut.Write DiffFileName & vbCrLf
WScript.StdOut.Write ParentFileName & vbCrLf
Set WTDisk = WTDiskClass.NewDiffWTDisk( DiffFileName, _
ParentFileName, _
Description, _
TRUE )
If ( Err.Number <> 0 ) Then
WScript.StdOut.Write "Failed to create differencing WTDisk. " & Err.Description & vbCrLf
WScript.Quit -1
End If
'
' Display the WTDisk index.
'
WScript.StdOut.Write "WinTarget Disk WTD " & WTDisk.WTD & " was created successfully." & vbCrLf
'
' Return the new LUN index.
'
WScript.Quit WTDisk.WTD
'-----------------------------------------------------------------------------
'
' CreateDiffVHD.vbs
'
' WScript (using VBScript) used to create a WinTarget Disk using a file.
'
' USAGE:
'
' CreateDiffVHD <diff VHD filename> <parent VHD filename> [description]
'
' Return value:
' Success: Index of newly created WTD
' Failure: -1
'
'-----------------------------------------------------------------------------
Dim Usage
Usage = "USAGE:" & vbCrLf & _
" CreateDiffVHD <diff VHD filename> <parent VHD filename> [description]" & vbCrLf
'
' Make sure we have the correct number of arguments.
'
If ( WScript.Arguments.Count < 2 Or WScript.Arguments.Count > 3 ) Then
WScript.StdOut.Write Usage
WScript.Quit -1
End If
'
' Extract the arguments.
'
Dim DiffFileName
DiffFileName = WScript.Arguments(0)
Dim ParentFileName
ParentFileName = WScript.Arguments(1)
Dim Description
Description = ""
If ( WScript.Arguments.Count = 3 ) Then
Description = WScript.Arguments(2)
End If
'
' Turn off automatic error handling so we can check the error status.
'
On Error Resume Next
'
' Get the Wbem Services object.
'
Dim WbemServices
Set WbemServices = GetObject("WINMGMTS:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\.\root\wmi")
'
' Get the WT_Disk class.
'
Dim WtDiskClass
Set WtDiskClass = WbemServices.Get( "WT_Disk" )
'
' Create the differencing WTDisk.
'
Dim WTDisk
Dim RetCode
WScript.StdOut.Write DiffFileName & vbCrLf
WScript.StdOut.Write ParentFileName & vbCrLf
Set WTDisk = WTDiskClass.NewDiffWTDisk( DiffFileName, _
ParentFileName, _
Description, _
TRUE )
If ( Err.Number <> 0 ) Then
WScript.StdOut.Write "Failed to create differencing WTDisk. " & Err.Description & vbCrLf
WScript.Quit -1
End If
'
' Display the WTDisk index.
'
WScript.StdOut.Write "WinTarget Disk WTD " & WTDisk.WTD & " was created successfully." & vbCrLf
'
' Return the new LUN index.
'
WScript.Quit WTDisk.WTD