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
289
votes
10 answers

How do I execute a program from Python? os.system fails due to spaces in path

I have a Python script that needs to execute an external program, but for some reason fails. If I have the following script: import os; os.system("C:\\Temp\\a b c\\Notepad.exe"); raw_input(); Then it fails with the following error: 'C:\Temp\a' is…
Lasse V. Karlsen
  • 350,178
  • 94
  • 582
  • 779
125
votes
5 answers

Open a Web Page in a Windows Batch FIle

I have a batch file that does a bunch of things and at the end needs to open up a web browser to a page. Is there a way to, in essence, call ShellExecute on a http to open the web page? Windows Command Prompt
Ian Vink
  • 60,720
  • 99
  • 311
  • 535
61
votes
7 answers

Exec a shell command in Go

I'm looking to execute a shell command in Go and get the resulting output as a string in my program. I saw the Rosetta Code version: package main import "fmt" import "exec" func main() { cmd, err := exec.Run("/bin/ls", []string{"/bin/ls"},…
Chris Bunch
  • 80,639
  • 36
  • 120
  • 123
58
votes
1 answer

How to Pass parameters for a Ant script , which is invoked via shell script?

I need to invoke a ant script via shell script. Let us consider the parameters for ant script are a,b,c. how can i pass the parameter for those variables? I must provide the parameters for ant vis invoke the shell script. can anyone help me on this?
trilawney
  • 1,766
  • 6
  • 26
  • 34
55
votes
2 answers

Exec vs ExecWait vs ExecShell vs nsExec::Exec vs nsExec::ExecToLog vs nsExec::ExecToStack vs ExecDos vs ExeCmd

Can I know what are the differences between each Exec, ExecWait, ExecShell, nsExec::Exec, nsExec::ExecToLog, nsExec::ExecToStack, ExecDos and ExecCmd, as in when to use which? I 've posted the various execute calls I know. I am trying to make a…
nawfal
  • 62,042
  • 48
  • 302
  • 339
52
votes
3 answers

ShellExecute equivalent in .NET

I'm looking for the .NET-preferred way of performing the same type of thing that ShellExecute does in Win32 (opening, printing, etc. for arbitrary file types). I've been programming Windows for over 20 years, but I'm a complete newbie at .NET, so…
Martin Kenny
  • 2,408
  • 1
  • 19
  • 16
46
votes
4 answers

How to call shell script from php that requires SUDO?

I have a file that is a bash script that requires SUDO to work. I can run it from the command line using SUDO but I will be prompted to put in the SUDO password. I want to run this script from php via shell_exec but I if I call SUDO, its not like a…
JD Isaacks
  • 51,154
  • 89
  • 267
  • 413
41
votes
4 answers

Lua os.execute return value

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…
Cyclone
  • 13,241
  • 22
  • 76
  • 112
39
votes
8 answers

replace a particular text in all the files using single line shell command

I have a renamed js file which I have to call in each of my php pages. Now I want to replace that old name with the new one using shell. what iam using is this: sed -i ’s/old/new/g’ * but this is giving the following error: sed: -e expression #1,…
developer
  • 1,952
  • 10
  • 35
  • 58
38
votes
3 answers

How do I launch a process with low priority? C#

I want to execute a command line tool to process data. It does not need to be blocking. I want it to be low priority. So I wrote the below Process app = new Process(); app.StartInfo.FileName = @"bin\convert.exe"; app.StartInfo.Arguments =…
user34537
37
votes
2 answers

Getting output from a shell/dos app into a Delphi app

I have a commandline application coded in delphi that I need to call from a normal desktop application (also coded in delphi). In short, I want to call the commandline app and display the text it outputs "live" in a listbox. It's been ages since I…
Jon Lennart Aasenden
  • 3,772
  • 2
  • 26
  • 41
31
votes
3 answers

How can I run a child process that requires elevation and wait?

Win 7/UAC is driving me crazy. From within my C++ application, I need to run an executable that requires elevation on Windows 7. I want to fire this thing off and wait for it to finish before proceeding. What's the easiest way to do this? I…
KenG
  • 313
  • 1
  • 3
  • 4
28
votes
3 answers

How to wait for ShellExecute to run?

I have manages to use ShellExecute in VC++ in order to launch a document. Now I wish to run a command-line tool that receives some arguments, and to run in the background (as hidden, not minimized) and let it block my program flow, so that i'll be…
buddy123
  • 4,657
  • 8
  • 42
  • 65
26
votes
2 answers

How do I run a command-line program in Delphi?

I need to execute a Windows "find" command from a Delphi software. I've tried to use the ShellExecute command, but it doesn't seem to work. In C, I'd use the system procedure, but here... I don't know. I'd like to do something like…
gramm
  • 18,623
  • 6
  • 24
  • 25
26
votes
1 answer

How to run application which requires admin rights from one that doesn't have them

I've been stuck on this for a few hours until I've finally managed to do it. There are already links which pointed me the right direction: Is it possible for the executable to ask for Administrator rights? (Windows 7) CreateProcess error=740, The…
Samuel
  • 1,975
  • 5
  • 24
  • 36
1
2 3
33 34