http://dieseyer.de • all rights reserved • © 2011 v11.4
'*** v9.3 *** www.dieseyer.de ******************************
'
' Datei: remotesystemdrive.vbs
' Autor: dieseyer@gmx.de
' Auf: www.dieseyer.de
'
' Die Prozedur ist Bestandteil von WinTuC_vbs.vbs (WinTuC.de)
'
'***********************************************************
Option Explicit ' Siehe http://dieseyer.de/dse-wsh-lernen.html#OptionExpl
MsgBox RemoteSystemDrive( "PC01" )
Wscript.Quit
'*** v10.3 *** www.dieseyer.de *****************************
Function RemoteSystemDrive( PCName )
'***********************************************************
' http://msdn2.microsoft.com/en-us/library/aa394596(vs.85).aspx
' ermittelt %SystemDrive%; häufig C:
Dim objWMIService, colOperatingSystems, objOperatingSystem, Tst
On Error Resume Next
err.Clear
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & PCName & "\root\cimv2")
Tst = err.Number & " - " & err.Description
On Error Goto 0
If Len( Tst ) > 4 Then : RemoteSystemDrive = "Fehler: WMI SysLw " & Tst : Exit Function
On Error Resume Next
err.Clear
Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
Tst = err.Number & " - " & err.Description
On Error Goto 0
If Len( Tst ) > 4 Then : RemoteSystemDrive = "Fehler: WMI SysLwOS " & Tst : Exit Function
On Error Resume Next
err.Clear
For Each objOperatingSystem in colOperatingSystems
Tst = err.Number & " - " & err.Description
On Error Goto 0
If Len( Tst ) > 4 Then : RemoteSystemDrive = "Fehler: WMI SysLwDr " & Tst : Exit Function
RemoteSystemDrive = objOperatingSystem.SystemDrive
Next
Set colOperatingSystems = nothing
Set objWMIService = nothing
' RemoteSystemDrive = "%systemdrive%: " & RemoteSystemDrive
End Function ' RemoteSystemDrive( PCName )
http://dieseyer.de • all rights reserved • © 2011 v11.4