利用网页强制重启服务器
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Runtime.InteropServices;
namespace WebApplication1_advapi
{
/**//// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected const int SE_PRIVILEGE_ENABLED = 0x2;
protected const int TOKEN_QUERY = 0x8;
protected const int TOKEN_ADJUST_PRIVILEGES = 0x20;
protected const string SE_SHUTDOWN_NAME = "SeShutdownPrivilege";
protected const int EWX_LOGOFF = 0x0;
protected const int EWX_SHUTDOWN = 0x1;
protected const int EWX_REBOOT = 0x2;
protected const int EWX_FORCE = 0x4;
protected const int EWX_POWEROFF = 0x8;
protected System.Web.UI.WebControls.Button Button1;
protected const int EWX_FORCEIFHUNG = 0x10;
[StructLayout(LayoutKind.Sequential, Pack=1)]
protected struct LuidStruct
{
public int Count;
public long Luid;
public int Attr;
}
[DllImport("kernel32.dll", ExactSpelling=true)]
protected static extern IntPtr GetCurrentProcess();
[DllImport("advapi32.dll", SetLastError=true)]
protected static extern bool OpenProcessToken(IntPtr h, int acc, ref IntPtr phtok);
[DllImport("advapi32.dll", SetLastError=true)]
protected static extern bool LookupPrivilegeValue(string host, string name, ref long pluid);
[DllImport("advapi32.dll", SetLastError=true, ExactSpelling=true)]
protected static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall, ref LuidStruct newst, int len, IntPtr prev, IntPtr relen);
[DllImport("user32.dll", SetLastError=true, ExactSpelling=true)]
protected static extern bool ExitWindowsEx(int flg, int rea);
protected static void DoExitWindows(int flg)
{
LuidStruct tp;
IntPtr hproc = GetCurrentProcess();
IntPtr htok = IntPtr.Zero;
OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok);
tp.Count = 1;
tp.Luid = 0;
tp.Attr = SE_PRIVILEGE_ENABLED;
LookupPrivilegeValue(null, SE_SHUTDOWN_NAME, ref tp.Luid);
AdjustTokenPrivileges(htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero);
ExitWindowsEx(flg, 0);
}
public static void Shutdown()
{
DoExitWindows(EWX_SHUTDOWN);
}
public static void Reboot()
{
DoExitWindows(EWX_REBOOT | EWX_FORCE);
}
public static void Logoff()
{
DoExitWindows(EWX_LOGOFF);
}
[DllImport("advapi32.dll", SetLastError=true, ExactSpelling=false)]
protected static extern bool InitiateSystemShutdown(string name, string msg, int timeout, bool force, bool reboot);
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}
Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/**//// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
InitiateSystemShutdown(null,null,0,true,true);
}
}
}
分享到:
相关推荐
硬盘占用、在线重启IIS、在线重启服务器、进程查看、网络连接查看、系统服务查看、端口管理、启动项查看、远程桌面管理...功能如此之多以致不能一一列出。 安装简单便捷 不需要复杂的手工配置,不需要额外...
进程隔离 强制访问控制(MAC) 基于角色的访问控制 裸金属架构 认证 审计跟踪 CC安全评估级 CC安全测试用例集 FIPS 140-2 认证加密 源代码开放 资源控制 磁盘加密 VSIP服务器虚拟化解决方案全文共35页,当前为第3页...
额外保护用法:将重要的文件存进安全区,系统每次重启时强制从安全区还原这些文件 穿透的用法:选中一个分区点击数据穿透,指定生成一个虚拟盘符(GMASTER2007中这盘符可以设置隐藏,这虚拟盘只读状态,任何程序都...
即使服务器硬件、操作系统或数据库自身出现故障,也可以在重新启动 时使用事务日志,将所有未完成的事务自动地回滚到系统出现故障的位置。 事务管理特性,强制保持事务的原子性和一致性。事务启动之后,就必须成功...
额外保护用法:将重要的文件存进安全区,系统每次重启时强制从安全区还原这些文件 穿透的用法:选中一个分区点击数据穿透,指定生成一个虚拟盘符(GMASTER2007中这盘符可以设置隐藏,这虚拟盘只读状态,任何程序都...
4、删除“线程_强制结束”命令,与 线程_销毁() 功能相同。 5、修改“窗口_热键注册”参数备注错误,感谢易友【灵魂出窍808】反馈。 6、优化“时间_取中国星期几”命令,感谢易友【灵魂出窍808】提议。 7、新增...
基于JAVA的UDP服务器模型源代码,内含UDP服务器端模型和UDP客户端模型两个小程序,向JAVA初学者演示UDP C/S结构的原理。 简单聊天软件CS模式 2个目标文件 一个简单的CS模式的聊天软件,用socket实现,比较简单。 ...
基于JAVA的UDP服务器模型源代码,内含UDP服务器端模型和UDP客户端模型两个小程序,向JAVA初学者演示UDP C/S结构的原理。 简单聊天软件CS模式 2个目标文件 一个简单的CS模式的聊天软件,用socket实现,比较简单。 ...
除了使您能够控制工作集大小的最小值和最大值,它还允许您重置缓存的工作集,强制它在必要时从一个最小的起点开始增长。CacheSet 的更改会对缓存的大小立即产生影响。注意:要在 NT 4.0 Service Pack 4 上使用 Cache...
如果源分区发现坏簇,则略过提示而强制拷贝。此参数可用于试着挽救硬盘坏道中的数据。 5.@filename 在 filename 中指定 txt 文件。txt文件中为 Ghost 的附加参数,这样做可以不受DOS命令行 150 个字符的限制。 ...
如果源分区发现坏簇,则略过提示而强制拷贝。此参数可用于试着挽救硬盘坏道中的数据。 5.@filename 在 filename 中指定 txt 文件。txt文件中为 Ghost 的附加参数,这样做可以不受DOS命令行 150 个字符的限制...
电脑信息:可以查看某个学生的电脑的系统、内存、驱动器、进程等信息,可以强制结束学生机上运行的某个进程; 黑屏肃静:在学生的电脑上显示黑屏肃静画面。教师还可以自己定义肃静画面的内容,以及是否显示文字,...
如果网络中有 Windows NT 4.0 或 Windows 2000 服务器,并且服务器上安装有 DHCP 服务,此时学生机网卡所绑定的 TCP/IP 协议的设置上可以设为自动获取 IP 地址。如果网络中没有服务器或服务器上没有安装 DHCP 服务,...
-f:没有调用shutdown,而强制关机或重启。 -i:关机(或重启)前,关掉所有的网络接口。 -f:强迫关机,不呼叫shutdown这个指令。 -p: 当关机的时候顺便做关闭电源的动作。 -d:关闭系统,但不留下纪录。...
1.4.0 服务器禁止设置外网 IP ......................................................................................21 1.4.1 防 SQL 注入(WEB), php.ini 配置文件里面设置 ..................................
ASP:动态网页文件;ProComm Plus安装与连接脚本文件;Astound介绍文件 AST:Astound多媒体文件;ClarisWorks“助手”文件 Axx:ARJ压缩文件的分包序号文件,用于将一个大文件压至几个小的压缩包中(xx取01-99的...
3. 运行该批处理程序将自动完成oracle卸载工作,最后手动删除\app文件夹(可能需要重启才能删除) 4. 运行regedit命令,打开注册表窗口。删除注册表中与Oracle相关的内容,具体如下: 删除HKEY_LOCAL_MACHINE/...