Questions tagged [shellexecute]

ShellExecute is a Win32 API function used to launch document files

ShellExecute is a Microsoft Win32 API function used to launch document files.

Depending on the type of document file, it will do this through:

  • Creating a process using the executable file associated with the specified document
  • Using the COM subsystem to request a shell extension to launch the document
  • Initiating an action to be completed by the end-user, such as a search

As a rule of thumb, it can be assumed that invoking ShellExecute on a document file will have the same result as double-clicking on that file in Windows Explorer, including displaying user interface elements.

497 questions
19
votes
3 answers

Programmatically selecting file in explorer

In my application I can programmatically open explorer and select a file using the following code: void BrowseToFile(LPCTSTR filename) { CString strArgs; strArgs = _T("/select,\""); strArgs += filename; strArgs += _T("\""); …
flashk
  • 2,293
  • 2
  • 19
  • 31
17
votes
2 answers

starting a UAC elevated process from a non-interactive service (win32/.net/powershell)

I'm using a thrid party Windows service that handles some automation tasks by running scripts and executables using CreateProcessAsUser(). I'm running into problems on Windows Server 2008 due to UAC and way the LUA elevation is handled through the…
Chris Sears
  • 5,533
  • 4
  • 28
  • 33
15
votes
3 answers

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

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…
wtjones
  • 3,722
  • 4
  • 29
  • 41
15
votes
1 answer

how to get return value of an exe called by ShellExecute

How to get the return value of an exe which is called by shellexecute function. ShellExecute(NULL, NULL, TEXT ( ".\\dpinstx86.exe" ), NULL, NULL, SW_SHOWNORMAL); In the above example I want the return value of "dpinstx86.exe".
2vision2
  • 4,651
  • 14
  • 74
  • 156
14
votes
5 answers

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

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…
lkessler
  • 19,414
  • 31
  • 125
  • 196
14
votes
1 answer

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

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…
LaBracca
  • 13,941
  • 34
  • 129
  • 224
13
votes
13 answers

Which reasons could make ShellExecute fail?

I have a VB6 application which opens files with their associated application using: ShellExecute(0, "open", filename, params, vbNullString, vbNormalFocus) This works perfectly. Now I got a customer (running XP with Adobe Reader) who can't open any…
MicSim
  • 25,056
  • 15
  • 84
  • 124
12
votes
3 answers

How to Run cmd.exe with parameters from javascript

I am trying to write javascript which should run cmd.exe with a specified command line in it like this docs.google.com/file/d/0B7QHCoQDlEvKWUZSX3oxUDI2SDg/edit: I prepare a code after reading shellexecute method on microsoft site: var objShell = new…
May12
  • 2,090
  • 11
  • 49
  • 91
11
votes
1 answer

Is it OK to pass a null window handle to ShellExecute?

I have a Delphi console application that at the end needs to launch one of two applications. I'm having some problems getting ShellExecute to work without erroring, and I think the problem is associated with not having a handle for the console…
Dan Kelly
  • 2,516
  • 3
  • 41
  • 58
11
votes
3 answers

How to shell to another app and have it appear in a delphi form

In Delphi I've used ShellExecute for years to launch (and optionally wait for) other applications. Now though, I need to have one of these applications appear in one of my Delphi app forms. I've tried the code below as a simple test to open notepad…
Brian Frost
  • 12,964
  • 10
  • 72
  • 146
11
votes
3 answers

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

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,…
Immanu'el Smith
  • 663
  • 1
  • 7
  • 17
11
votes
2 answers

Is there a way to detect if a monitor is plugged in?

I have a custom application written in C++ that controls the resolution and other settings on a monitor connected to an embedded system. Sometimes the system is booted headless and run via VNC, but can have a monitor plugged in later (post boot). …
martinarcher
  • 137
  • 2
  • 9
11
votes
1 answer

How to launch the associated application for a file / directory / URL?

Linux seems to be easy: xdg-open . Apparently, Mac is similar: open should be used instead of xdg-open. I don't have access to a Mac so I couldn't test it. For Windows, I found 4 different suggestions and those that I have tried…
Ali
  • 51,545
  • 25
  • 157
  • 246
10
votes
3 answers

Shell_exec php with nohup

I think there are tons of similar posts but I haven't yet found a solution after searching around. Basically, I'm trying to run two scripts in the background. When I run them in the commandline, I see after calling my first script: /usr/bin/nohup…
Rio
  • 11,734
  • 21
  • 62
  • 104
10
votes
1 answer

Selecting file in Windows Explorers does not always work

Using the following explorer.exe /select, "c:\path\to\file.txt" I can open Windows Explorer and select the file. In Delphi I do this to select "Parm" file: ShellExecute(Application.MainForm.Handle, 'OPEN', PChar('explorer.exe'), PChar('/select,"' +…
Eduardo Mauro
  • 1,517
  • 1
  • 26
  • 38
1
2
3
33 34