十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
搞啥呢,strServer1是变量且有赋值为:strServer1 = "dc2";
创新互联是一家专注于网站设计制作、成都网站建设与策划设计,虎丘网站建设哪家好?创新互联做网站,专注于网站建设十多年,网设计领域的专业建站公司;建站业务涵盖:虎丘等地区。虎丘做网站价格咨询:18982081108
所以WSHNetwork.MapNetworkDrive "x:", "\\" strServer1 "\子公司"就能执行
而strServer2的赋值语句在哪儿?俺没看见,所以俺要求WSHNetwork.MapNetworkDrive "z:", "\\" strServer2 "\集团公司"不能被执行,一个找不到服务器的mapping语句直接报错,你可以显示下errorcode去确定下。
同理strServer3也没有被赋值。
Shell "cmd /c net use Z: \\server\share\" StrT " 123456 /user:share /p:n"
文件镜像功能吧, 监控文件的变化然后实时同步就行了 .. 好像是叫那个filewatcher类,可以做
”VBS脚本“可以用任何纯
文本编辑
工具编写,包括系统自带的”记事本“。VB.NET当然也可以。
如果你是需要语法提示之类的,VB.NET可以提供绝大部分的语法提示。毕竟
VBS
是
VB
的子集。
本来可以用简单的dos命令的,但是影射成功与否返回不理想,建议用API,见下面
Module LocalNetConnect'模块,直接复制即可
Public Declare Function WNetAddConnection2 Lib "mpr.dll" Alias "WNetAddConnection2A" (ByRef lpNetResource As NETRESOURCE, ByVal lpPassword As String, ByVal lpUserName As String, ByVal dwFlags As Integer) As Integer
Public Declare Function WNetCancelConnection2 Lib "mpr.dll" Alias "WNetCancelConnection2A" (ByVal lpName As String, ByVal dwFlags As Integer, ByVal fForce As Integer) As Integer
Public Structure NETRESOURCE
Dim dwScope As Integer
Dim dwType As Integer
Dim dwDisplayType As Integer
Dim dwUsage As Integer
Dim lpLocalName As String
Dim lpRemoteName As String
Dim lpComment As String
Dim lpProvider As String
End Structure
Public Function netconnect(ByVal localDrive As String, ByVal sharePath As String, ByVal userName As String, ByVal UserPassword As String) As Boolean
Dim NetR As New NETRESOURCE
Dim ErrInfo As Integer
NetR.dwScope = 2
NetR.dwType = 1
NetR.dwDisplayType = 3
NetR.dwUsage = 1
'设置驱动器
NetR.lpLocalName = localDrive
'设置远程端口名字
NetR.lpRemoteName = sharePath
'设置连接
ErrInfo = WNetAddConnection2(NetR, UserPassword, userName, 1)
If ErrInfo = 0 Then
Return True
Else
Return False
End If
End Function
Public Function netdisconnect(ByVal localDrive As String) As Boolean
Dim ErrInfo As Integer
ErrInfo = WNetCancelConnection2(localDrive, 1, False)
If ErrInfo = 0 Then
Return True
Else
Return False
End If
End Function
End Module
‘调用
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'这里是映射调用,administrator为用户名,根据实际用户名
’如果将“Z:”设置为空就不会网络盘映射但是已经和172.26.120.47联机了(返回真时成立)。
If netconnect("Z:", "\\172.26.120.47\c$", "administrator", "局域网电脑实际密码") = True Then
MsgBox("success")
Else
MsgBox("Faile")
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click'这里是取消映射
If netdisconnect("Z:") = True Then
MsgBox("success")
Else
MsgBox("Faile")
End If
End Sub
非也,乃微软新一代面向对象可视化编程语言。另外,vb.net和vb6.0及以前版本都有很大差别。属.net平台。.net framework现在最新的版本是3.5,建议你学习2.0版本即可,有机会再看看3.5。