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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conntect to a remote drive

Status
Not open for further replies.

ConfusedScript

IS-IT--Management
Feb 11, 2008
2
US
Hey all....What I am trying to do is connect to the c (or d) drive of another pc on my network. Using a batch file I was able to just do Start explorer \\%targetpc%\C$
But I wanted to convert my batch file into a vbscript (eventually in hta...but one step at a time).
What I have is the following....can anyone see anything wrong with this? I left out the part where I prompt the user for the pc name to cut the size down.
Sub MapC()
Set objShell=CreateObject("Wscript.Shell")
Set objNetwork=CreateObject("Wscript.Network")
strremotedrive = "\\" & strcomputer & "\C$"
objShell.run("Explorer" & " " & strremotedrive & "\")
End Sub

Now this works...but is it doing something that I don't see(like leaving an open connection, etc...)?
THanks!
 
>Now this works...but is it doing something that I don't see(like leaving an open connection, etc...)?
If you run lanmanserver to list all the sessions, you might identify it?
[tt]
set olmsvr=getobject("WinNT://" & strComputer & "/LanmanServer")
for each osession in olmsvr.sessions
wscript.echo osession.name
next
set olmsvr=nothing
[/tt]
 
Ok so I do not need the set objnetwork=createobject ("wscript.networ") line....can anyone see anything wrong with this or is there a better way to take the batch command and make it into vbscript?
Thanks
 
If you are not concerned with something that I don't see(like leaving an open connection, etc...)? that I was trying to answer, and that you are only feeling uncomfortable with your line
> Set objNetwork=CreateObject("Wscript.Network")
then, absolutely, delete the line. It means nothing there except people want to inflat a script to make it look big.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top