shellexecute

How to use javas Process.waitFor()?

被刻印的时光 ゝ 提交于 2019-12-04 06:00:35
问题 I am trying to run command line commands from Java and a quick sanity check made me realize that the reason I am having trouble is that I can't get the pr.waitFor() call below to work. This programs ends in less than 30s and prints nothing after "foo:". I expected it to take just over 30 s and print a random number after "foo:". What am I doing wrong? import java.io.BufferedReader; import java.io.InputStreamReader; public class Sample { public static void main(String[] args) throws Exception

Wait before ShellExecute is carried out?

前提是你 提交于 2019-12-04 03:12:34
I have a hopefully quick question: Is it possible to delay execution of ShellExecute a little bit? I have an application with autoupdater. After it downloads all necessary files etc, it renames current files to *.OLD and the new as the previous. Simple enough. But then I need to delete those .OLD files. This 'cleanup' procedure is executed on MainForm.OnActivate (with a check if it is the first activate proc). But this apparently happens too fast (I get False from DeleteFile). This is the procedure: procedure TUpdateForm.OKBtnClick(Sender: TObject); const SHELL = 'ping 127.0.0.1 -n 2'; begin

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

倾然丶 夕夏残阳落幕 提交于 2019-12-03 22:06:26
问题 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? 回答1: The main problem is that you use nginx.conf as the file name.

Open default browser as standard user (C++)

做~自己de王妃 提交于 2019-12-03 20:16:24
I'm currently using ShellExecute "open" to open a URL in the user's browser, but running into a bit of trouble in Win7 and Vista because the program runs elevated as a service. When ShellExecute opens the browser, it seems to read the "Local Admin" profile instead of the user's. So for example, if the user at the keyboard has Firefox as his default browser, it may open IE (which is the admin's default). I know that the "runas" verb can be used to elevate, but how do you do it the other way around? Is there a way to open a URL in the default browser on a standard user's desktop from a service?

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

巧了我就是萌 提交于 2019-12-03 19:52:05
问题 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

How to Print any document in a SELECTED printer

…衆ロ難τιáo~ 提交于 2019-12-03 14:18:16
I would like to print any document such as pdf,word,excel or text files in a selected printer using .net .I have got success to do such printing in the default printer .The only issue now is to print in the selected printer. Here is the code for the printing. public bool Print(string FilePath) { if (File.Exists(FilePath)) { if (ShellExecute((System.IntPtr )1, "Print", FilePath, "", Directory.GetDirectoryRoot(FilePath), SW_SHOWNORMAL).ToInt32() <= 32) { return false; } else { return true; } } else { return false; } } Dmitry Process printJob = new Process(); printJob.StartInfo.FileName = path;

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

筅森魡賤 提交于 2019-12-03 09:25:21
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 = TheArgs; app.PriorityClass = ProcessPriorityClass.BelowNormal; app.Start(); However, I get a System.InvalidOperationException with the message "No process is associated with this object." Why? How do I properly launch this app in low priority? Without the line app.PriorityClass = ProcessPriorityClass.BelowNormal; the app runs fine. Try setting the

Why ShellExecute can not find a file?

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: as comming from a *nix world I'm very confused with Windows behaviour and probably its security system. I'm simply trying to execute an external program within my app. I've found the WinAPI function ShellExecute which works as expected except when launching some programs placed in %windir%\System32 subdirectory. execution of ping.exe succeeds ShellExecute(NULL, "open", "c:\\Windows\\System32\\ping.exe', NULL, NULL, SW_SHOW) ); // ^^^ OK, retcode == 42 execution of java.exe fails ShellExecute(NULL, "open", "c:\\Windows\\System32\\java.exe',

Selecting file in Windows Explorers does not always work

断了今生、忘了曾经 提交于 2019-12-03 06:32:44
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,"' + Parm + '"'), nil, SW_NORMAL); And it works. My problem is this: if I select a different file in the recently opened Explorer (clicking in a different file) and then call the above code the "Parm" file is not selected again. Interestingly, there are some programs that select the file again. For instance, ITunes always selects the desired file. Does

How should I make my VBA code compatible with 64-bit Windows?

匿名 (未验证) 提交于 2019-12-03 01:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a VBA application developed in Excel 2007, and it contains the following code to allow access to the ShellExecute function from Shell32.dll : Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long I originally said: Apparently the application will not compile on a 64-bit version of Windows (still using 32-bit Office 2007). I assume that this is