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

'*** v10.3 *** www.dieseyer.de *****************************
'
' Datei: remoteccmshare.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

Dim PC, CacheLocation

PC = "PC1"
CacheLocation = SMSCacheLocation( PC )
MsgBox RemoteCCMShare( PC, CacheLocation ), , "017 :: " & PC

Wscript.Quit


'*** v10.3 *** www.dieseyer.de *****************************
Function RemoteCCMShare( PCName, CCMCacheVerz )
'***********************************************************
' 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 : RemoteCCMShare = "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

If not InStr( CCMCacheVerz, WinDir ) = 1 Then
RemoteCCMShare = "Fehler: " & CCMCacheVerz & " befindet sich nicht im %windir%-Verzeichnis" : Exit Function
Exit Function
End If

' MsgBox "WinDir: " & WinDir, , "049 :: " & PCName & " " & WScript.ScriptName

RemoteCCMShare = "\\" & PCName & "\" & Left( CCMCacheVerz, 1 ) & "$" & Mid( CCMCacheVerz, 3 )
' MsgBox "RemoteCCMShare: " & RemoteCCMShare, , "052 :: " & PCName & " " & WScript.ScriptName

Tst = LCase( RemoteCCMShare )
Tst = Replace( Tst, "\System32\", "\SysWOW64\" )
Tst = Replace( Tst, "\system32\", "\SysWOW64\" )
Tst = Replace( Tst, "\SYSTEM32\", "\SysWOW64\" )
If fso.FolderExists( Tst ) Then RemoteCCMShare = Tst

' MsgBox "RemoteCCMShare: " & RemoteCCMShare, , "060 :: " & PCName & " " & WScript.ScriptName

If not fso.FolderExists( RemoteCCMShare ) Then
RemoteCCMShare = "Fehler - Nicht erreichbar: " & RemoteCCMShare
' MsgBox "RemoteCCMShare: " & RemoteCCMShare, , "064 :: " & PCName & " " & WScript.ScriptName
Exit Function
End If

' MsgBox "RemoteCCMShare: " & RemoteCCMShare, , "068 :: " & PCName & " " & WScript.ScriptName
RemoteCCMShare = "Erreichbar: " & RemoteCCMShare

End Function ' RemoteCCMShare( PCName, CCMCacheVerz )


'*** v10.3 *** www.dieseyer.de *****************************
Function SMSCacheLocation( PC )
'***********************************************************

Dim objWMIService : Set objWMIService = GetObject("winmgmts://" & PC & "/root/ccm/SoftMgmtAgent")
Dim colItems : Set colItems = objWMIService.ExecQuery("Select * from CacheConfig")
Dim objItem, errTst, Tst

On Error Resume Next
For Each objItem in colItems
errTst = err.Number & " - " & err.Description
On Error GoTo 0
If Len( errTst ) > 4 Then
SMSCacheLocation = "Fehler: 'CacheConfig' nicht ansprechbar: " & errTst
Exit Function
End If
Tst = 0
On Error Resume Next
Tst = objItem.Size
errTst = err.Number & " - " & err.Description
On Error GoTo 0
If Len( errTst ) > 4 Then
SMSCacheLocation = "Fehler: 'objItem.Size' nicht auslesbar: " & errTst
Exit Function
End If
SMSCacheLocation = objItem.Location
Next
Set objWMIService = nothing
Set colItems = nothing

End Function ' SMSCacheLocation( PC )

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