Code-Beispiel
VHD-Dateien einbinden oder abtrennen
Lizenz: | Erster Autor: | Letzte Bearbeitung: |
k. A. | ![]() | ![]() |
Dim As String vhdpath,partialstring,vdiskcommand,scriptpath
If Len(Command(1))>0 Then
vhdpath=Command(1)
Print Wstr(vhdpath)
Else
Input "Paste VHD path: ",vhdpath
End If
If Instr(vhdpath,":")=0 Then End ' Full path required
Dim As Long attribute
If Len(Dir(vhdpath,&hFF,attribute))=0 Then End ' Path not found
If Bit(attribute,4) Then End ' If Directory Then End
partialstring=Lcase(Right(vhdpath,Len(vhdpath)-Instrrev(vhdpath,".")))
If Not((partialstring="vhd") Or (partialstring="vhdx")) Then End
Print
Print "[ attach virtual disk | detach virtual disk ]"
Print
Print "Input [ a | d ]: ";
Select Case Chr(Getkey)
Case "a"
vdiskcommand="attach vdisk"
Case "d"
vdiskcommand="detach vdisk"
Case Else
End
End Select
Print vdiskcommand
Print
scriptpath=Exepath & "\diskpartscript.txt"
Open scriptpath For Output As #1
Print #1,"select vdisk file=" & Chr(34) & vhdpath & Chr(34)
Print #1,vdiskcommand
Print #1,"exit"
Close #1
Dim As Long result=Shell("diskpart /s " & Chr(34) & scriptpath & Chr(34))
If result=0 Then
Print "Operation successful."
Else
Print "Operation failed."
End If
Sleep
End ' mountvhd.bas
'
Eine Verknüpfung kann in das "Senden an"-Menü kopiert werden.
Der entsprechende Ordner lässt sich mit der FreeBASIC-Zeile
shell "explorer shell:sendto"
öffnen.
Zusätzliche Informationen und Funktionen | |||||||
---|---|---|---|---|---|---|---|
|