shellexecute

ShellExecute equivalent in .NET

*爱你&永不变心* 提交于 2019-11-26 15:31:53
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 maybe I'm just looking in the wrong places. I'm currently using .NET 2.0 (VS C# 2005), but could use VS 2008 if need be. If the only answer is to use P/Invoke, then I might be better just writing my small utility using Win32 anyway. Process.Start . Note that advanced uses (printing etc) require using a ProcessStartInfo and setting the Verb property.

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

梦想与她 提交于 2019-11-26 13:58:06
问题 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 this: System('find "320" in.txt > out.txt'); Edit : Thanks for the answer :) I was trying to run 'Find' as an executable, not as argument for cmd.exe. 回答1: An example using ShellExecute() : procedure TForm1.Button1Click(Sender: TObject); begin ShellExecute(0, nil,

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

浪尽此生 提交于 2019-11-26 12:14:11
问题 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 requested operation requires elevation But I\'ve thought that simple overview of the problem could help someone :). 回答1: Real problem: (from Wikipedia: http://en.wikipedia.org/wiki/User_Account_Control) An executable that is marked as

Programmatically selecting file in explorer

元气小坏坏 提交于 2019-11-26 10:59:07
问题 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(\"\\\"\"); ShellExecute(0, _T(\"open\"), _T(\"explorer.exe\"), strArgs, 0, SW_NORMAL); } My problem is that if I call this function a second time with a different file, but in the same folder, the selection in explorer does not change to the new file, but remains on the

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

荒凉一梦 提交于 2019-11-26 06:35:52
问题 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 normally do this kind of thing via CreateProcess() , but it fails for executables that require elevation. I tried running using cmd.exe /c ... through CreateProcess , which works but pops up an ugly cmd terminal window. I am reading that ShellExecute()

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

ぃ、小莉子 提交于 2019-11-26 04:40:25
问题 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 have played around with the shell, but I distinctly remember that in order to grab the text from a commandline app - I have to use the pipe symbol \">\". Like this: C:/mycmdapp.exe >c:/result.txt This will take any text printed to the shell

ShellExecute equivalent in .NET

微笑、不失礼 提交于 2019-11-26 04:28:14
问题 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 maybe I\'m just looking in the wrong places. I\'m currently using .NET 2.0 (VS C# 2005), but could use VS 2008 if need be. If the only answer is to use P/Invoke, then I might be better just writing my small utility using Win32 anyway. 回答1: Process

How to call shell script from php that requires SUDO?

眉间皱痕 提交于 2019-11-26 00:55:01
问题 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 command line where I can be prompted for the password. Is there a way to pass the password for sudo with the sudo call? How can I do this? 回答1: Edit the sudoers file (with visudo ) and add a rule that allows the web server user to run the command

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

馋奶兔 提交于 2019-11-26 00:13:09
问题 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 not recognized as an internal or external command, operable program or batch file. If I escape the program with quotes: import os; os.system(\'\"C:\\\\Temp\\\\a b c\\\\Notepad.exe\"\'); raw_input(); Then it works. However, if I add a