Option ExplicitPrivate Sub Command1_Click() 'Share Dim WshShell As IWshShell Set WshShell = CreateObject("WScript.Shell") WshShell.Run "net share ShareTesting=C:", 0, True Set WshShell = Nothing MsgBox ("OK") End SubPrivate Sub Command2_Click() 'Unshare Dim WshShell As IWshShell Set WshShell = CreateObject("WScript.Shell") WshShell.Run "net share ShareTesting /delete", 0, True Set WshShell = Nothing MsgBox ("OK") End Sub
Dim WshShell As IWshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "net share ShareTesting=C:", 0, True
Set WshShell = Nothing
MsgBox ("OK")
End SubPrivate Sub Command2_Click() 'Unshare
Dim WshShell As IWshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "net share ShareTesting /delete", 0, True
Set WshShell = Nothing
MsgBox ("OK")
End Sub
(10)Net Share
作 用:创建、删除或显示共享资源。
命令格式:net share sharename=drive:path [/users:number | /unlimited] [/re:"text"]
参数介绍:
<1>键入不带参数的net share显示本地计算机上所有共享资源的信息。
<2>sharename是共享资源的网络名称。
<3>drive:path指定共享目录的绝对路径。
<4>/users:number设置可同时访问共享资源的最大用户数。
<5>/unlimited不限制同时访问共享资源的用户数。
<6>/re:"text "添加关于资源的注释,注释文字用引号引住。
简单事例:
<1>net share mylove=c:\temp /re:"my first share"以mylove为共享名共享C:\temp
<2>net share mylove /delete停止共享mylove目录