Re: External process fails with switch arguments



On Thu, 21 Jun 2007 09:56:01 -0700, michael sorens <m_j_sorens@xxxxxxxxxxxxxxxx> wrote:

Sometimes you think too hard :-)

I think you're being too hard on him. He's just looking at your question at face value, assuming that everything you've done there is intentional..

I am simply using the DOS "date /t" command here which should return a value
like that shown in my test case. And it seems pretty clear that the problem
is in the .Net interface, not the "date" program itself.

Well, except for the fact that the "date" that takes "/t" as an argument isn't an executable program you can start using the fileName parameter of the ProcessStartInfo class. If you go to a command prompt in Windows and type "date", you get the built-in "date" command by default, but you can't use that "date" command as input to the creation of a process.

On my PC, I don't even have a "date" executable anywhere, and I can't start a process using that as the fileName parameter. If you do have a "date" executable that you are running (as it appears that you do), then you need to determine the correct arguments to use to get the output you desire. From your original post, it appears that "/t" is not the correct argument (though it is with the built-in "date" command).

For what it's worth, if you use this to create your ProcessStartInfo, you get what you're asking for:

ProcessStartInfo psi = new ProcessStartInfo("cmd", "/c date /t");

Though, it doesn't use your installed "date.exe" program, so if that was intentional, you'll have to figure out what arguments to pass to your installed "date.exe" program (as I suggest above).

Pete
.



Relevant Pages

  • Re: External process fails with switch arguments
    ... for me "date.exe /t" gives the expected output. ... Seems like you might be running the cygwin version of date by ... use that "date" command as input to the creation of a process. ... For what it's worth, if you use this to create your ProcessStartInfo, you ...
    (microsoft.public.dotnet.languages.csharp)
  • Problems creating a process from a .net service
    ... I want to print pdf files by calling the Adobe Acrobat 4 command line ... ProcessStartInfo psi = new ProcessStartInfo; ... If i do this in a normal command line tool, ... Windows XP SP2. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How do I launch a process with parameters
    ... You've got your command line parameters included in the program name in the ... Do the ProcessStartInfo thing with the Filename and Arguments ... >>> launching IE with a URL but the above command did not work. ...
    (microsoft.public.dotnet.framework)

Loading