Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista Tutorial - Question about [System.Diagnostics.Process]::Start()

Reply
 
Old 07-20-2007   #1 (permalink)
andy@nodisabilities.com
Guest


 
 

Question about [System.Diagnostics.Process]::Start()

I am trying to figure out how to start a process with parameters.

For example I can do [System.Diagnostics.Process]::Start("outlook")
and Outlook launches.

I would like to do [System.Diagnostics.Process]::Start("outlook /
safe")

But I get the following error

PS > [System.Diagnostics.Process]::Start("outlook /safe")
Exception calling "Start" with "1" argument(s): "The system cannot
find the file specified"
At line:1 char:36
+ [System.Diagnostics.Process]::Start( <<<< "outlook /safe")

Thanks

Andy


My System SpecsSystem Spec
Old 07-20-2007   #2 (permalink)
Jeff
Guest


 
 

Re: Question about [System.Diagnostics.Process]::Start()

On Jul 21, 5:56 am, a...@nodisabilities.com wrote:
> I am trying to figure out how to start a process with parameters.
>
> For example I can do [System.Diagnostics.Process]::Start("outlook")
> and Outlook launches.
>
> I would like to do [System.Diagnostics.Process]::Start("outlook /
> safe")
>
> But I get the following error
>
> PS > [System.Diagnostics.Process]::Start("outlook /safe")
> Exception calling "Start" with "1" argument(s): "The system cannot
> find the file specified"
> At line:1 char:36
> + [System.Diagnostics.Process]::Start( <<<< "outlook /safe")
>
> Thanks
>
> Andy


What you want is the overload of the Process.Start method that takes
the arguments as the second parameter:

[System.Diagnostics.Process]::Start( "outlook", "/safe" )

Good luck.

Jeff

My System SpecsSystem Spec
Old 07-20-2007   #3 (permalink)
Brandon Shell
Guest


 
 

Re: Question about [System.Diagnostics.Process]::Start()

Use System.Diagnostics.ProcessStartInfo and pass to
System.Diagnostics.Process. This gives you a little more control of the
process and its properties.

$StartInfo = new-object System.Diagnostics.ProcessStartInfo
$StartInfo.FileName = "outlook.exe"
$StartInfo.Arguments="/safe"
$StartInfo.LoadUserProfile = $false
$StartInfo.UseShellExecute = $false
$StartInfo.WorkingDirectory = (get-location).Path
$proc = [System.Diagnostics.Process]::Start($StartInfo)

Some good info here
http://blogs.msdn.com/powershell/arc...owershell.aspx

<andy@nodisabilities.com> wrote in message
news:1184972219.099933.109360@i38g2000prf.googlegroups.com...
>I am trying to figure out how to start a process with parameters.
>
> For example I can do [System.Diagnostics.Process]::Start("outlook")
> and Outlook launches.
>
> I would like to do [System.Diagnostics.Process]::Start("outlook /
> safe")
>
> But I get the following error
>
> PS > [System.Diagnostics.Process]::Start("outlook /safe")
> Exception calling "Start" with "1" argument(s): "The system cannot
> find the file specified"
> At line:1 char:36
> + [System.Diagnostics.Process]::Start( <<<< "outlook /safe")
>
> Thanks
>
> Andy
>


My System SpecsSystem Spec
Old 07-20-2007   #4 (permalink)
andy@nodisabilities.com
Guest


 
 

Re: Question about [System.Diagnostics.Process]::Start()

Perfect, that is just what I was looking for.

Thanks!

Andy


Jeff wrote:
> On Jul 21, 5:56 am, a...@nodisabilities.com wrote:
> > I am trying to figure out how to start a process with parameters.
> >
> > For example I can do [System.Diagnostics.Process]::Start("outlook")
> > and Outlook launches.
> >
> > I would like to do [System.Diagnostics.Process]::Start("outlook /
> > safe")
> >
> > But I get the following error
> >
> > PS > [System.Diagnostics.Process]::Start("outlook /safe")
> > Exception calling "Start" with "1" argument(s): "The system cannot
> > find the file specified"
> > At line:1 char:36
> > + [System.Diagnostics.Process]::Start( <<<< "outlook /safe")
> >
> > Thanks
> >
> > Andy

>
> What you want is the overload of the Process.Start method that takes
> the arguments as the second parameter:
>
> [System.Diagnostics.Process]::Start( "outlook", "/safe" )
>
> Good luck.
>
> Jeff


My System SpecsSystem Spec
Old 07-21-2007   #5 (permalink)
RichS
Guest


 
 

Re: Question about [System.Diagnostics.Process]::Start()

As an alternative there is a start-process cmdlet in the PowerShell Community
Extensions
--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"Brandon Shell" wrote:

> Use System.Diagnostics.ProcessStartInfo and pass to
> System.Diagnostics.Process. This gives you a little more control of the
> process and its properties.
>
> $StartInfo = new-object System.Diagnostics.ProcessStartInfo
> $StartInfo.FileName = "outlook.exe"
> $StartInfo.Arguments="/safe"
> $StartInfo.LoadUserProfile = $false
> $StartInfo.UseShellExecute = $false
> $StartInfo.WorkingDirectory = (get-location).Path
> $proc = [System.Diagnostics.Process]::Start($StartInfo)
>
> Some good info here
> http://blogs.msdn.com/powershell/arc...owershell.aspx
>
> <andy@nodisabilities.com> wrote in message
> news:1184972219.099933.109360@i38g2000prf.googlegroups.com...
> >I am trying to figure out how to start a process with parameters.
> >
> > For example I can do [System.Diagnostics.Process]::Start("outlook")
> > and Outlook launches.
> >
> > I would like to do [System.Diagnostics.Process]::Start("outlook /
> > safe")
> >
> > But I get the following error
> >
> > PS > [System.Diagnostics.Process]::Start("outlook /safe")
> > Exception calling "Start" with "1" argument(s): "The system cannot
> > find the file specified"
> > At line:1 char:36
> > + [System.Diagnostics.Process]::Start( <<<< "outlook /safe")
> >
> > Thanks
> >
> > Andy
> >

>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
[diagnostics.process]::start("exe") PowerShell
redirecting standar output when using [System.Diagnostics.Process]::Start PowerShell
Wrap command shell in System.Diagnostics.Process PowerShell
Using ProcessStartInfo with [System.Diagnostics.Process]::Start PowerShell
Stupid [Diagnostics.Process]::Start("..") tricks PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46