shellexecute

使用ShellExecute函数实现以管理员身份运行程序

匿名 (未验证) 提交于 2019-12-02 23:51:01
背景 在 Win7 或者 Win7 以上版本的系统,我们想以管理员身份运行一个程序的时候,只需要选中这个程序文件,鼠标右击,选择“以管理员身份启动”就可以了。但是,在实际的编程中,我们要以管理员身份创建一个进程该怎么操作呢? 可能有人会想,创建一个进程,那使用 CreateProcess 函数创建就可以了。是的,CreateProcess 是可以创建一个进程,但是它不能以管理员权限创建进程。换句话说,它只能创建一个权限比它低或者相同权限的进程。若是一个普通进程,它就创建不了管理员权限进程。 本文要介绍的 ShellExecute 函数,可以实现创建管理员权限进程。但是,如果系统开启了UAC(用户账户控制),则会弹窗提示是否要以管理员权限运行。现在,我就把这个小程序实现的过程进行整理,分享给大家。 文章来源: https://blog.csdn.net/demongwc/article/details/85276000

Lua os.execute return value

耗尽温柔 提交于 2019-12-02 18:49:59
Is it possible to read the following from the local variable in Lua? local t = os.execute("echo 'test'") print(t) I just want to achieve this: whatever is executed via the ox.execute and will return any value, I would like to use it in Lua - for example echo 'test' will output test in the bash command line - is that possible to get the returned value ( test in this case) to the Lua local variable? You can use io.popen() instead. This returns a file handle you can use to read the output of the command. Something like the following may work: local handle = io.popen(command) local result = handle

Read Registry Keys from within VBA using Windows Shell

こ雲淡風輕ζ 提交于 2019-12-02 15:21:57
问题 I have been searching around on the internet and am having problems finding a solution to this issue. Basically I am trying to execute a registry query with administrator privileges using Shell.Application from within VBA to read the value of TypeGuessRows (and eventually modify it to 0 aswell so that excel data can be correctly queried using ADOdb). I have come up with the following sub routine: Sub Read_Registry_Value() 'Declare variables Dim reg_key_location As String Dim reg_key_name As

Need to execute shell script from webapp and display console output in page

我的未来我决定 提交于 2019-12-02 10:25:43
I am looking for java examples or library that will help me integrate this into a Struts2/Spring application. Many build systems such as Luntbuild or Hudson have this functionality, I thought I would ask if any one knows of a standalone example before I attempted to dig it out of one of those. I glanced at Quartz job scheduling framework also, but I haven't found the UI hooks yet. Do I just need to read from a file with a JSP include? If I understand what you are trying to do, this is one way in Java. This executes the ls command and then captures the shell output and writes it back to System

How to get the Handle that is executed in winexec or shellexecute?

时光毁灭记忆、已成空白 提交于 2019-12-02 09:59:38
i use to create a custom function like winexec(...):Hwnd that will retun the handle of executed application. i did use the findwindow() but having problem if it change window caption. There is no general way to get "the" window handle of an application because there's no guarantee that any program has one window handle. A program may have many top-level handles (i.e., Microsoft Word, one for each document), or it may have no windows at all. You might question what you really need the window handle for; there could be better ways of doing whatever it is you're trying to do that don't require

Perfom a ShellExecute from Firefox Addon

北城以北 提交于 2019-12-02 09:42:26
In my Firefox extensions I want to open certain files with the "default viewer" for that file type in Windows. So basically something similar to the ShellExecute('OPEN') function call of the Windows API. Is it possible? If so, how can that be achieved? Files The closest thing is nsIFile::launch . However, it is not implemented for every conceivable platform (but it is implemented at least for Windows, OSX, GTK/Gnome and compatible, KDE and Android). You cannot use ::launch to instruct the OS (in particular Windows) to use a verb other than open , though, so there is no equivalent to e.g.

Close external application launched from R

喜欢而已 提交于 2019-12-02 08:03:51
Is it possible to close an application that was launched from within R? Assume that I have opened a CSV file my_file.csv with its associated application via the shell.exec function . I then want to close this application. Since R has no control over other programs you cannot directly close files opended without R reliably. You do not even know which program to close. E.g. one one computer a csv file may be opened with notepad, on another computer it may be opened with Excel. If you know the program you can use system2() or similar commands to execute a command to kill the other program. E.g.

Trying to call ShellExecute to run Mysql and a sql script

半腔热情 提交于 2019-12-02 03:04:32
I've been trying to use ShellExecute from within a Delphi app to open Mysql and run a script. ShellExecute(Handle, 'open', PWideChar(InpCommandProgram.text), PWideChar(commandline), nil, SW_SHOWNORMAL); InpCommandProgram.text = 'MYSQL' commandline = '--user=root --password=password < C:/directory/filename.sql ' filename.sql has been stripped down to 'Create databasename'. A command window opens briefly and scrolls some messages - too fast to read. If I open a command window and enter the same program and commandline it works. I can't see the error messages when it fails. I'm running locally on

C++ open link with ShellExecute

主宰稳场 提交于 2019-12-02 01:25:51
If I write like this: ShellExecute(NULL, "open", "www.google.com", NULL, NULL, SW_SHOWNORMAL); Everything's okay and is as it has to be. But I want so that user could enter a link where he wants to go. std::cout<<"Enter the link: "; char link; std::cin>>link; ShellExecute(NULL, "open", link, NULL, NULL, SW_SHOWNORMAL); In this case I get an invalid conversion from 'char' to 'const CHAR* error. So, is there a way to do this properly? Your code only gets one character in as the link. You need to make link a type able to hold the value of the link and also read stdio in. Making link a std::string

.net cf - launch explorer programmatically

夙愿已清 提交于 2019-12-02 01:08:36
I am trying to launch explorer programmatically from my .Net CF Window application. But its throwing win32 exception. I have used same kind of code in desktop .Net version, and it always worked. (I am using Windows CE 5 and .Net CF 3.5 ) Following code throws Win32 Exception, Process.Start("\\", null); Unfortunately, I am using the code like this :-( try { Process.Start("\\", null); } catch { } Maybe you should give it a program name to start? "\" is not an application. Something like this is probably more likely to yield success: Process.Start("\\windows\\explorer.exe", null); In order to