July 7, 2002
![sp_UserOfflineSmall](https://nordichardware.se/wp-content/sp-resources/forum-themes/reboot/images/darkpack/sp_UserOfflineSmall.png)
kan nån berätta hur man gör så följande kod BARA skriver ut cd-romer? nu skirver den alla enheter ju =(
on error resume Next
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim oFileSys, oFileWrite, Drive
Set oFileSys = CreateObject("Scripting.FileSystemObject")
Count = -1
For each drv in oFileSys.Drives
Set Drive = oFileSys.GetDrive(drv.Driveletter)
Set oFileWrite = oFileSys.CreateTextFile("CD_" & Drive.DriveLetter & ".vbs", True)
oFileWrite.WriteLine("'Extended Drive Attributes Functions VBScript")
oFileWrite.WriteLine("'this is a remake by x1zt =)")
oFileWrite.WriteLine
oFileWrite.WriteLine("on error resume Next")
oFileWrite.WriteLine
oFileWrite.WriteLine("Dim oFileSys, Drive, sDriveType")
oFileWrite.WriteLine
oFileWrite.WriteLine("Set oFileSys = CreateObject(""Scripting.FileSystemObject"")")
oFileWrite.WriteLine("Set Drive = oFileSys.GetDrive(" & Chr(34) & Drive.DriveLetter & Chr(34) & Chr(41))
If Drive.DriveType = 2 Then
Count = Count + 1
oFileWrite.WriteLine("Set DiskInfoSet = GetObject(" & Chr(34)& "winmgmts:{impersonationLevel=impersonate}!//localhost" & Chr(34)_
& ").ExecQuery(" & Chr(34) & "select Model, SCSIBus, SCSILogicalUnit, SCSIPort, SCSITargetId from Win32_DiskDrive where Index = " & Count & Chr(34) & Chr(41))
oFileWrite.WriteLine
End If
oFileWrite.WriteLine
oFileWrite.WriteLine
oFileWrite.WriteLine
oFileWrite.WriteLine("'----------------------------------------------")
oFileWrite.WriteLine("'Displays individual drive volume name")
oFileWrite.WriteLine("Function VolumeName()")
oFileWrite.WriteLine
oFileWrite.WriteLine("If Drive.IsReady = True Then")
oFileWrite.WriteLine(" VolumeName = Drive.VolumeName")
oFileWrite.WriteLine("Else")
oFileWrite.WriteLine("VolumeName = ""NO CD""")
oFileWrite.WriteLine("End If")
oFileWrite.WriteLine
oFileWrite.WriteLine("End Function")
next
December 6, 2001
![sp_UserOfflineSmall](https://nordichardware.se/wp-content/sp-resources/forum-themes/reboot/images/darkpack/sp_UserOfflineSmall.png)
Du måste testa om Drive.DriveType = 4, om det är sant så är det en CD-ROM.
Kolla in exemplet i dokumentationen till VB. :bok:
1 Guest(s)
![sp_Information](https://nordichardware.se/wp-content/sp-resources/forum-themes/reboot/images/darkpack/sp_Information.png)