[IronPython] System.Diagnostics.Process.Start only uses first argument

Luke Hoersten luke.hoersten at gmail.com
Fri Jun 22 17:47:29 CEST 2007


I'm not including the quotes. Those are just the strings I'm using,
similar to your example. I'm getting different results: Only the first
argument being sent in that string is being processed. The other is
being ignored. So either I get /s and no .reg file or I import
the .reg file and it prompts me. I'm writing a script so obviously
prompting is undesirable.

Here's my code:
name = "c:\\Windows\\regedit.exe"
args = "/s example.reg"
System.Diagnostics.Process.Start(name, args)

I've even tried waiting on the process to exit with WaitForExit() but
that still does not work.

I've read on Google about a lot of people having this similar problem
but people seem to give up before posting a solution. Any other ideas?

On Jun 22, 10:32 am, Dino Viehland <d... at exchange.microsoft.com>
wrote:
> How exactly are you passing this?  I assume the quotes aren't being included?  The 1st form below prompts me and the 2nd form doesn't prompt (ignoring the UAC prompt on Vista of course which is a whole other ball of wax), are you doing something different?
>
> >>> import System
> >>> System.Diagnostics.Process.Start('regedit.exe', '"/s foo.reg"')
>
> <System.Diagnostics.Process object at 0x000000000000002B [System.Diagnostics.Process (regedit)]>>>> System.Diagnostics.Process.Start('regedit.exe', '/s foo.reg')
>
> <System.Diagnostics.Process object at 0x000000000000002C [System.Diagnostics.Process (regedit)]>
>
> You could also check out the nt module where we have nt.popen (or os if you have the CPython std lib installed) which takes a single command line (exe + args) and we do the splitting for you - that'd also be compatible w/ CPython.
>
> -----Original Message-----
> From: users-boun... at lists.ironpython.com [mailto:users-boun... at lists.ironpython.com] On Behalf Of Luke Hoersten
> Sent: Friday, June 22, 2007 8:07 AM
> To: u... at lists.ironpython.com
> Subject: [IronPython] System.Diagnostics.Process.Start only uses first argument
>
> System.Diagnostics.Process.Start(app, args) should take a string of
> arguments delimited by spaces for the second argument of start which
> it will pass to app on stdin. I'm trying to run app = "regedit.exe"
> and args ="/s key.reg" but it's only recognizing the first argument
> (which is /s). If I remove /s, it runs the key but I want this to run
> silently.
>
> I've also tried ProcessStartInfo() but it suffers from the same
> problem. Does anyone have any more information on this or know how to
> work around this?
>
> Thanks,
> Luke
>
> _______________________________________________
> users mailing list
> u... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> _______________________________________________
> users mailing list
> u... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/users-ironpython.com




More information about the Ironpython-users mailing list