Hi, I have been searching about this, but I can't find anything... I've got a code, but it doesn't map remotely, it does locally I need connect to Xserver and Map Xdrive. please if someone knows could help me please?
this is my code:
1. reads from a file "list.txt" a list of computer
2. create a connection with the computer one by one
3. try to do the mapping, obviously here is my mistake, I think
Const WbemAuthenticationLevelPktPrivacy = 6
strComputer = "xxx"
strNamespace = "root\cimv2"
strUser = InputBox ("Username: ")
strPassword= inputbox ("Password: ")
Set objWbemLocator = reateObject("WbemScripting.SWbemLocator")
Set objList = objFSO.OpenTextFile("j:\vbscripts\remoteinstall\" & "list.txt",1, True)
Do While not objlist.AtEndOfStream
strComputer = objlist.ReadLine
call gotoserver(strComputer)
Loop
objlist.close
Wscript.Echo "Done!!!"
'---------------------------------------------------------------------------------
Public Function gotoserver(strComputer)
on error resume next
Set objWMIService = objwbemLocator.ConnectServer(strComputer, strNamespace, strUser, strPassword)
objWMIService.Security_.authenticationLevel = WbemAuthenticationLevelPktPrivacy
strServiceName = "Select * From Win32_LogicalDisk Where DeviceID = 'X:'"
Set colServiceList = objWMIService.ExecQuery (strServiceName)
If colItems.Count = 0 Then
Set objNetwork = CreateObject("Wscript.Network")
objNetwork.MapNetworkDrive "X:", "\\Xfolder\Xsubfolder"
End If
end function
this is my code:
1. reads from a file "list.txt" a list of computer
2. create a connection with the computer one by one
3. try to do the mapping, obviously here is my mistake, I think
Const WbemAuthenticationLevelPktPrivacy = 6
strComputer = "xxx"
strNamespace = "root\cimv2"
strUser = InputBox ("Username: ")
strPassword= inputbox ("Password: ")
Set objWbemLocator = reateObject("WbemScripting.SWbemLocator")
Set objList = objFSO.OpenTextFile("j:\vbscripts\remoteinstall\" & "list.txt",1, True)
Do While not objlist.AtEndOfStream
strComputer = objlist.ReadLine
call gotoserver(strComputer)
Loop
objlist.close
Wscript.Echo "Done!!!"
'---------------------------------------------------------------------------------
Public Function gotoserver(strComputer)
on error resume next
Set objWMIService = objwbemLocator.ConnectServer(strComputer, strNamespace, strUser, strPassword)
objWMIService.Security_.authenticationLevel = WbemAuthenticationLevelPktPrivacy
strServiceName = "Select * From Win32_LogicalDisk Where DeviceID = 'X:'"
Set colServiceList = objWMIService.ExecQuery (strServiceName)
If colItems.Count = 0 Then
Set objNetwork = CreateObject("Wscript.Network")
objNetwork.MapNetworkDrive "X:", "\\Xfolder\Xsubfolder"
End If
end function