我调用另一台电脑里面的一个可执行文件,知道其ip地址,用户名,密码,和执行文件所在的路径,然后执行它,这在C#里面怎么实现呢?
多谢高手指点。
多谢高手指点。
解决方案 »
- 用的Visual Studio 2003 2005还是2010
- 我自定义了一个搜索控件,现在想搜索结果分页,怎么办
- GridView控件内某一个TextBox有他的事件吗?有的话请指出如何弄出来?
- 字符串截断
- C# 2.0 弹出菜单问题!
- C#一个windows服务项目如何生成和安装?
- 如何访问控件属性?
- c# 调用并显示wor2000 该怎么做 (搞拉一天都没有出来)
- 如何截取一段字符串碰到第一个非汉字的字符的时候停止截取
- 怎么按这个要求在字符串与字节数组之间转换?
- ***********十一想去河南玩,听说那地方比较刺激,大家说应该注意点什么。谢谢啦***********
- 请问我要用已登陆的用户作条件查询,这样写哪里错了?
#DefineFunction RunRemote(ComputerName,Application,WorkingDirectory,User,Password)
Locator = ObjectOpen("WbemScripting.SWbemLocator")
Service = Locator.ConnectServer(ComputerName,"root/cimv2",User,Password)
Security = Service.Security_
Security.ImpersonationLevel = 3
Class = Service.Get("Win32_Process")
If WorkingDirectory == "" then
Result = Class.Create(Application) ;no working directory specified
Else
Result = Class.Create(Application,WorkingDirectory) ;pass the specified working directory
EndIf
ObjectClose(Class)
ObjectClose(Security)
ObjectClose(Service)
ObjectClose(Locator)
Return Result
#EndFunctionComputerName = "SCOOBY" ;remote machine name (specify "" for local machine)
Application = "Notepad.exe"
WorkDir = ""
User = ""
Password = ""
rslt = RunRemote(ComputerName,Application,WorkDir,User,Password)
Switch rslt
Case 0
Message("RunRemote","Successful completion ")
break
Case 2
Message("RunRemote","Access denied")
break
Case 3
Message("RunRemote","Insufficient privilege")
break
Case 8
Message("RunRemote","Unknown failure")
break
Case 9
Message("RunRemote","Path not found")
break
Case 21
Message("RunRemote","Invalid parameter")
break
Case rslt
Message("RunRemote","Unknown error")
breakEndSwitchexit
该代码摘自:
http://techsupt.windowware.com/TS/T000001002F15.html
ManagementOperationObserver obs=new ManagementOperationObserver();
ConnectionOptions co=new ConnectionOptions();
/*co.Username="Administrator";
co.Password="";*/
ManagementScope ms=new ManagementScope(@"\\chf-13758681208\root\cimv2",co);
ManagementPath path = new ManagementPath( "Win32_Process");
ManagementClass mcs=new ManagementClass(ms,path,null);
object[] param=new object[]{"notepad.exe",null,null,0};
mcs.InvokeMethod(obs,"Create",param);
bat 如下:
net use x: \\computername\c$ /USER:administrator 123456
x:\app.exe然后在C#里面调用这个bat就行了