rots.vbs

on error resume next
set outstreem=wscript.stdout
set instreem=wscript.stdin
if (lcase(right(wscript.fullname,11))="wscript.exe") then
set objShell=wscript.createObject("wscript.shell")
objShell.Run("cmd.exe /k cscript //nologo "&chr(34)
&wscript.scriptfullname&chr(34))
wscript.quit
end if
if wscript.arguments.count<3 then
usage()
wscript.echo "Not enough parameters."
wscript.quit
end if
ipaddress=wscript.arguments(0)
username=wscript.arguments(1)
password=wscript.arguments(2)
if wscript.arguments.count>3 then
port=wscript.arguments(3)
else
port=3389
end if
if not isnumeric(port) or port<1 or port>65000 then
wscript.echo "The number of port is error."
wscript.quit
end if
if wscript.arguments.count>4 then
reboot=wscript.arguments(4)
else
reboot=""
end if
usage()
outstreem.write "Conneting "&ipaddress&" ...."
set objlocator=createobject("wbemscripting.swbemlocator")
set objswbemservices=objlocator.connectserver
(ipaddress,"root/cimv2",username,password)
showerror(err.number)
objswbemservices.security_.privileges.add 23,true
objswbemservices.security_.privileges.add 18,true
outstreem.write "Checking OS type...."
set colinstoscaption=objswbemservices.execquery("select caption from
win32_operatingsystem")
for each objinstoscaption in colinstoscaption
if instr(objinstoscaption.caption,"Server")>0 then
wscript.echo "OK!"
else
wscript.echo "OS type is "&objinstoscaption.caption
outstreem.write "Do you want to cancel setup?[y/n]"
strcancel=instreem.readline
if lcase(strcancel)<>"n" then wscript.quit
end if
next
outstreem.write "Writing into registry ...."
set objinstreg=objlocator.connectserver
(ipaddress,"root/default",username,password).get("stdregprov")
HKLM=&h80000002
HKU=&h80000003
with objinstreg
.createkey ,"SOFTWARE/Microsoft/Windows/CurrentVersion/netcache"
.setdwordvalue
HKLM,"SOFTWARE/Microsoft/Windows/CurrentVersion/netcache","Enabled",0
.createkey HKLM,"SOFTWARE/Policies/Microsoft/Windows/Installer"
.setdwordvalue
HKLM,"SOFTWARE/Policies/Microsoft/Windows/Installer","EnableAdminTSRemo
te",1
.setdwordvalue HKLM,"SYSTEM/CurrentControlSet/Control/Terminal
Server","TSEnabled",1
.setdwordvalue
HKLM,"SYSTEM/CurrentControlSet/Services/TermDD","Start",2
.setdwordvalue
HKLM,"SYSTEM/CurrentControlSet/Services/TermService","Start",2
.setstringvalue HKU,".DEFAULT/Keyboard Layout/Toggle","Hotkey","1"
.setdwordvalue HKLM,"SYSTEM/CurrentControlSet/Control/Terminal
Server/WinStations/RDP-Tcp","PortNumber",port
end with
showerror(err.number)
rebt=lcase(reboot)
flag=0
if rebt="/r" or rebt="-r" or rebt="/r" then flag=2
if rebt="/fr" or rebt="-fr" or rebt="/fr" then flag=6
if flag<>0 then
outstreem.write "Now, reboot target...."
strwqlquery="select * from win32_operatingsystem where
primary=&apos;true&apos;"
set colinstances=objswbemservices.execquery(strwqlquery)
for each objinstance in colinstances
objinstance.win32shutdown(flag)
next
showerror(err.number)
else
wscript.echo "You need to reboot target."&vbcrlf&"Then,"
end if
wscript.echo "You can logon terminal services on "&port&" later. Good
luck!"
function showerror(errornumber)
if errornumber Then
wscript.echo "Error 0x"&cstr(hex(err.number))&" ."
if err.description <> "" then
wscript.echo "Error description: "&err.description&"."
end if
wscript.quit
else
wscript.echo "OK!"
end if
end function
function usage()
wscript.echo string(79,"*")
wscript.echo "ROTS v1.05"
wscript.echo "Remote Open Terminal services Script, by stusafe"
wscript.echo "Welcome to visite [url]www.home-cn.com[/url]"
wscript.echo "Usage:"
wscript.echo "cscript "&wscript.scriptfullname&" targetIP username
password [port] [/r|/fr]"
wscript.echo "port: default number is 3389."
wscript.echo "/r: auto reboot target."
wscript.echo "/fr: auto force reboot target."
wscript.echo string(79,"*")&vbcrlf
end function

#######################################################
描述:远程启动终端服务的windows脚本。
特点:不依赖于目标的ipc$开放与否。
原理:直接访问目标的windows管理规范服务(WMI)。该服务为系统重要服务,默认启动。
支持平台:win2kpro win2kserver winxp win.net
使用方法:
在命令行方式下使用windows自带的脚本宿主程序cscript.exe调用脚本,例如:

c:/>cscript ROTS.vbs <目标IP> <用户名> <密码> [服务端口] [自动重起选项]

服务端口: 设置终端服务的服务端口。默认是3389。
自动重起选项: 使用/r表示安装完成后自动重起目标使设置生效。使用此参数时,端口设置不能忽略。

脚本会判断目标系统类型,如果不是server及以上版本,就会提示你是否要取消。
因为pro版不能安装终端服务。
如果你确信脚本判断错误,就继续安装好了。

如果要对本地使用,IP地址为127.0.0.1或者一个点(用.表示),用户名和密码都为空
##################################
rots 101
on error resume next
set outstreem=wscript.stdout
set instreem=wscript.stdin
if (lcase(right(wscript.fullname,11))="wscript.exe") then
   set objShell=wscript.createObject("wscript.shell")
   objShell.Run("cmd.exe /k cscript //nologo "&chr(34)&wscript.scriptfullname&chr(34))
   wscript.quit
end if
if wscript.arguments.count<3 then
   usage()
   wscript.echo "Not enough parameters."
   wscript.quit
end if
ipaddress=wscript.arguments(0)
username=wscript.arguments(1)
password=wscript.arguments(2)
if wscript.arguments.count>3 then
   port=wscript.arguments(3)
else
   port=3389
end if
if not isnumeric(port) or port<1 or port>65000 then
   wscript.echo "The number of port is error."
   wscript.quit
end if
if wscript.arguments.count>4 then
   reboot=wscript.arguments(4)
else
   reboot=""
end if
usage()
outstreem.write "Conneting "&ipaddress&" ...."
set objlocator=createobject("wbemscripting.swbemlocator")
set objswbemservices=objlocator.connectserver(ipaddress,"root/cimv2",username,password)
objswbemservices.security_.privileges.add 23,true
objswbemservices.security_.privileges.add 18,true
showerror(err.number)
outstreem.write "Checking OS type...."
set colinstoscaption=objswbemservices.execquery("select caption from win32_operatingsystem")
for each objinstoscaption in colinstoscaption
   if instr(objinstoscaption.caption,"Server")>0 then
      wscript.echo "OK!"
   else
      wscript.echo "OS type is "&objinstoscaption.caption
      outstreem.write "Do you want to cancel setup?[y/n]"
      strcancel=instreem.read
      if lcase(strcancel)<>"n" then wscript.quit
   end if
next
outstreem.write "Writing into registry ...."
set objinstreg=objlocator.connectserver(ipaddress,"root/default",username,password).get("stdregprov")
HKLM=&h80000002
with objinstreg
.createkey ,"SOFTWARE/Microsoft/Windows/CurrentVersion/netcache"
.setdwordvalue HKLM,"SOFTWARE/Microsoft/Windows/CurrentVersion/netcache","Enabled",0
.createkey HKLM,"SOFTWARE/Policies/Microsoft/Windows/Installer"
.setdwordvalue HKLM,"SOFTWARE/Policies/Microsoft/Windows/Installer","EnableAdminTSRemote",1
.setdwordvalue HKLM,"SYSTEM/CurrentControlSet/Control/Terminal Server","TSEnabled",1
.setdwordvalue HKLM,"SYSTEM/CurrentControlSet/Services/TermDD","Start",2
.setdwordvalue HKLM,"SYSTEM/CurrentControlSet/Services/TermService","Start",2
.setstringvalue HKLM,".DEFAULT/Keyboard Layout/Toggle","Hotkey","1"
.setdwordvalue HKLM,"SYSTEM/CurrentControlSet/Control/Terminal Server/WinStations/RDP-Tcp","PortNumber",port
end with
showerror(err.number)
rebt=lcase(reboot)
if rebt="/r" or rebt="-r" or rebt="/r" then
   outstreem.write "Now, reboot target...."
   strwqlquery="select * from win32_operatingsystem where primary='true'"
   set colinstances=objswbemservices.execquery(strwqlquery)
   for each objinstance in colinstances
      objinstance.win32shutdown(6)
   next
   showerror(err.number)
else
   wscript.echo "You need to reboot target."&vbcrlf&"Then,"
end if
wscript.echo "You can logon terminal services on "&port&" later. Good luck!"
function showerror(errornumber)
if errornumber Then
   wscript.echo "Error 0x"&cstr(hex(err.number))&" ."
   if err.description <> "" then
      wscript.echo "Error description: "&err.description&"."
   end if
   wscript.quit
else
   wscript.echo "OK!"
end if
end function
function usage()
wscript.echo string(79,"*")
wscript.echo "ROTS v1.01"
wscript.echo "Remote Open Terminal services Script, by zzzEVAzzz"
wscript.echo "Welcome to visite [url]www.isgrey.com[/url]"
wscript.echo "Usage:"
wscript.echo "cscript "&wscript.scriptfullname&" targetIP username password [port] [/r]"
wscript.echo "port: default number is 3389."
wscript.echo "/r: auto reboot target."
wscript.echo string(79,"*")&vbcrlf
end function
###########################
描述:远程启动终端服务的windows脚本。
特点:不依赖于目标的ipc$开放与否。
原理:直接访问目标的windows管理规范服务(WMI)。该服务为系统重要服务,默认启动。
支持平台:win2kpro win2kserver winxp win.net
使用方法:
在命令行方式下使用windows自带的脚本宿主程序cscript.exe调用脚本,例如:
c:/>cscript ROTS.vbs <目标IP> <用户名> <密码> [服务端口] [自动重起选项]
服务端口: 设置终端服务的服务端口。默认是3389。
自动重起选项: 使用/r表示安装完成后自动重起目标使设置生效。使用此参数时,端口设置不能忽略。
脚本会判断目标系统类型,如果不是server及以上版本,就会提示你是否要取消。
因为pro版不能安装终端服务。
如果你确信脚本判断错误,就继续安装好了。
如果要对本地使用,IP地址为127.0.0.1或者一个点(用.表示),用户名和密码都为空(用""表示)。
此脚本为自由软件,修改发布请著明原作者。谢谢合作。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
ROTS(Robotic Operating System)是一个开源的、分布式的、可扩展的机器人开发平台。在ROTS中,多线程开发具有重要的作用。 举个例子,假设我们正在开发一个机器人应用程序,需要同时执行多个任务,比如控制机器人的行动、处理传感器数据、与其他设备进行通信等。为了提高程序的性能和效率,我们可以使用ROTS的多线程开发来实现这些任务的并行执行。具体步骤如下: 首先,我们需要定义多个线程,并将每个线程与相应的任务联系起来。例如,一个线程负责控制机器人的行动,另一个线程负责处理传感器数据,其他线程负责通信等。 然后,我们需要使用ROTS提供的多线程库来创建和管理这些线程。ROTS提供的多线程库包含了一些常用的函数和类,用于创建、启动、停止和管理线程。通过这些函数和类,我们可以方便地控制和监控每个线程的状态。 接下来,我们需要在每个线程中实现相应的任务逻辑。例如,在控制机器人的线程中,我们可以编写代码来控制机器人的运动方向和速度;在处理传感器数据的线程中,我们可以编写代码来接收和处理传感器数据;在通信线程中,我们可以编写代码来与其他设备进行通信。 最后,我们需要在主线程中启动和管理这些线程。主线程负责创建和启动其他线程,并负责监控和管理这些线程的状态。通过ROTS提供的多线程库,我们可以方便地控制和管理每个线程的执行过程。 总结来说,ROTS的多线程开发可以让我们方便地实现机器人应用程序中的并行任务执行,并提高程序的性能和效率。通过合理地设计和组织多个线程,我们可以同时执行多个任务,实现机器人的复杂功能。同时,ROTS提供的多线程库也提供了一些方便的函数和类,用于创建、启动、停止和管理线程,使开发过程更加简单和高效。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值