Rcmd.vbs [Remote Cmd with wmi]远程脚本
来源:本站原创|时间:2020-01-10|栏目:vb|点击: 次
复制代码 代码如下:
On Error Resume Next
Set outstreem=Wscript.stdout
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<4 Then
usage()
Wscript.echo "Not enough Parameters."
Wscript.Quit
End If
ip=Wscript.arguments(0)
username=Wscript.arguments(1)
password=Wscript.arguments(2)
CmdStr=Wscript.arguments(3)
EchoStr=Wscript.arguments(4)
foldername="c:\\windows\\temp\\"
wsh.echo "Conneting "&ip&" ...."
Set objlocator=CreateObject("wbemscripting.swbemlocator")
Set objswbemservices=objlocator.connectserver(ip,"root/cimv2",username,password)
showerror(err.number)
Set Win_Process=objswbemservices.Get("Win32_ProcessStartup")
Set Hide_Windows=Win_Process.SpawnInstance_
Hide_Windows.ShowWindow=12
Set Rcmd=objswbemservices.Get("Win32_Process")
Set colFiles = objswbemservices.ExecQuery _
("Select * from CIM_Datafile Where Name = '"&foldername&"read.vbs'")
If colFiles.Count = 0 Then
wsh.echo "Not found read.vbs! Create Now!"
Create_read()
End If
If EchoStr = "0" Then
msg=Rcmd.create("cmd /c "&CmdStr,Null,Hide_Windows,intProcessID)
Else
msg=Rcmd.create("cmd /c cscript %windir%\temp\read.vbs """&CmdStr&"""",Null,Hide_Windows,intProcessID)
End If
If msg = 0 Then
wsh.echo "Command success..."
Else
showerror(Err.Number)
End If
wsh.echo "Please Wait 3 Second ...."
wsh.sleep(3000)
Set StdOut = Wscript.StdOut
Set oReg=objlocator.connectserver(ip,"root/default",username,password).Get("stdregprov")
oReg.GetMultiStringValue &H80000002,"SOFTWARE\Clients","cmd" ,arrValues
wsh.echo String(79,"*")
wsh.echo cmdstr&Chr(13)&Chr(10)
'wsh.echo arrvalues
For Each strValue In arrValues
StdOut.WriteLine strValue
Next
oReg.DeleteValue &H80000002,"SOFTWARE\Clients","cmd"
Sub Create_read()
RunYN =Rcmd.create("cmd /c echo set ws=WScript.CreateObject(^""WScript.Shell^"")> %windir%\temp\read.vbs"_
&"&&echo str=ws.Exec(^""cmd /c ^""^&wscript.arguments(0)).StdOut.ReadAll:set ws=nothing>> %windir%\temp\read.vbs"_
&"&&echo Set oReg=GetObject(^""winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv^"")>> %windir%\temp\read.vbs"_
&"&&echo oReg.SetMultiStringValue ^&H80000002,^""SOFTWARE\Clients^"",^""cmd^"",Array(str) >> %windir%\temp\read.vbs",Null,Hide_Windows,intProcessID)
If RunYN = 0 Then
wsh.echo "read.vbs Created!!!"
Else
showerror(Err.Number)
End If
End Sub
Function showerroronly(errornumber)
If errornumber Then
wsh.echo "Error 0x"&CStr(Hex(Err.Number))&" ."
If Err.Description <> "" Then
wsh.echo "Error Description: "&Err.Description&"."
End If
Wscript.Quit
Else
outstreem.Write "."
End If
End Function
Sub usage()
wsh.echo string(79,"*")
wsh.echo "Rcmd v1.01 by NetPatch"
wsh.echo "Usage:"
wsh.echo "cscript "&wscript.scriptfullname&" targetIP username password Command"
wsh.echo "cscript "&wscript.scriptfullname&" targetIP username password Command 0 //No echo"
wsh.echo string(79,"*")&vbcrlf
end Sub
上一篇:vbs 字符统计功能模块
栏 目:vb
下一篇:重新安装ie的一个vbs
本文标题:Rcmd.vbs [Remote Cmd with wmi]远程脚本
本文地址:https://www.xiuzhanwang.com/a1/vb/7539.html
您可能感兴趣的文章
- 01-10RCMD使用说明
- 01-10ÓÃvbs½Å±¾ÊµÏÖÔËÐÐDOSÅú´¦Àí²»ÔÙ³öÏÖºÚÆÁcmd´°¿Ú
- 01-10用vbs实现cmd功能
- 01-10用vbs实现cmd功能的代码
- 01-10vbs实现右键菜单中添加CMD HERE
- 01-10用vbs实现cmd多命令运行功能代码
- 01-10用VBS来代替BAT或CMD文件进行命令第1/2页
- 01-10用vbs实现解除注册表CMD、Regedit、Taskmgr限制的脚本代码
- 01-10CMD和vbs修改 IP地址及DNS的实现代码
- 01-10Rcmd.vbs 1.01修正版 增加了下载功能
阅读排行
本栏相关
- 01-10下载文件到本地运行的vbs
- 01-10飘叶千夫指源代码,又称qq刷屏器
- 01-10SendKeys参考文档
- 01-10什么是一个高效的软件
- 01-10VBS中的正则表达式的用法大全 &l
- 01-10exe2swf 工具(Adodb.Stream版)
- 01-10VBS中SendKeys的基本应用
- 01-10用VBSCRIPT控制ONSUBMIT事件
- 01-10VBScript教程 第十一课深入VBScript
- 01-10VBScript语法速查及实例说明
随机阅读
- 01-10SublimeText编译C开发环境设置
- 01-10delphi制作wav文件的方法
- 04-02jquery与jsp,用jquery
- 01-10使用C语言求解扑克牌的顺子及n个骰子
- 08-05dedecms(织梦)副栏目数量限制代码修改
- 01-11Mac OSX 打开原生自带读写NTFS功能(图文
- 08-05织梦dedecms什么时候用栏目交叉功能?
- 01-11ajax实现页面的局部加载
- 01-10C#中split用法实例总结
- 08-05DEDE织梦data目录下的sessions文件夹有什