Click here to Skip to main content
16,016,669 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good afternoon,

I have a script that when you enter the machine name it will open a explorer window and connect to the remote machines temp folder.

I m currently writing an application that i want to include that in a button click.
I have declared the machine name. Here is my code.


VB
 Private Sub UNC_Menuitem1_Click(ByVal sender As System.Object, e As System.EventArgs) Handles UNC_MenuItem1.Click

        strComputer = Machine_Name_Textbox_Header.Text
        objWshShell = CreateObject("Wscript.Shell")
        objWshShell.run("explorer.exe \\" + strComputer + "\c$")

End Sub


I get the explorer window to open up but i cant get it to do it to the remote machine. Any help would be great on how i can have a button click open a explorer windows to another machines temp folder.
Posted
Updated 7-Dec-11 8:08am
v2
Comments
Wendelius 7-Dec-11 14:08pm    
Pre tags added

I figured it out. I found 2 ways. Hope this help

First way:

Dim Path As String

strComputer = MachineNameTextBox.Text

If strComputer = "" Then
strComputer = "Localhost"
End If

Path = "\\" & strComputer & "\c$\Windows\System32\drivers\etc"
Dim objshell = CreateObject("wscript.shell")
objshell.run(Path)

Second Way

Dim p As New Process()
strComputer = MachineNameTextBox.Text

If strComputer = "" Then
strComputer = "Localhost"
End If

p.StartInfo.FileName = "explorer.exe "
p.StartInfo.Arguments = "-e,-root,\\" & strComputer & "\c$\users"
p.Start()
 
Share this answer
 
One thing is that if your using administrative shares such as c$, do you have proper privileges (admin) to access it on the remote machine?
 
Share this answer
 
Comments
Zachary.shupp 7-Dec-11 14:41pm    
Yes the application will be running with admin rights.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900