关闭远程计算机
把电脑当服务器用asp.net做了一网站,现在电脑能被远程关机,但是还要用另外一台联网的电脑才行。我的网站能用手机登陆,于是在网站上做了一网页,用vb里的shell方法调用cmd里的shutdown命令让我的电脑关机,想用手机登陆该网页就能使自己的电脑关机,但是又提示权限不够,不能调用外部程序,请问怎么设置ASP和IIS的权限,或者有没有其他方法。最终要实现用手机登陆我电脑服务器上的网站的一个网页,按下该网页上的一按钮就能关闭我的电脑(指服务器,不是客户端!)。请大侠们给出的代码最好是vb的,谢了! --------------------编程问答-------------------- 在服务器上放一个关机p处理执行文件,发送指令启动执行文件,让服务器自己关机 --------------------编程问答-------------------- 试过了,不行! --------------------编程问答-------------------- 服务器安全设置里面支持p处理关机吗(类似这样的设置)? --------------------编程问答-------------------- 不知道怎么设置! --------------------编程问答-------------------- C# :
ConnectionOptions ConOptions = new ConnectionOptions();
ConOptions.Username = "{AdminUser} ";
ConOptions.Password = "{myPassword} ";
ConOptions.EnablePrivileges = true;
ManagementScope scope = new ManagementScope( "\\\\{Target}\\root\\cimv2 ", ConOptions);
scope.Connect();
ObjectQuery OQuery = new ObjectQuery( "Select * From Win32_OperatingSystem Where Primary = true ");
ManagementObjectSearcher OSearcher = new ManagementObjectSearcher(scope, OQuery);
foreach(ManagementObject MO in OSearcher.Get())
{
MO.InvokeMethod( "Reboot ", null);
}
MessageBox.Show( "Restart? ");
VB.NET:
Dim ConOptions As ConnectionOptions = New ConnectionOptions
ConOptions.Username = "{AdminUser} "
ConOptions.Password = "{myPassword} "
ConOptions.EnablePrivileges = True
Dim scope As ManagementScope = New ManagementScope( "\\{Target}\root\cimv2 ", ConOptions)
scope.Connect()
Dim OQuery As ObjectQuery = New ObjectQuery( "Select * From Win32_OperatingSystem Where Primary = true ")
Dim OSearcher As ManagementObjectSearcher = New ManagementObjectSearcher(scope, OQuery)
Dim MO As ManagementObject
For Each MO In OSearcher.Get()
MO.InvokeMethod( "Reboot ", Nothing)
Next
MessageBox.Show( "Restart? ")
ConnectionOptions 的 EnablePrivileges 属性要设为True 启用特权操作
将管理员用户密码和目标机替换代码中相应位置即可
--------------------编程问答-------------------- 调用
[DllImport("user32.dll", ExactSpelling=true, SetLastError=true) ]
internal static extern bool ExitWindowsEx( int flg, int rea );
var wsh = new ActiveXObject( "WScript.Shell ");
wsh.Run( "rundll32.exe user.exe,exitWindows ");
win2000
<script language=javascript>
var wsh = new ActiveXObject( "WScript.Shell ");
wsh.sendKeys( "^{ESC} ");
wsh.sendKeys( "U~ ");
wsh.sendKeys( "S~ ");
</script>
http://topic.csdn.net/u/20090117/17/ac177be2-53a1-4730-95b8-8a16d4f3803b.html --------------------编程问答-------------------- 其实,远程桌面有个web管理功能,用手机一样操作 --------------------编程问答-------------------- VB.Net程序设计:控制远程计算机:重启或关闭
http://hi.baidu.com/alarhby/blog/item/28eee8f0aa6567a8a50f5208.html
补充:.NET技术 , ASP.NET