设为首页收藏本站

 找回密码
 注册

QQ登录

只需一步,快速开始

BC Morning V1806 门户 IT世界 系统管理 查看内容

iSCSitarget: create differencing VHD

2014-11-18 20:56| 发布者: Test| 查看: 305| 评论: 0|来自: Microsoft

摘要: Create differencing VHDsVisual Basic'----------------------------------------------------------------------------- ' 'CreateDiffVHD.vbs ' 'WScript(usingVBScript)usedtocreateaWinTargetDiskusingafile. ' ...
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(2End 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
Windows Server 2012 No
Windows Server 2008 R2 Yes
Windows Server 2008 Yes
Windows Server 2003 No
Windows 8 No
Windows 7 No
Windows Vista No
Windows XP No
Windows 2000 No
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.

返回顶部