请教一个WMI远程bat 执行命令结果,获取命令输出结果

温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
阅读(5545)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'ssh 执行远程命令,所有命令都存放在变量里面',
blogAbstract:' &&&& 今天改写脚本程序,调试了一下午,频繁报错,搞得我的灰心了,不过最后终于调通了,把今天的关键问题贴出来,以后方便查阅,文章最后面是害苦了我的一段脚本,红色字体标注部分调了两个小时才调成功! 使用ssh执行远程命令,我们只要在主机名后面将要执行的远程主机上的命令使用单引号或者双引号括起来就行了 e.g: 查看192.168.1.1上面的进程可以使用下面的命令 ssh -p22
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}c#中可以通过wmi在远程机上执行命令(wmi:;//ManagementPath包装了生成和分析;ManagementPathmngPath=ne;ManagementScopescope=new;//ObjectGetOptions类是指定用于;//ManagementClass是表示公共信息;ManagementClassclassInst;objec
c#中可以通过wmi在远程机上执行命令(wmi:windows management interface 可以通过一个公共的接口访问不同操作系统(windows系统)的构成单元,利用它可以高效的管理远程和本地的计算机。它也是w2k3,w2k8和xp的管理系统的控制核心),下面是完成这个工作的示范代码:
//////////////////////////////////////////////////////////////////////////////////////////////////
//ConnectionOptions指定生成wmi连接所需的设置
ConnectionOptions connOption = new ConnectionOptions();
connOption.Username = domain + @\
connOption.Password =
//ManagementPath 包装了生成和分析wmi对象的路径
ManagementPath mngPath = new ManagementPath(@\@\
ManagementScope scope = new ManagementScope(mngPath, connOption);
scope.Connect();
//ObjectGetOptions 类是指定用于获取管理对象的选项
ObjectGetOptions objOption = new ObjectGetOptions();
//ManagementClass 是表示公共信息模型 (CIM) 管理类,通过该类的成员,可以使用特定的 WMI 类路径访问 WMI 数据
ManagementClass classInstance = new ManagementClass(scope, mngPath, objOption);
int ProcessId = 0;
object[] cmdline = { \
//调用执行命令的方法
classInstance.InvokeMethod(\
其中domain是登陆远程机的域名,userName,password是登陆远程机的帐户密码。
serverHostName是要访问的远程机名或者IP。
strCommand是需要在远程机上面执行的命令。
//////////////////////////////////////////////////////////////////////////////////////////////////
c#中还可以通过使用 HTTP 协议传输消息的客户端信道,来实现远程调用,下面是示范代码:
//首先建立信道,并注册信道服务
HttpChannel c = new HttpChannel();
ChannelServices.RegisterChannel(c, false);
//然后调用可执行文件执行操作
object remoteObject = Activator.GetObject(Type.GetType(RemoteObject), remoteObjectURL);
RemoteObject marshalObj = (RemoteObject)remoteO
marshalObj.RunCommand(ExeFilePath);
//关闭信道
ChannelServices.UnregisterChannel(c);
public class RemoteObject:MarshalByRefObject
public string RunCommand(string cmd)
Process p=new Process();
p.StartInfo.FileName=\
p.StartInfo.UseShellExecute=
p.StartInfo.RedirectStandardInput=
p.StartInfo.RedirectStandardOutput=
p.StartInfo.RedirectStandardError=
p.StartInfo.CreateNoWindow=
p.Start();
p.StandardInput.WriteLine(cmd);
p.StandardInput.WriteLine(\
p.Close();
三亿文库3y.uu456.com包含各类专业文献、专业论文、文学作品欣赏、外语学习资料、中学教育、58c#通过wmi在远程机上执行命令等内容。 
 目前网络管理软件通常的做法是, 在远程计算机上运行客户端后台程式,在本地计算机...其所使用的就是 WMI, 下面是 Visual C#中利用 WMI 控制远程计算机具体实现步骤...  WMI远程控制程序开发_IT/计算机_专业资料。通过VB语言...脚本语言替代原来的批命令,同时提供了一 个供 ...注意:在 Windows NT 4.0 上安装并运行 WMI 之前,...  使用C#控制远程计算机的服务 控制远程计算机的服务作者:郑佐
在.net...命名空间下面的 ServiceController 类, System.Management 下面的一些 WMI 操作的...  通过WMI 远程采集 Windows 日志 作者:空灵 1. 在 Windows 主机上创建用户,并...运行 dcomcnfg.exe 命令 更改 splunkag 用户 COM 安全权限,点击“组件服务”-...  WMI远程访问_计算机软件及应用_IT/计算机_专业资料。如何在 C# 中使用 WMI 实现...现在的运行状态等,我们没有全部列举出来,感兴趣的话您可以自//己试试 listBox...  WMIC 扩展 WMI(Windows Management Instrumentation ,Windows...:密码&的形 式可以登录到远程主机执行 wmic 命令。...没有在该机执行Windows脚... 8页 免费
window...  WMI监控管理远程主机配置,包括监控端配置,被监控端...机: VMware 此次配置主要是针对两台机器通过 WMI ...在命令提示符执行以下命令: Windows 2003/XP * c:...  过程调用)协议之上的, 所以,使用 WMI 监控远程机器...也可以用下面的命令来代替,可以起到同样的效果: ...被监控本身保存在本机上的域信息中只保留了登录过...温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
using System.Collections.Gusing System.Lusing System.Tusing System.Musing System.Tnamespace ConsoleApplication10{&& &class Program&& &{&& & & &&& & & &public static void f(string command)&& & & &{&& & & & & &ConnectionOptions connOption = new ConnectionOptions();&& & & & & &connOption.Username = @"\" + "administrator";&& & & & & &connOption.Password = "server";&& & & & & &ManagementPath mngPath = new ManagementPath(@"\\" + "10.100.100.68" + @"\root\cimv2:Win32_Process");&& & & & & &// connOption.Username = @"\" + "haha";&& & & & & &//connOption.Password = "haha";&& & & & & &//ManagementPath 包装了生成和分析wmi对象的路径&& & & & & &// ManagementPath mngPath = new ManagementPath(@"\\" + "10.30.10.119" + @"\root\cimv2:Win32_Process");&& & & & & &ManagementScope scope = new ManagementScope(mngPath, connOption);&& & & & & &scope.Connect();&& & & & & &//ObjectGetOptions 类是指定用于获取管理对象的选项&& & & & & &ObjectGetOptions objOption = new ObjectGetOptions();&& & & & & &//ManagementClass 是表示公共信息模型 (CIM) 管理类,通过该类的成员,可以使用特定的 WMI 类路径访问 WMI 数据&& & & & & &ManagementClass classInstance = new ManagementClass(scope, mngPath, objOption);&& & & & & &int ProcessId = 1;&& & & & & &object[] cmdline = { "cmd &/c" + command, "c:\\", null, ProcessId };&& & & & & &//调用执行命令的方法\&& & & & & &Object str = classInstance.InvokeMethod("Create", cmdline);&& & & & & &String errorStr = "";&& & & & & &Console.WriteLine(int.Parse(str.ToString()));&& & & & & &switch (int.Parse(str.ToString()))&& & & & & &{&& & & & & & & &case 2:&& & & & & & & & & &errorStr = "Access denied";&& & & & & & & & & &&& & & & & & & &case 3:&& & & & & & & & & &errorStr = "Insufficient privilege";&& & & & & & & & & &&& & & & & & & &case 6:&& & & & & & & & & &errorStr = "Unknown failure";&& & & & & & & & & &&& & & & & & & &case 9:&& & & & & & & & & &errorStr = "Path not found";&& & & & & & & & & &&& & & & & & & &case 21:&& & & & & & & & & &errorStr = "Invalid parameter";&& & & & & & & & & &&& & & & & & & &case 0:&& & & & & & & & & &errorStr = "OK";&& & & & & & & & & &&& & & & & & & &default:&& & & & & & & & & &errorStr = "unknow";&& & & & & & & & & &&& & & & & &}&& & & & & &Console.WriteLine(errorStr);&& & & &}&& & & &static void Main(string[] args)&& & & &{&& & & & & &string command = "md wenjian";&& & & & & &Console.WriteLine("正在创建文件夹");&& & & & & &f(command);&& & & & & & Console.WriteLine("正在删除文件夹");&& & & & & & Thread.Sleep(1000);&& & & & & & command = "rd wenjian";&& & & & & & f(command);&& & & & & &&&& & & &}&& & & &&& & &&& &}}
阅读(1549)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'wmi执行dos命令',
blogAbstract:'using Susing System.Collections.Gusing System.Lusing System.Tusing System.Musing System.Tnamespace ConsoleApplication10{&& &class Program&& &{&& & & &&& & & &public static void f(string command)',
blogTag:'',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:4,
publishTime:1,
permalink:'blog/static/',
commentCount:0,
mainCommentCount:0,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'',
hmcon:'1',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}wmi协议支持远程执行cmd命令,并返回获取命令相关信息
一、vbs:WMI远程控制机器时报0x拒绝访问错误的解决方法
昨天晚上学习一个WMI远程连接机器的方法,可是始终报错,错误代码为0x;拒绝访问,今天上午看到别人的...
问题 1:WMI 是什么,它能帮我做什么?
问题 2: WMI 适用于那些平台?
问题 3:如果 WMI 向外界暴露特定的功能,我如何才能知道?
问题 4:如果 WMI 没有提供我想要的功能,我...
本文主要介绍如何使用WMI执行方法。
1. 使用os.system("cmd")
特点是执行的时候程序会打出cmd在Linux上执行的信息。
os.system("ls")
2. 使用Popen模块...
转:http://zhaoningbo.iteye.com/blog/1553314
最近两次被网友问到,关于java运行dos命令的问题。一个是问能不能,一个是反映他写的程序执行...
在VC下执行DOS命令并得到输出(转)
http://topic.csdn.net/u//-43f3--f...
在项目中,将本地C盘的一个文件夹使用subst命令映射成了X盘,在C#代码中需要获取这个X盘在C盘中的真实路径。但是在C#中并没有找到相应的接口来获取这个结果,或许是我没有找到。在DOS中有命令sub...
a. system("md c://12");
1) 调用命令时会出现一个dos窗口一闪而过,影响视觉效果。
2 )无法将命令的执行结果反馈给用户。
b. WinEx...
他的最新文章
他的热门文章
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)c#通过wmi在远程机上执行命令_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
c#通过wmi在远程机上执行命令
&&c#通过wmi在远程机上执行命令
阅读已结束,下载文档到电脑
想免费下载本文?
定制HR最喜欢的简历
你可能喜欢}

我要回帖

更多关于 php 执行命令并输出 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信