shellexecute

Simple method to run a batch as Administrator using javascript

邮差的信 提交于 2019-12-01 21:52:35
问题 I want to derive a simple reliable method to auto elevate a running batch without using extra VBS files or elevated shortcuts, proposed in other threads. Calling the UAC dialog from the batch via javascript ensures the short simple code. The script below auto elevates a user to Admin rights correctly, when Yes is chosen in the dialog, but the error dialog popups (outside of Cmd window) " Windows cannot find 'test.bat '". Can it be since the path-to-file includes spaces? How to fix the code or

ShellExecute: Verb “runas” does not work for batch files with spaces in path

南楼画角 提交于 2019-12-01 10:00:36
问题 I am using ShellExecuteW to start a batch file. Code looks somewhat like this: ShellExecuteW(GetDesktopWindow(), wide_verb.c_str(), wide_filename.c_str(), wide_parameters.c_str(), NULL, SW_SHOW); Where the wide_ variables are of type wstring . This code works fine for arbitrary combinations of file path and verb, except for verb "runas" (to get administrator rights) and a batch file with spaces in the given path wide_filename . The UAC prompt will pop up and, after confirmation, for a short

Launching Shell Links (LNKs) from WOW64

耗尽温柔 提交于 2019-12-01 09:14:04
Our 32-Bit application launches Windows LNK files (Shell Links) via ShellExecute. When it tries to "launch" a link to a 64-Bit binary (such as the "Internet Explorer (64-Bit)" shortcut in Start Menu) it always ends up launching the 32-Bit binary. Internally, ShellExecute incorrectly resolves the link target: There's a hidden field inside the LNK which holds FOLDERID_ProgramFiles. A 64-Bit app resolves this to the 64-Bit Program Files directory, but a 32-Bit app won't. Wow64DisableWow64FsRedirection does not change this behavior of ShellExecute. Besides going through a 64-Bit "trampoline"

Launching Shell Links (LNKs) from WOW64

早过忘川 提交于 2019-12-01 05:36:10
问题 Our 32-Bit application launches Windows LNK files (Shell Links) via ShellExecute. When it tries to "launch" a link to a 64-Bit binary (such as the "Internet Explorer (64-Bit)" shortcut in Start Menu) it always ends up launching the 32-Bit binary. Internally, ShellExecute incorrectly resolves the link target: There's a hidden field inside the LNK which holds FOLDERID_ProgramFiles. A 64-Bit app resolves this to the 64-Bit Program Files directory, but a 32-Bit app won't.

How do I open a file with the default text editor?

不想你离开。 提交于 2019-12-01 00:48:33
I want to open a *.conf file. I want to open this file with the standard Windows editor (e.g., notepad.exe). I currently have this ShellExecute code: var sPath, conf: String; begin try sPath := GetCurrentDir + '\conf\'; conf := 'nginx.conf'; ShellExecute(Application.Handle, 'open', PChar(conf), '', Pchar(sPath+conf), SW_SHOW); except ShowMessage('Invalid config path.'); end; end; But nothing happens. So what should I change? The main problem is that you use nginx.conf as the file name. You need the fully-qualified file name (with drive and directory). If the file resides in the same directory

Is there anyway to specify a PrintTo printer when spawning a process?

痴心易碎 提交于 2019-11-30 12:42:20
What I Have I am currently writing a program which takes a specified file and the performs some action with it. Currently it opens it, and/or attaches it to an email and mails it to specified addresses. The file can either be of the formats: Excel, Excel Report, Word, or PDF. What I am currently doing is spawning a process with the path of the file and then starting the process; however I also am trying to fix a bug feature that I added which adds the verb 'PrintTo' to the startup information, depending on a specified setting. What I Need The task I am trying to accomplish is that I would like

How to install a windows service from command line specifying name and description?

感情迁移 提交于 2019-11-30 11:57:53
I created a Windows service with Delphi for a client server application. To install it I use c:\Test\MyService.exe /install (or /uninstall) This installs the service and in Windows services it lists with "MyService" name and empty description. How to define a different name and insert a description (to be seen when running services.msc )? Note: I need this because on the same machine i need to install more times the same service (1 per database). Currently the only workaround i foudn is to rename the service exe, but I'd prefer to find out the correct command line way to do it (since I do this

VBA: Running “Elevated” Command (Shell vs. ShellExecute)

 ̄綄美尐妖づ 提交于 2019-11-30 09:25:08
问题 In my VBA procedure, I need to run the app "Skitch" and use it to open a JPEG file. This is the command I've been using: ReturnValue = Shell("C:\Program Files (x86)\Evernote\Skitch\Skitch.exe " & """" & aPic & """", 1) ...where "aPic" is the path and filename. After some experimenting, I think I need to run the command as if it were in an Elevated Command window (in other words, run it "as Administrator"). Is it possible to run Shell elevated? If that's not possible: If I understand correctly

How do I perform a shell execute in a chrome extension?

安稳与你 提交于 2019-11-30 00:48:14
I'm not finding a way to do this in the chrome.* API or even the experimental. It doesn't run through wscript so ActiveXObject("Shell.Application") isn't allowed. I fear that my only option is to build a dll with NPAPI but I wanted to see if there was a simpler way. If you want to do anything Natively, you need to use NPAPI. That allows you to run code outside the sandbox for your extensions. http://code.google.com/chrome/extensions/npapi.html mgalgs To update this for a fellow wary lonesome traveler, even NPAPI is deprecated and being phased out. One of the alternatives mentioned in the NPAPI

How can a Delphi Program send an Email with Attachments via the DEFAULT E-mail Client?

我的未来我决定 提交于 2019-11-30 00:31:05
Within my program, I am composing an email to send using the default e-mail client software installed on a user's machine. I have composed the mailto address, the subject, the multilined body, and I have several attachments to be included. I almost got this working using mailto and ShellExecute as follows: Message := 'mailto:someone@somewhere.com' + '?subject=This is the subjectBehold Error Report' + '&body=This is line 1' + '%0D%0A' + 'This is line 2' + '%0D%0A' + 'This is line 3' + '&Attach=c:\file1.txt'; RetVal := ShellExecute(Handle, 'open', PChar(Message), nil, nil, SW_SHOWNORMAL); if