RunAsAdmin in windows 8

function RunAsAdmin(hWnd: HWND; filename: string; Parameters: string): Boolean;
{
    See Step 3: Redesign for UAC Compatibility (UAC)
    http://msdn.microsoft.com/en-us/library/bb756922.aspx
}
var
    sei: TShellExecuteInfo;
begin
    ZeroMemory(@sei, SizeOf(sei));
    sei.cbSize := SizeOf(TShellExecuteInfo);
    sei.Wnd := hwnd;
    sei.fMask := SEE_MASK_FLAG_DDEWAIT or SEE_MASK_FLAG_NO_UI;
    sei.lpVerb := PChar(‘runas‘);
    sei.lpFile := PChar(Filename); // PAnsiChar;
    if parameters <> ‘‘ then
    	sei.lpParameters := PChar(parameters); // PAnsiChar;
    sei.nShow := SW_SHOWNORMAL; //Integer;

    Result := ShellExecuteEx(@sei);
end;

See Mask values here:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb759784(v=vs.85).aspx

This article will show you how to create a Delphi Application with a manifest to request elevation (run as admin). Read the article, it has a link to Delphi Manifest creator for doing this - very nice ! it will save you a lot of work. So if the program you need to run is written in Delphi and you have the source code then use this method.

http://delphi.about.com/od/delphitips2009/qt/delphi-vista-registry-run-on-startup.htm
https://stackoverflow.com/questions/15319158/use-shell-execute-to-run-cmd-as-admin

时间: 2024-08-05 11:25:10

RunAsAdmin in windows 8的相关文章

Windows API参考大全新编

书名:新编Windows API参考大全 作者:本书编写组 页数:981页 开数:16开 字数:2392千字 出版日期:2000年4月第二次印刷 出版社:电子工业出版社 书号:ISBN 7-5053-5777-8 定价:98.00元 内容简介 作为Microsoft 32位平台的应用程序编程接口,Win32 API是从事Windows应用程序开发所必备的.本书首先对Win32 API函数做完整的概述:然后收录五大类函数:窗口管理.图形设备接口.系统服务.国际特性以及网络服务:在附录部分,讲解如何

Windows上安装MongoDB

Windows上安装MongoDB(2.2版本开始不再支持Windows XP) 1.安装包有zip和msi格式,两者没太大区别,msi其实就是自动解压缩而已,安装目录就是解压缩目录,默认解压到C:\mongodb.要说有区别就是.msi可以用来升级已安装的旧版本.我这里选择解压/安装到D:\MongoDB(Windows的文件系统记录但不区分大小写) 2.将MongoDB添加到环境变量(可选):新建系统变量MONGODB_HOME,值为D:\MongoDB ,在Path变量下添加%MONGOD

通过调用Windows本地RPC服务器bypass UAC提权

备战一个月比赛,导致近期都没啥时间更新博客,正好今天看到一篇通过调用本地RPC服务的文章,觉得非常有意思,就拿来充充博客. 在1.0版本的APPINFO.DLL中的RPC服务调用接口ID为:201ef99a-7fa0-444c-9399-19ba84f12a1a 用RAiLaunchAdminProcess函数调用本地RPC [ uuid (201ef99a-7fa0-444c-9399-19ba84f12a1a), version(1.0), ] long RAiLaunchAdminProc

Windows Server定时重启任务制定

[本篇以Windows Server 2012 R2为例] 第一步:编写重启脚步 其实就是一句话:shutdown /r 其他shutdown命令参考可以使用shutdown /?查阅 第二步:设置任务计划程序 1.再开始-所有应用中找到任务计划程序 2.展开任务计划程序库,这里对任务计划程序做了很多的分类,我们找到System Manager类,在此类下创建自动重启系统任务 3.选择窗口右侧的创建任务(也可以使用创建基本任务,它是以向导的方法创建) 4.常规页面用于定义任务名称及执行任务的用户

windows安装TortoiseGit详细使用教程【基础篇】

环境:win8.1 64bit 安装准备: 首先你得安装windows下的git msysgit1.9.5 安装版本控制器客户端tortoisegit  tortoisegit1.8.12.0 [32和64别下载错,不习惯英文的朋友,也可以下个语言包] 一.安装图解: 先安装GIT[一路默认即可] 安装好git以后,右键,会发现菜单多了几项关于GIT的选项 2.安装tortoisegit[一路默认即可] 安装好以后,右键,会发现菜单多了几项关于tortoisegit的选项 到此,安装算完成了,相

Windows下尝试PHP7提示丢失VCRUNTIME140.DLL的问题解决

前天PHP7.0.0正式版发布了,有一些比较好的改进,官方也说速度比php5.6快了两倍,性能上有了很大提升,并且也发布了从php5.x向php7迁移的问题,所以今后php网站迁移后能够大幅度的提升网站性能,所以为了尝鲜我也去php官网下载了7.0的版本,通过命令行进行独立的测试,下载zip包后解压出来,下载后进入目录,将php.ini-development改为php.ini其余的参数暂时不用修改,然后在当前目录下新建test.php,输入简单的代码: 1 <?php 2 echo "H

AD 脚本kixtart运用之三(添加windows共享打印机)

在http://windyma.blog.51cto.com/661702/1967027文章,已做好用户脚本基础上 在脚本文件kixtart.kix里添加如下内容: --------------------------------------- IF INGROUP ("Color_Printer") If AddPrinterConnection ("\\zsprinter.nccn.int\NEO-Color-Printer") = 0 ? "Add

Install Hyper-V on Windows 10

? Enable Hyper-V to create virtual machines on Windows 10.Hyper-V can be enabled in many ways including using the Windows 10 control panel, PowerShell (my favorite) or using the Deployment Imaging Servicing and Management tool (DISM). This documents

Windows Git+TortoiseGit简易使用教程

转载自 http://blog.csdn.net/jarelzhou/article/details/8256139 官方教程:http://tortoisegit.org/docs/tortoisegit/(英文版) 为什么选择Git 效率 很多人有一种习惯吧,什么软件都要最新的,最好的.其实吧,软件就是工具,生产力工具,为的是提高我们的生产力.如果现有的工具已经可以满足生产力要求了,就没有必要换了.生产效率高低应当是选择工具的第一位. 历史 开源世界的版本控制系统,经历了这么几代: 第一代,