Re: shell commands via ASP

Discussion in 'ASP .Net' started by George Lake, May 10, 2006.

  1. George Lake

    George Lake Guest

    Ok,
    I tested it in VB and returns nothing. Output is nothing.
    I am using impersonation (as a domain admin).


    Dim p As New Process
    ' #tells operating system not to use a shell;
    p.StartInfo.UseShellExecute = False
    '#allow me to capture stdout, i.e. results
    p.StartInfo.RedirectStandardOutput = True
    'Say DOS Command is [EXEPath] CONNECT anotherargument
    p.StartInfo.Arguments = "CONNECT anotherargument"
    p.StartInfo.FileName = "qwinsta.exe"
    '#do not show MSDOS window
    p.StartInfo.CreateNoWindow = True
    '#do it!
    p.Start()
    Dim _processID As System.Int32 = p.Id
    '#capture results
    Dim output As String = p.StandardOutput.ReadToEnd()
    ' this is the output from the
    p.WaitForExit()
    p.Close()



    "Swanand Mokashi" <> wrote in message
    news:...
    > Here is a sample in C# -- you can use it in business layer and the output
    > below can be shown on the ASP.NET page
    >
    > //-----------------Start
    >
    > / #start a new process
    >
    > Process p = new Process();
    >
    > // #tells operating system not to use a shell;
    >
    > p.StartInfo.UseShellExecute = false;
    >
    >
    > //#allow me to capture stdout, i.e. results
    >
    > p.StartInfo.RedirectStandardOutput = true;
    >
    > //Say DOS Command is [EXEPath] CONNECT anotherargument
    >
    > p.StartInfo.Arguments = "CONNECT anotherargument";
    >
    > p.StartInfo.FileName =[EXEPath];
    >
    > //#do not show MSDOS window
    >
    > p.StartInfo.CreateNoWindow = true;
    >
    > //#do it!
    >
    > p.Start();
    >
    > System.Int32 _processID = p.Id;
    >
    > //#capture results
    >
    > string output = p.StandardOutput.ReadToEnd(); // this is the output from
    > the command
    >
    > //#wait for all results.
    >
    > p.WaitForExit();
    >
    > p.Close();
    >
    >
    >
    > //-----------------End
    >
    > HTH
    > --
    > Swanand Mokashi
    > Microsoft Certified Solution Developer (.NET) - Early Achiever
    > Microsoft Certified Application Developer (.NET)
    >
    > http://www.dotnetgenerics.com/
    > DotNetGenerics.com -- anything and everything about Microsoft .NET
    > technology ...
    >
    >
    > http://www.swanandmokashi.com/
    > http://www.swanandmokashi.com/HomePage/WebServices/
    > Home of the Stock Quotes, Quote of the day and Horoscope web services
    >
    >
    > "George Lake" <> wrote in message
    > news:%...
    >> ASP.NET
    >>
    >> "Swanand Mokashi" <> wrote in message
    >> news:...
    >>> ASP or ASP.NET ?
    >>>
    >>> --
    >>> Swanand Mokashi
    >>> Microsoft Certified Solution Developer (.NET) - Early Achiever
    >>> Microsoft Certified Application Developer (.NET)
    >>>
    >>> http://www.dotnetgenerics.com/
    >>> DotNetGenerics.com -- anything and everything about Microsoft .NET
    >>> technology ...
    >>>
    >>> http://www.swanandmokashi.com/
    >>> http://www.swanandmokashi.com/HomePage/WebServices/
    >>> Home of the Stock Quotes, Quote of the day and Horoscope web services
    >>>
    >>>
    >>> "George Lake" <> wrote in message
    >>> news:%...
    >>>> Hi,
    >>>> I need to run a few commands from the shell and display the output via
    >>>> ASP (VB)
    >>>>
    >>>> Any ideas?
    >>>>
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
     
    George Lake, May 10, 2006
    #1
    1. Advertising

  2. does the shell command return anything if you normally run it in say DOS
    window ?

    --
    Swanand Mokashi
    Microsoft Certified Solution Developer (.NET) - Early Achiever
    Microsoft Certified Application Developer (.NET)

    http://www.dotnetgenerics.com/
    DotNetGenerics.com -- anything and everything about Microsoft .NET
    technology ...

    http://www.swanandmokashi.com/
    http://www.swanandmokashi.com/HomePage/WebServices/
    Home of the Stock Quotes, Quote of the day and Horoscope web services


    "George Lake" <> wrote in message
    news:...
    > Ok,
    > I tested it in VB and returns nothing. Output is nothing.
    > I am using impersonation (as a domain admin).
    >
    >
    > Dim p As New Process
    > ' #tells operating system not to use a shell;
    > p.StartInfo.UseShellExecute = False
    > '#allow me to capture stdout, i.e. results
    > p.StartInfo.RedirectStandardOutput = True
    > 'Say DOS Command is [EXEPath] CONNECT anotherargument
    > p.StartInfo.Arguments = "CONNECT anotherargument"
    > p.StartInfo.FileName = "qwinsta.exe"
    > '#do not show MSDOS window
    > p.StartInfo.CreateNoWindow = True
    > '#do it!
    > p.Start()
    > Dim _processID As System.Int32 = p.Id
    > '#capture results
    > Dim output As String = p.StandardOutput.ReadToEnd()
    > ' this is the output from the
    > p.WaitForExit()
    > p.Close()
    >
    >
    >
    > "Swanand Mokashi" <> wrote in message
    > news:...
    >> Here is a sample in C# -- you can use it in business layer and the output
    >> below can be shown on the ASP.NET page
    >>
    >> //-----------------Start
    >>
    >> / #start a new process
    >>
    >> Process p = new Process();
    >>
    >> // #tells operating system not to use a shell;
    >>
    >> p.StartInfo.UseShellExecute = false;
    >>
    >>
    >> //#allow me to capture stdout, i.e. results
    >>
    >> p.StartInfo.RedirectStandardOutput = true;
    >>
    >> //Say DOS Command is [EXEPath] CONNECT anotherargument
    >>
    >> p.StartInfo.Arguments = "CONNECT anotherargument";
    >>
    >> p.StartInfo.FileName =[EXEPath];
    >>
    >> //#do not show MSDOS window
    >>
    >> p.StartInfo.CreateNoWindow = true;
    >>
    >> //#do it!
    >>
    >> p.Start();
    >>
    >> System.Int32 _processID = p.Id;
    >>
    >> //#capture results
    >>
    >> string output = p.StandardOutput.ReadToEnd(); // this is the output from
    >> the command
    >>
    >> //#wait for all results.
    >>
    >> p.WaitForExit();
    >>
    >> p.Close();
    >>
    >>
    >>
    >> //-----------------End
    >>
    >> HTH
    >> --
    >> Swanand Mokashi
    >> Microsoft Certified Solution Developer (.NET) - Early Achiever
    >> Microsoft Certified Application Developer (.NET)
    >>
    >> http://www.dotnetgenerics.com/
    >> DotNetGenerics.com -- anything and everything about Microsoft .NET
    >> technology ...
    >>
    >>
    >> http://www.swanandmokashi.com/
    >> http://www.swanandmokashi.com/HomePage/WebServices/
    >> Home of the Stock Quotes, Quote of the day and Horoscope web services
    >>
    >>
    >> "George Lake" <> wrote in message
    >> news:%...
    >>> ASP.NET
    >>>
    >>> "Swanand Mokashi" <> wrote in message
    >>> news:...
    >>>> ASP or ASP.NET ?
    >>>>
    >>>> --
    >>>> Swanand Mokashi
    >>>> Microsoft Certified Solution Developer (.NET) - Early Achiever
    >>>> Microsoft Certified Application Developer (.NET)
    >>>>
    >>>> http://www.dotnetgenerics.com/
    >>>> DotNetGenerics.com -- anything and everything about Microsoft .NET
    >>>> technology ...
    >>>>
    >>>> http://www.swanandmokashi.com/
    >>>> http://www.swanandmokashi.com/HomePage/WebServices/
    >>>> Home of the Stock Quotes, Quote of the day and Horoscope web services
    >>>>
    >>>>
    >>>> "George Lake" <> wrote in message
    >>>> news:%...
    >>>>> Hi,
    >>>>> I need to run a few commands from the shell and display the output via
    >>>>> ASP (VB)
    >>>>>
    >>>>> Any ideas?
    >>>>>
    >>>>>
    >>>>
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
    >
     
    Swanand Mokashi, May 11, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Allan Rojas

    Shell commands in ASP.NET?

    Allan Rojas, Jul 3, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    3,769
    dave wanta
    Jul 3, 2003
  2. George Lake

    shell commands via ASP

    George Lake, May 9, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    840
    George Lake
    May 9, 2006
  3. George Lake

    bump shell commands via ASP

    George Lake, May 11, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    437
    George Lake
    May 11, 2006
  4. Ben Pfaff

    Re: man pages for C commands (GCC commands)

    Ben Pfaff, Jun 24, 2003, in forum: C Programming
    Replies:
    4
    Views:
    4,009
    Thomas Stegen
    Jun 28, 2003
  5. mlay

    executing shell commands in asp

    mlay, Nov 9, 2003, in forum: ASP General
    Replies:
    2
    Views:
    198
    Aaron Bertrand [MVP]
    Nov 9, 2003
Loading...

Share This Page