网站首页
网站导航
Ctrl+D收藏
首 页
代码段
源码包
文档库
工具箱
代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
VBS
】
VBS远程主机共享设置
作者:
dezai
/ 发布于
2014-1-21
/
432
'///////code by youxi01@bbs.bathome.net '//////早期作品; '/////依赖rpc on error resume next if (lcase(right(wscript.fullname,11))="wscript.exe") then set objShell=wscript.createObject("wscript.shell") objShell.Run("cmd.exe /k title 远程主机共享"&"& cscript //nologo " &wscript.scriptfullname) wscript.quit end if dim objconnect connect() sub connect() wscript.echo " #欢迎使用# " wscript.echo "**************************************" wscript.echo "#请输入远程主机名或IP地址#" strcomputer=wscript.stdin.readline set objShell=wscript.createObject("wscript.shell") set objexec=objShell.exec("ping -n 2 -w 1000 "&strcomputer) if instr(objexec.stdout.readall,"Reply from") then wscript.echo wscript.echo "#请输入用户名:" username=wscript.stdin.readline wscript.echo wscript.echo "#请输入密码:" pass=wscript.stdin.readline wscript.echo "#正在列举共享,请等待...." set obj=createobject("wbemscripting.swbemlocator") set objconnect=obj.connectserver(strcomputer,"root\cimv2",username,pass) for each ps in objconnect.execquery("select * from win32_logicaldisk where description='本地固定磁盘'") cnt=objconnect.execquery("select * from win32_share where name='"&left(ps.name,1)&"$'").count if cnt>0 then share=share+"固定磁盘"+vbtab+ps.volumename+" "+ps.name&vbcrlf else noshare=noshare+vbcrlf+"固定磁盘"+vbtab+ps.volumename+" "+ps.name end if next if noshare="" then wscript.echo "**************************************" wscript.echo "#所有的磁盘已经共享:"&vbcrlf&share else wscript.echo "**************************************" wscript.echo "#已经共享的磁盘:"&vbcrlf&vbcrlf&share wscript.echo "**************************************" wscript.echo "#未共享的磁盘:"&vbcrlf&noshare wscript.echo "**************************************" end if choice() else wscript.echo "远程主机: "&chr(34)&strcomputer&chr(34)&" ping不通." choice() end if end sub sub setshare() wscript.echo "**************************************" wscript.echo "请输入需要共享的磁盘" input=wscript.stdin.readline input=left(input,1) input1=input&":" set share=objconnect.get("win32_share") errreturn=share.create(input1&"\",input&"$",0,10,"默认共享") if errreturn=0 then wscript.echo input&": 共享成功" choice() elseif errreturn=22 then wscript.echo input &": 共享失败,该共享已经存在" choice() elseif errreturn=24 then wscript.echo input &": 共享失败,该盘符不存在" choice() else wscript.echo input &": 共享失败,存在未知错误" choice() end if end sub sub choice() wscript.echo "**************************************" wscript.echo "请输入指令:" wscript.echo "A、添加共享" wscript.echo "D、删除共享" wscript.echo "L、列举共享" wscript.echo "C、重新连接" wscript.echo "Q、退出" input=wscript.stdin.readline if ucase(input)="Q" then wscript.quit elseif ucase(input)="D" then delshare() elseif ucase(input)="A" then setshare() elseif ucase(input)="L" then listshare() elseif ucase(input)="C" then connect() else wscript.echo "未知的服务" choice() end if end sub sub delshare() wscript.echo "请输入要删除的盘符名:" input=wscript.stdin.readline input=left(input,1) input1=input&"$" for each ps in objconnect.execquery("select * from win32_share where name='"&input1&"'") errreturn=ps.delete next if errreturn=0 then wscript.echo input1&" 成功删除" choice() else wscript.echo input&" 删除失败,发生未知错误 " choice() end if end sub sub listshare() for each drive in objconnect.execquery("select * from win32_share where description='默认共享'") share1=share1+"固定磁盘:"+vbtab+left(drive.name,1)&":"+vbcrlf next if share1="" then wscript.echo vbcrlf&"没有共享" else wscript.echo "**************************************" wscript.echo vbcrlf&"已经存在的共享有:"&vbcrlf&share1 end if choice() end sub
评论列表
本站所提供的代码,版权归原作者所有,若有侵犯作者版权,请与我们联系,我们将立即删除或修改。谢谢!
本站所有代码发布及提供者。
试试其它关键字
远程主机共享
同语言下
.
使用脚本将域账号添加到客户机的本地管理员组
.
删除服务器上文件
.
主动ping服务器是否宕机
.
自动 服务器检查 的vbs脚本
.
VBS脚本发送邮件,密送多人,带附件,可更换账号密码
.
根据文件路径复制文件
.
VBA操作数据库
.
双击获取公网IP到剪贴板
.
定时运行ie浏览执行网址不显示浏览器窗口
.
批处理生成日历
可能有用的
.
python 抓取搜狗指定公众号
.
屏幕中间的弹框列表
.
json下钻函数,解决多层嵌套问题
.
pandas读取指定列
.
队列的顺序存储实现和栈的链式实现
.
多线程(Runtime类、Timer计时器)
.
任意字符串前后互换、100以内素数
.
实现队列的操作
.
数组去重,记录数组元素角标
.
input框强制输入整百的数
dezai
贡献的其它代码
(
1065
)
.
双色球
.
列出所有物理网络适配器
.
快乐数的 Python 实现
.
计算当月还剩天数
.
猜属相
.
二十四小时时钟
.
每日一语
.
很酷的日历
.
超长日历表单
.
最简单的时钟
地图
本站
我们
服务
版权
联系
回馈
博客