'以下创建ie对象,以及设置ie对象的一些属性set ie=wscript.createobject("internetexplorer.application","event_")ie.menubar=0 '取消菜单栏ie.addressbar=0 '取消地址栏ie.toolbar=0 '取消工具栏ie.statusbar=0 '取消状态栏ie.width=380 'ie对象宽度ie.height=500 'ie对象高度ie.resizable=0 '不允许用户改变窗口大小ie.navigate "about:blank" '打开空白页面ie.left=fix((ie.document.parentwindow.screen.availwidth-ie.width)/2) '水平居中ie.top=fix((ie.document.parentwindow.screen.availheight-ie.height)/2) '垂直居中ie.visible=1 '窗口可见'以下调用document.write方法,写ie对象内容with ie.document.write "".write "".write " ".write " ".write " ".write "映射远程电脑磁盘 "'ie对象标题.write "".write "".write "
映射远程电脑磁盘
".write "
".write "".write ""end with'以下是设置点击页面按钮时的处理函数set wnd=ie.document.parentwindow '设置wnd为窗口对象set id=ie.document.all '设置id为document中全部对象的集合id.confirm.οnclick=getref("confirm") '设置点击"确定"按钮时的处理函数id.cancel.οnclick=getref("cancel") '设置点击"取消"按钮时的处理函数id.del.οnclick=getref("del") '设置点击单个"删除"按钮时的处理函数id.dels.οnclick=getref("dels") '设置点击全部"删除"按钮时的处理函数id.about.οnclick=getref("about")'设置点击"关于"按钮时的处理函数id.help.οnclick=getref("help")'设置点击"帮助"按钮时的处理函数'由于ie对象支持事件,所以相应的,脚本以无限循环来等待各种事件do while truewscript.sleep 100loop'ie退出事件处理过程sub event_onquitwscript.quit '当ie退出时,脚本也退出end sub'"帮助"按钮处理函数sub helpwnd.alert("错误号5,拒绝访问:很可能你使用的用户不是管理员权限的,先提升权限;"&Chr(10)&"错误号51,Windows无法找到网络路径:网络有问题;"&Chr(10)&"错误号53,找不到网络路径:ip地址错误;目标未开机;目标lanmanserver服务未启动;目标有防火墙(端口过滤); (net start lanmanserver 开启lanmanserver服务)"&Chr(10)&"错误号67,找不到网络名:你的lanmanworkstation服务未启动或者目标删除了ipc$; "&Chr(10)&"错误号1219,提供的凭据与已存在的凭据集冲突:你已经和对方建立了一个ipc$,请删除再连; "&Chr(10)&"错误号1326,未知的用户名或错误密码:原因很明显了; "&Chr(10)&"错误号1792,试图登录,但是网络登录服务没有启动:目标NetLogon服务未启动; "&Chr(10)&"错误号2242,此用户的密码已经过期:目标有帐号策略,强制定期要求更改密码")end sub'"关于"按钮处理函数sub aboutwnd.alert ("此脚本仅供娱乐而已,目前仍存在Bug"&Chr(10)&"如有更好的建议请联系QQ:798776238"&Chr(10)&"作者:sirrah")end sub'单个"删除"按钮处理函数sub delwith idDim strSet objFSO = CreateObject("Scripting.FileSystemObject")Set colDrives = objFSO.Drives'判断删除单个网络映射的盘符输入框是否是空的,如果是空的,给出提示if (.disk3.value="") Then For Each objDrive in colDrives if(objDrive.DriveType=3 ) then str=str & objDrive.DriveLetter & "、" end if Next'判断当前电脑是否存在网络映射 if(str="") then wnd.alert("当前没有网络映射!!!") exit sub end if wnd.alert ("您当前电脑存在的网络驱动器盘符是:" & Left(str,Len(str)-1) & Chr(10)&"请输入相应盘符,并点击删除即可删除该网络驱动器") exit subend if'判断当前输入的盘符是否存在 For Each objDrive in colDrives If (objDrive.DriveType=3 and objDrive.DriveLetter=UCase(.disk3.value)) then on error resume next Set vbs2=CreateObject("Wscript.Shell") vbs2.Run "cmd" wscript.sleep 500 vbs2.SendKeys "net use " & .disk3.value & ": /del" & "{Enter}" vbs2.SendKeys "exit" vbs2.SendKeys "{Enter}" .disk3.value="" Exit sub End If nextwnd.alert ("您当前输入的盘符所对应的网络驱动器不存在,请重新输入!").disk3.value=""end withend sub '全部"删除"按钮处理函数sub dels'判断当前是否存在网络映射Set objFSO = CreateObject("Scripting.FileSystemObject")Set colDrives = objFSO.DrivesFor Each objDrive in colDrivesif(objDrive.DriveType=3) Then '最后验证是否真的需要删除本地所有网络映射 intMessage=msgbox("点击是,您将删除本地所有网络映射,点击否,您将取消删除本地所有网络映射",vbYesNo,"确认是否全部删除") If intMessage=vbYes then on error resume next Set vbs=CreateObject("Wscript.Shell") vbs.Run "cmd" wscript.sleep 500 vbs.SendKeys " net use * /del " & " {enter}" & "Y" & " {enter}" & "exit" & "{Enter}" Exit sub else Exit sub End Ifend If Nextwnd.alert("当前没有网络映射!!!")end Sub '"确认"按钮处理函数sub confirmwith idIf(.ip.value="") thenwnd.alert("请输入IP地址")exit subEnd IfIf(.user.value="") thenwnd.alert("请输入登入用户名")exit subEnd IfIf(.pass.value="") thenwnd.alert("请输入登入密码")exit subEnd IfIf(.disk1.value="") thenwnd.alert("请输入远程盘符")exit subEnd IfIf(.disk2.value="") thenwnd.alert("请输入本地盘符")exit subEnd If'判断映射到本地的盘符是否存在Set objFSO = CreateObject("Scripting.FileSystemObject")Set colDrives = objFSO.DrivesFor Each objDrive in colDrivesIf (objDrive.DriveLetter=UCase(.disk2.value)) thenwnd.alert("对不起,您输入的本地盘符"& .disk2.value &"已存在,请重新输入!!!").disk2.value=""Exit SubEnd IfNext'映射网络驱动器on error resume nextSet vbs1=CreateObject("Wscript.Shell")vbs1.Run "cmd"wscript.sleep 500'建立空链接vbs1.SendKeys "net use \\" & .ip.value & "\ipc$ " & Chr(34) & .pass.value & Chr(34) & " /user:"& Chr(34) & .user.value & Chr(34) & "{enter}"'映射磁盘vbs1.SendKeys "net use " & .disk2.value & ": \\"& .ip.value & "\" & .disk1.value & "$ " & Chr(34)& .pass.value & Chr(34) & " /user:" & Chr(34) & .user.value & Chr(34) & " {enter}"vbs1.SendKeys "exit"vbs1.SendKeys "{Enter}".disk1.value="".disk2.value=""end withend sub'"取消"按钮处理函数sub cancelie.quitend sub