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

'*** v10.3 *** www.dieseyer.de *****************************
'
' Datei: remotesysrootshare.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 RemoteSysRootShare( "PC1" )

Wscript.Quit


'*** v10.3 *** www.dieseyer.de *****************************
Function RemoteSysRootShare( PCName )
'***********************************************************
' Erweiterte "Function RemoteSystemDrive( PCName )""

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

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

WinDir = Replace( WinDir, ":", "")
' MsgBox "WinDir: " & WinDir, , "41 :: " & PCName & " " & WScript.ScriptName
Tst = Left( WinDir, 1 )
RemoteSysRootShare = "\\" & PCName & "\" & Left( WinDir, 1 ) & "$" & Mid( WinDir, 2 )
' MsgBox "RemoteSysRootShare: " & RemoteSysRootShare, , "44 :: " & PCName & " " & WScript.ScriptName

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

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

End Function ' RemoteSysRootShare( PCName )

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