Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how map a drive in a remote computer¿?

Status
Not open for further replies.

RockJona

Programmer
Nov 14, 2008
7
AR
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 :p


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
 
Let's consider the requirements for a mapped drive first... A drive mapping is usually associated with an Interactive Logon. What service and/or user are sustaining the session?

PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top