http://dieseyer.de • all rights reserved • © 2011 v11.4

'*** v9.3 *** www.dieseyer.de ******************************
'
' Datei: remotesysdriveshare.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 RemoteSysDriveShare( "PC02" )

Wscript.Quit


'*** v9.3 *** www.dieseyer.de ******************************
Function RemoteSysDriveShare( PCName )
'***********************************************************
' Erweiterte "Function RemoteSystemDrive( PCName )""

Dim fso : Set fso = WScript.CreateObject("Scripting.FileSystemObject")
Dim Lw
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 : RemoteSysDriveShare = "Fehler: \..\c$: " & Tst : Exit Function

Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
Lw = objOperatingSystem.SystemDrive
Next
Set colOperatingSystems = nothing
Set objWMIService = nothing

Lw = Replace( Lw, ":", "")
' MsgBox "Lw: " & Lw, , "41 :: " & PCName & " " & WScript.ScriptName

RemoteSysDriveShare = "\\" & PCName & "\" & Lw & "$"
' MsgBox "RemoteSysDriveShare: " & RemoteSysDriveShare, , "44 :: " & PCName & " " & WScript.ScriptName

If fso.FolderExists( RemoteSysDriveShare ) Then
RemoteSysDriveShare = "Erreichbar: " & RemoteSysDriveShare
' MsgBox "RemoteSysDriveShare: " & RemoteSysDriveShare, , "48 :: " & PCName & " " & WScript.ScriptName
Exit Function
End If

RemoteSysDriveShare = "Fehler - Nicht erreichbar: " & RemoteSysDriveShare
' MsgBox "RemoteSysDriveShare: " & RemoteSysDriveShare, , "53 :: " & PCName & " " & WScript.ScriptName

End Function ' RemoteSysDriveShare( PCName )

http://dieseyer.de • all rights reserved • © 2011 v11.4