home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2005 June / PCWELT_6_2005.ISO / pcwsoft / pcwUnstick.z.exe / pcwUnstick.vbs
Encoding:
Text File  |  2005-03-23  |  2.9 KB  |  67 lines

  1. ''''''''''''''''''''''''''''''''''''''''''''''''
  2. ' Hier k÷nnen Sie in der Variable sounddatei
  3. ' eine eigene WAV-Datei angeben.
  4. ' Beispiel: "C:\Windows\Media\Ding.wav"
  5. ''''''''''''''''''''''''''''''''''''''''''''''''
  6.  
  7. sounddatei = ""
  8.  
  9. ''''''''''''''''''''''''''''''''''''''''''''''''
  10. ' Ab hier beginnt das Script:
  11. ''''''''''''''''''''''''''''''''''''''''''''''''
  12.  
  13. strMsg = ""
  14. strComputer = "."
  15.  
  16. Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  17. Set colDiskDrives = objWMI.ExecQuery("Select DeviceID from Win32_DiskDrive WHERE InterfaceType='USB'")
  18. For Each objDiskDrive In colDiskDrives
  19.    strDeviceID = objDiskDrive.DeviceID
  20.    strEscapedDeviceID = Replace(strDeviceID, "\", "\\")
  21.    Set colDiskPartitions = objWMI.ExecQuery("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=""" & strEscapedDeviceID & """} WHERE AssocClass = Win32_DiskDriveToDiskPartition")
  22.    For Each objDiskPartition In colDiskPartitions
  23.      Set colLogicalDisks = objWMI.ExecQuery("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=""" & objDiskPartition.DeviceID & """} WHERE " & "AssocClass = Win32_LogicalDiskToPartition")
  24.      For Each objLogicalDisk In colLogicalDisks
  25.        if strUSBDrive = "" then
  26.       strUSBDrive = objLogicalDisk.DeviceID
  27.     else
  28.       strUSBDrive = strUSBDrive & "und " & objLogicalDisk.DeviceID
  29.     end if
  30.      Next
  31.    Next
  32. Next
  33.  
  34. Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  35. Set colDiskDrives = objWMI.ExecQuery("Select DeviceID from Win32_DiskDrive WHERE InterfaceType='1394'")
  36. For Each objDiskDrive In colDiskDrives
  37.    strDeviceID = objDiskDrive.DeviceID
  38.    strEscapedDeviceID = Replace(strDeviceID, "\", "\\")
  39.    Set colDiskPartitions = objWMI.ExecQuery("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=""" & strEscapedDeviceID & """} WHERE AssocClass = Win32_DiskDriveToDiskPartition")
  40.    For Each objDiskPartition In colDiskPartitions
  41.      Set colLogicalDisks = objWMI.ExecQuery("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=""" & objDiskPartition.DeviceID & """} WHERE " & "AssocClass = Win32_LogicalDiskToPartition")
  42.      For Each objLogicalDisk In colLogicalDisks
  43.        if str1394Drive = "" then
  44.       str1394Drive = objLogicalDisk.DeviceID
  45.     else
  46.       str1394Drive = str1394Drive & "und " & objLogicalDisk.DeviceID
  47.     end if
  48.      Next
  49.    Next
  50. Next
  51.  
  52. if strUSBDrive <> "" then
  53.  strMsg = "Bitte USB-Laufwerk(e) " & strUSBDrive & " nicht vergessen" & chr(10)
  54. end if
  55.  
  56. if str1394Drive <> "" then
  57.  strMsg = strMsg & "Bitte Firewire-Laufwerk(e) " & strUSBDrive & " nicht vergessen"
  58. end if
  59.  
  60. if strMsg <> "" then
  61.   Set objWSH = CreateObject("Wscript.Shell")
  62.   if sounddatei = "" then sounddatei = objWSH.ExpandEnvironmentStrings("%WINDIR%") & "\Media\Ringin.wav"
  63.   objWSH.Run "sndrec32.exe /play /close " & sounddatei, 0, false
  64.   Msgbox strMsg, 16, "Externe Wechselmedien gefunden!"
  65. end if
  66.  
  67.