Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares.
They application is written in VB.NET targeting the .NET framework 2.0.
Usage
Enter a computername, Share Name, Share Path and Share Description if needed
You can get a list of shares by pressing the Show button
You can Create a share if the necessary information has been filled in by pressing Create
You can Remove a share by selecting the share and pressing Remove
You can Open the share by dubbleclicking on the share listed in the listbox
Screenshots
GUI Version Remote Share
Commandline Version Remote Share
Main Functions
Public Sub CreateShare(ByVal strShareName As String, ByVal strPath As String, ByVal computername As String, ByVal shareinfo As String)
Try
Dim objSWbemServices As Object
Dim objSWbemObject As Object
Dim colSWbemObject As Object
Dim intRet As Integer
Dim blnExists As Boolean
Dim objSWbem As Object
objSWbemServices = GetObject("winmgmts://" + computername + "/root/cimv2")
colSWbemObject = objSWbemServices.InstancesOf("Win32_Share")
For Each objSWbem In colSWbemObject
If (objSWbem.name = strShareName) Then
blnExists = True
Exit For
Else
blnExists = False
End If
Next
If (blnExists = False) Then
objSWbemObject = objSWbemServices.Get("Win32_Share")
intRet = objSWbemObject.Create(strPath, strShareName, 0, 25, shareinfo)
Else
MsgBox("Folder aready shared")
End If
Catch ex As Exception
MsgBox("Error occured while trying to create shares on remote pc." + vbCrLf + "Check if you have the necessary rights and/or that the pc is turned on." + vbCrLf + ex.ToString)
End Try
End Sub
'
Public Function ShowShares(ByVal ComputerName) As Boolean
Try
ListView1.Items.Clear()
Dim objSWbemServices As Object
Dim colSWbemObject As Object
objSWbemServices = GetObject("winmgmts://" + ComputerName + "/root/cimv2")
colSWbemObject = objSWbemServices.InstancesOf("Win32_Share")
' Loop through each share on the machine to see if it already exists
For Each objSWbem In colSWbemObject
Dim lvitem As New ListViewItem
With lvitem
.Text = objSWbem.name
.SubItems.Add(objSWbem.path)
.SubItems.Add(objSWbem.description)
End With
ListView1.Items.Add(lvitem)
Next
Catch ex As Exception
MsgBox("Error occured while trying to show shares on remote pc." + vbCrLf + "Check if you have the necessary rights and/or that the pc is turned on." + vbCrLf + ex.ToString)
End Try
End Function
Public Function RemoveShare(ByVal shareName As String, ByVal computername As String) As Boolean
Try
Dim objSWbemServices As Object
Dim objSWbemObject As Object
Dim colSWbemObject As Object
objSWbemServices = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & computername & "\root\cimv2")
colSWbemObject = objSWbemServices.ExecQuery("SELECT * FROM Win32_Share WHERE Name = '" + shareName + "'")
For Each objSWbemObject In colSWbemObject
objSWbemObject.Delete()
Next
Catch ex As Exception
MsgBox("Error occured while trying to remove shares on remote pc." + vbCrLf + "Check if you have the necessary rights and/or that the pc is turned on." + vbCrLf + ex.ToString)
End Try
End Function
Files
Download Remote Share GUI
Download Remote Share
Source Files (VB.NET 2008)
Download Source Remote Share GUI
Download Source Remote Share
Posts
Article Posted on Expert Exchange
Article Posted on CodeProject
No comments:
Post a Comment