我已经有一个脚本要求用户输入将文件“install1.exe”安装到“install6.exe”,默认驱动器号路径为D:\,我有另一个驱动器可以得到像“C:”这样的驱动器号,不知道如何整合
首先我需要进行驱动器盘符检查以确认计算机有驱动器D物理本地磁盘(不是cdrom),如果是,则提示用户确认继续 或者用户可以单击“否”输入驱动器号,驱动器号也需要在当前安装脚本{D}上更新:\ temp \ install1.exe
Dim query
Dim objWMI
Dim diskDrives
Dim diskDrive
Dim partitions
Dim partition ' will contain the drive & partition numbers
Dim logicalDisks
Dim logicalDisk ' will contain the drive letter
Set objWMI = GetObject("winmgmts:\\.\root\cimv2")
Set diskDrives = objWMI.ExecQuery("SELECT * FROM Win32_DiskDrive") ' First get out the physical drives
For Each diskDrive In diskDrives
query = "ASSOCIATORS OF {Win32_DiskDrive.DeviceID='" + diskDrive.DeviceID + "'} WHERE AssocClass = Win32_DiskDriveToDiskPartition" ' link the
physical drives to the partitions
Set partitions = objWMI.ExecQuery(query)
For Each partition In partitions
query = "ASSOCIATORS OF {Win32_DiskPartition.DeviceID='" + partition.DeviceID + "'} WHERE AssocClass = Win32_LogicalDiskToPartition" ' link
the partitions to the logical disks
Set logicalDisks = objWMI.ExecQuery (query)
For Each logicalDisk In logicalDisks
' Wscript.Echo logicalDisk.DeviceID & " - " & partition.Caption
Wscript.Echo logicalDisk.DeviceID
'else
Next
Next
Next
Dim objShell
Dim Message, result
Dim Title, Text1, Text2
' Define dialog box variables.
Message = "Please enter a path"
Title = "Install Started"
Text1 = "Install Cancelled"
Text2 = "You entered value is incorrect, please select from 1,2,3,4,5 or 6" & vbCrLf
result = InputBox("Please select the by number"& Chr(13) & "A" & Chr(13) & "B" & Chr(13) & "C" & Chr(13) & "D" & Chr(13) & "E" & Chr(13) & "F", Title, "Please enter the number", 100, 100)
Set objShell = WScript.CreateObject( "WScript.Shell" )
' Evaluate the user input.
If result = "" Then ' Canceled by the user
WScript.Echo Text1
ElseIf result = "1" Then
objShell.Run("7z.exe x temp.7z -oD:\ -bd -y")
wscript.sleep (3000)
objShell.Run("D:\temp\install1.exe")
wscript.sleep (150000)
wScript.Echo "install Completed"
ElseIf result = "2" Then
......
......
......
Else
WScript.Echo Text2 & result
End If
wscript.quit
谢谢