Click here to Skip to main content
15,885,216 members
Home / Discussions / C#
   

C#

 
QuestionGetting values from tasklist.exe /v Pin
CCodeNewbie7-Apr-12 6:24
CCodeNewbie7-Apr-12 6:24 
AnswerRe: Getting values from tasklist.exe /v Pin
Richard Andrew x647-Apr-12 6:42
professionalRichard Andrew x647-Apr-12 6:42 
GeneralRe: Getting values from tasklist.exe /v Pin
CCodeNewbie7-Apr-12 6:55
CCodeNewbie7-Apr-12 6:55 
AnswerRe: Getting values from tasklist.exe /v Pin
Alan N7-Apr-12 9:55
Alan N7-Apr-12 9:55 
AnswerRe: Getting values from tasklist.exe /v Pin
Richard Andrew x647-Apr-12 10:23
professionalRichard Andrew x647-Apr-12 10:23 
GeneralRe: Getting values from tasklist.exe /v Pin
CCodeNewbie7-Apr-12 11:18
CCodeNewbie7-Apr-12 11:18 
GeneralRe: Getting values from tasklist.exe /v Pin
Luc Pattyn7-Apr-12 11:35
sitebuilderLuc Pattyn7-Apr-12 11:35 
GeneralRe: Getting values from tasklist.exe /v Pin
CCodeNewbie7-Apr-12 11:55
CCodeNewbie7-Apr-12 11:55 
Hi Luc, gee thanks...didn't know you cared...

The issue is that if you run
C#
Process p = new Process();
p.StartInfo = new ProcessStartInfo("tasklist");
p.StartInfo.Arguments = " /v /nh /fo csv";
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.Start();
while (true)
{
    string o = p.StandardOutput.ReadLine();
    if (!string.IsNullOrEmpty(o))
    {
        string [] s = o.Split(',');
        Console.WriteLine(o);
        Console.ReadLine();
    }
}

occasionally, you only get the last 2 values of the first line. Also, you can't do this
C#
Console.WriteLine(a.Remove(0,1).Remove(a.Length -1,1));
without an exception 'System.ArgumentOutOfRangeException: Index and count must refer to a location within the string. Parameter name: count' which doesn't make much sense because if:-
string s = "bob";
s = s.Remove(s.length -1,1)
result = bo
why is Remove(a.Length -1,1) causing an exception?

Could anyone make any (relevant) suggestions...
AnswerRe: Getting values from tasklist.exe /v Pin
Luc Pattyn7-Apr-12 12:56
sitebuilderLuc Pattyn7-Apr-12 12:56 
GeneralRe: Getting values from tasklist.exe /v Pin
CCodeNewbie7-Apr-12 14:01
CCodeNewbie7-Apr-12 14:01 
GeneralRe: Getting values from tasklist.exe /v Pin
Eddy Vluggen8-Apr-12 8:53
professionalEddy Vluggen8-Apr-12 8:53 
GeneralRe: Getting values from tasklist.exe /v Pin
CCodeNewbie8-Apr-12 9:06
CCodeNewbie8-Apr-12 9:06 
GeneralRe: Getting values from tasklist.exe /v Pin
CCodeNewbie8-Apr-12 9:11
CCodeNewbie8-Apr-12 9:11 
GeneralRe: Getting values from tasklist.exe /v - update Pin
CCodeNewbie7-Apr-12 23:24
CCodeNewbie7-Apr-12 23:24 
Questionprogrammatically log into yahoo or godaddy Pin
DanYELL6-Apr-12 16:55
DanYELL6-Apr-12 16:55 
Questionuse select statement inside insert statement in ado.net Pin
mrx1006-Apr-12 12:22
mrx1006-Apr-12 12:22 
AnswerRe: use select statement inside insert statement in ado.net Pin
PIEBALDconsult6-Apr-12 12:55
mvePIEBALDconsult6-Apr-12 12:55 
AnswerRe: use select statement inside insert statement in ado.net Pin
JOAT-MON6-Apr-12 14:07
JOAT-MON6-Apr-12 14:07 
AnswerRe: use select statement inside insert statement in ado.net Pin
Luc Pattyn6-Apr-12 15:31
sitebuilderLuc Pattyn6-Apr-12 15:31 
QuestionCode Insertion Syntax Query Pin
mauricemcse6-Apr-12 6:39
mauricemcse6-Apr-12 6:39 
AnswerRe: Code Insertion Syntax Query Pin
Wes Aday6-Apr-12 6:59
professionalWes Aday6-Apr-12 6:59 
AnswerRe: Code Insertion Syntax Query Pin
Big Daddy Farang6-Apr-12 7:03
Big Daddy Farang6-Apr-12 7:03 
GeneralRe: Code Insertion Syntax Query Pin
mauricemcse6-Apr-12 10:11
mauricemcse6-Apr-12 10:11 
GeneralRe: Code Insertion Syntax Query Pin
Ennis Ray Lynch, Jr.6-Apr-12 10:24
Ennis Ray Lynch, Jr.6-Apr-12 10:24 
GeneralRe: Code Insertion Syntax Query Pin
Big Daddy Farang6-Apr-12 12:17
Big Daddy Farang6-Apr-12 12:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.