#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=VHD Auto Attach 1.1\Icons\No.ico
#AutoIt3Wrapper_Outfile=VHD Auto Attach 1.1\DetachRun.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
$UNC = ""
$UNC_SPLIT = ""
$Result = ""
#Include <Array.au3>
#include <Constants.au3>
TrayTip( "Starting Detaching...", "VHDAutoAttach starts. Please standby and let the focus on the windows!", 30, 2)
Sleep(1000)
$UNC = ""
$UNC_SPLIT = ""
$Result = ""

	For $i = 2 to $CmdLine[0] Step 1
		$UNC = $UNC & $CmdLine[$i]
		if $i <> $CmdLine[0] Then $UNC = $UNC & " "
	Next

	$UNC_SPLIT = StringSplit($UNC,"\")

	if $CmdLine[1] = "UNC" Then
		$Result = $UNC_SPLIT[1]
		For $i = 2 to UBound($UNC_SPLIT)-1 Step 1
			$Result = $Result & "\" & $UNC_SPLIT[$i]
		Next
		ClipPut($Result)
	EndIf




Run( "Diskpart.exe")
Sleep(1000)
Send('list disk {ENTER}')
Send('list volume {ENTER}')
Send('select vdisk file= ' & $Result & '{ENTER}')
Send('Detach vdisk {ENTER}')
Sleep(1000)
WinClose( "[ACTIVE]","")