Windows Vista Forums

psc1 launch problem
  1. #1


    Nicola Attico Guest

    psc1 launch problem

    This is maybe a dumb question, but I don't understand

    I've a very dummy psc1 script myscript.psc1 on C:\ that contains an endless
    loop (or what I suppose to be an endless loop...)

    $i=0
    while ($i -ge 0) {$i++;write-host $i}

    PS C:\> $i=0
    PS C:\> while ($i -ge 0) {$i++;write-host $i}
    1
    2
    3
    4
    ....


    If I try to execute from the cmd prompt or from the PS prompt as
    CMD C:\>powershell.exe .\myscript.psc1
    or
    PS C:\>powershell.exe .\myscript.psc1

    a PS windows is open for a millisecond but it's closed immediately.
    Can you please explain me what's going on?

    Thanks in advance,

    Nicola Attico





      My System SpecsSystem Spec

  2. #2


    Keith Hill [MVP] Guest

    Re: psc1 launch problem

    "Nicola Attico" <Nicola Attico@discussions.microsoft.com> wrote in message
    news:B30EDB76-55E3-4C20-A0F2-1618A4D190CE@microsoft.com...
    > If I try to execute from the cmd prompt or from the PS prompt as
    > CMD C:\>powershell.exe .\myscript.psc1
    > or
    > PS C:\>powershell.exe .\myscript.psc1


    Try this:

    PS C:\>powershell.exe -NoExit -Command .\myscript.ps1

    Note that the extension should be .PS1 and *not* .PSC1. :-)

    --
    Keith



      My System SpecsSystem Spec

  3. #3


    DBMwS Guest

    RE: psc1 launch problem

    "Nicola Attico" wrote:
    > If I try to execute from the cmd prompt or from the PS prompt as
    > CMD C:\>powershell.exe .\myscript.psc1
    >


    There is this gotcha when trying to run a PowerShell script from Cmd.exe.
    Here is a great blog entry "Running PowerShell Scripts from Cmd.exe" by Lee
    Holmes on
    http://www.leeholmes.com/blog/Runnin...romCmdexe.aspx

      My System SpecsSystem Spec

  4. #4


    Abhishek Agrawal [MSFT] Guest

    Re: psc1 launch problem

    Nicola,
    PSC1 is the extension for a PowerShell console files will PS1 is the
    extension for the powershell script file.

    What you wrote is a script, so should be saved in a ps1 file.

    PSC1 is a xml like file containing information on what snapins to load when
    powershell is started (think similar to MMC console files)

    Btw, the behavior you saw is actually a bug, We are not catching parse
    errors in PSC1 correctly.

    --
    Abhishek Agrawal [MSFT]
    PowerShell Team
    http://spaces.msn.com/abhishek225
    Microsoft Corporation
    This posting is provided "AS IS" with no warranties, and confers no rights.

    "Nicola Attico" <Nicola Attico@discussions.microsoft.com> wrote in message
    news:B30EDB76-55E3-4C20-A0F2-1618A4D190CE@microsoft.com...
    > This is maybe a dumb question, but I don't understand
    >
    > I've a very dummy psc1 script myscript.psc1 on C:\ that contains an
    > endless
    > loop (or what I suppose to be an endless loop...)
    >
    > $i=0
    > while ($i -ge 0) {$i++;write-host $i}
    >
    > PS C:\> $i=0
    > PS C:\> while ($i -ge 0) {$i++;write-host $i}
    > 1
    > 2
    > 3
    > 4
    > ...
    >
    >
    > If I try to execute from the cmd prompt or from the PS prompt as
    > CMD C:\>powershell.exe .\myscript.psc1
    > or
    > PS C:\>powershell.exe .\myscript.psc1
    >
    > a PS windows is open for a millisecond but it's closed immediately.
    > Can you please explain me what's going on?
    >
    > Thanks in advance,
    >
    > Nicola Attico
    >
    >




      My System SpecsSystem Spec

psc1 launch problem problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
VLC - Videolan Player Launch problem Fix filegrrrl Software 5 31 Dec 2008
3D flip (quick Launch) problem jdm Vista General 4 09 Jun 2008
psc1 file using community extensions Achim Domma PowerShell 0 11 Mar 2008
MS Outlook launch problem on Vsta. CityTrader Vista General 2 09 Jan 2008
Quick Launch problem Bestlife Vista General 1 15 Dec 2007