Create differencing VHDs Visual Basic '----------------------------------------------------------------------------- ' ' 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 Verified on the following platforms
This script is tested on these platforms by the author. It is
likely to work on other platforms as well. If you try it and find that
it works on another platform, please add a note to the script discussion
to let others know.
Online peer support
For online peer support, join
The Official Scripting Guys Forum!
To provide feedback or report bugs in sample scripts, please start a new discussion on the Discussions tab for this script.
|
手机版|BC Morning Website ( Best Deal Inc. 001 )
GMT-8, 2025-7-8 11:17 , Processed in 0.013320 second(s), 19 queries .
Supported by Best Deal Online X3.5
© 2001-2025 Discuz! Team.