RE: C# console application executing command line commands?
- From: "Katherine Moss" <plymouthroamer285@xxxxxxxxx>
- To: <programmingblind@xxxxxxxxxxxxx>
- Date: Thu, 5 Aug 2010 09:24:30 -0400
But don't for get. You can use AutoIt for the scripting part of it and C#
can just be the base of it with the AutoIt dll being called.
-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Dave
Sent: Thursday, August 05, 2010 8:48 AM
To: programmingblind@xxxxxxxxxxxxx
Subject: Re: C# console application executing command line commands?
Usually, C# is a little too heavy weight to perform batch
file/scripting tasks so there's no real elegant way of doing this. C#
wants you to stay within the abstractions of processes, threads, and
objects.
With that said, why not just use the static member
Process.Start(string filename, string arguments);
http://msdn.microsoft.com/en-us/library/h6ak8zt5.aspx
i.e.
try {
Process.Start("copy", @"/s c:\documents\foo z:\bar\");
Process.Start("del", @"/f c:\documents\foo\temp.txt");
}
catch (Exception exp) {
}
...
On 8/5/10, black ares <matematicianu2003@xxxxxxxxxxx> wrote:
> if you do an application and put it a shortcut as send to
> then when that item is clicked you app is called and a string is passed as
> argument, the name of the object where right click happened.
> I have done this for an application which receives an sql file and changes
> with capitals all keywords.
> Now if you right click on a sql file and give open with xxx application it
> will create another sql file with all keywords capitalised.
>
> ----- Original Message -----
> From: "Jacob Kruger" <jacobk@xxxxxxxxxxxxxx>
> To: <ProgrammingBlind@xxxxxxxxxxxxx>
> Sent: Thursday, August 05, 2010 7:15 AM
> Subject: Re: C# console application executing command line commands?
>
>
>> Not specifically - this initial/current app is just one that would be
used
>> from send to context menu shortcut to generate playlists for a specific
>> media player, since it uses a slightly different format of text file
than,
>> for example, winamp generated playlists, so I really just want to be able
>> to
>> catch the argument/parameter sent to it - args[0], and then I can either
>> use
>> an actual System.IO.StreamWriter to write the relevant text file, or
>> should
>> be able to just call the relevant command line command to generate that
>> text
>> file, using a form of dir > filename command, and idea is also to keep it
>> as
>> low level/simple as possible to let it work on a wider variety of
>> machines,
>> but anyway.
>>
>> In other words, would actually have preferred to just handle this in a
>> batch
>> file, but it's been a while since used one of them to try manipulate any
>> variable values, etc.
>>
>> Looking into this also got me thinking about a few other possible uses
for
>>
>> a
>> command line/console app, and that's also why started wondering about
>> getting it to execute command line commands, and exit/finish off itsself
>> after code execution, but the other application/usage of console
>> applications would most likely be related to either utilities, or simple,
>> pseudo games etc.
>>
>> Stay well
>>
>> Jacob Kruger
>> Blind Biker
>> Skype: BlindZA
>> '...fate had broken his body, but not his spirit...'
>>
>> ----- Original Message -----
>> From: "Jamal Mazrui" <empower@xxxxxxxxx>
>> To: <programmingblind@xxxxxxxxxxxxx>
>> Cc: "Jacob Kruger" <jacobk@xxxxxxxxxxxxxx>
>> Sent: Thursday, August 05, 2010 4:16 AM
>> Subject: Re: C# console application executing command line commands?
>>
>>
>>> Are you interested in creating a console mode environment with a
>>> read-execute-print-loop (REPL)? Generally, this requires a dynamic
>>> language that includes an "Eval" function that can evaluate arbitrary
>>> code
>>> at runtime and display the result. C# and Visual Basic do not have such
>>> a
>>> feature. JScript .NET, IronPython, IronRuby, F#, Boo, and Nemerl -- all
>>> .NET languages -- do.
>>>
>>> Jamal
>>>
>>> On 8/4/2010 3:46 PM, Jacob Kruger wrote:
>>>>
>>>> Got that far, but apart from using
>>>>
>>>> System.Console.WriteLine to write strings to the console output,
without
>>>> them executing, and also trying to start a System.Diagnostics.Process
>>>> like have done in past to launch external apps, I don't seem to be able
>>>> to find out how to actually execute a command, and it always finishes
>>>> off with something like 'Press any key' when it finishes executing.
>>>>
>>>> Stay well
>>>>
>>>>
>>>> Jacob Kruger
>>>> Blind Biker
>>>> Skype: BlindZA
>>>> '...fate had broken his body, but not his spirit...'
>>>>
>>>> ----- Original Message -----
>>>> *From:* Katherine Moss <mailto:plymouthroamer285@xxxxxxxxx>
>>>> *To:* programmingblind@xxxxxxxxxxxxx
>>>> <mailto:programmingblind@xxxxxxxxxxxxx>
>>>> *Sent:* Wednesday, August 04, 2010 8:38 PM
>>>> *Subject:* RE: C# console application executing command line
>>>> commands?
>>>>
>>>> No you're not. All you have to do is to use the Console App
template
>>>> in VS2010 or 2008. That will set up the correct namespaces and such
>>>> and then just tell it what you want the program to do.
>>>>
>>>> *From:* programmingblind-bounce@xxxxxxxxxxxxx
>>>> <mailto:programmingblind-bounce@xxxxxxxxxxxxx>
>>>> [mailto:programmingblind-bounce@xxxxxxxxxxxxx] *On Behalf Of *Jacob
>>>> Kruger
>>>> *Sent:* Wednesday, August 04, 2010 1:40 PM
>>>> *To:* Program-l
>>>> *Cc:* ProgrammingBlind@xxxxxxxxxxxxx
>>>> *Subject:* C# console application executing command line commands?
>>>>
>>>> Ok, next silly question...
>>>>
>>>> Since have never really created command line/console applications,
>>>> am now just trying to figure out how to get a console application
>>>> created in C# to execute command line commands, and then how to get
>>>> it to close/exit itsself after operation?
>>>>
>>>> Idea would be to create a slightly trumped up target for something
>>>> like a send to shortcut that can do a bit more than your average
>>>> batch file.
>>>>
>>>> Have looked for simple examples, but am obviously, again, using
>>>> incorrect search terms or something - LOL!
>>>>
>>>> TIA
>>>>
>>>>
>>>> Jacob Kruger
>>>> Blind Biker
>>>> Skype: BlindZA
>>>> '...fate had broken his body, but not his spirit...'
>>>>
>>>>
>>>>
>>>> __________ Information from ESET NOD32 Antivirus, version of virus
>>>> signature database 5341 (20100804) __________
>>>>
>>>> The message was checked by ESET NOD32 Antivirus.
>>>>
>>>> http://www.eset.com
>>>>
>>>>
>>>> __________ Information from ESET NOD32 Antivirus, version of virus
>>>> signature database 5339 (20100804) __________
>>>>
>>>> The message was checked by ESET NOD32 Antivirus.
>>>>
>>>> http://www.eset.com
>>>>
>>>>
>>>>
>>>> __________ Information from ESET NOD32 Antivirus, version of virus
>>>> signature database 5339 (20100804) __________
>>>>
>>>> The message was checked by ESET NOD32 Antivirus.
>>>>
>>>> http://www.eset.com
>>>>
>>>>
>>>> __________ Information from ESET NOD32 Antivirus, version of virus
>>>> signature database 5341 (20100804) __________
>>>>
>>>> The message was checked by ESET NOD32 Antivirus.
>>>>
>>>> http://www.eset.com
>>> __________
>>> View the list's information and change your settings at
>>> http://www.freelists.org/list/programmingblind
>>>
>>>
>>> __________ Information from ESET NOD32 Antivirus, version of virus
>>> signature database 5341 (20100804) __________
>>>
>>> The message was checked by ESET NOD32 Antivirus.
>>>
>>> http://www.eset.com
>>>
>>>
>>>
>>
>>
>> __________ Information from ESET NOD32 Antivirus, version of virus
>> signature database 5341 (20100804) __________
>>
>> The message was checked by ESET NOD32 Antivirus.
>>
>> http://www.eset.com
>>
>>
>>
>>
>> __________ Information from ESET NOD32 Antivirus, version of virus
>> signature database 5341 (20100804) __________
>>
>> The message was checked by ESET NOD32 Antivirus.
>>
>> http://www.eset.com
>>
>>
>>
>> __________
>> View the list's information and change your settings at
>> http://www.freelists.org/list/programmingblind
>>
>
> __________
> View the list's information and change your settings at
> http://www.freelists.org/list/programmingblind
>
>
__________
View the list's information and change your settings at
http://www.freelists.org/list/programmingblind
__________ Information from ESET NOD32 Antivirus, version of virus signature
database 5341 (20100804) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
__________ Information from ESET NOD32 Antivirus, version of virus signature
database 5341 (20100804) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
__________
View the list's information and change your settings at
http://www.freelists.org/list/programmingblind
Other related posts:
- » C# console application executing command line commands? - Jacob Kruger
- » Re: C# console application executing command line commands? - Martin Slack
- » RE: C# console application executing command line commands? - Katherine Moss
- » Re: C# console application executing command line commands? - Jacob Kruger
- » Re: C# console application executing command line commands? - Jacob Kruger
- » RE: C# console application executing command line commands? - Katherine Moss
- » Re: C# console application executing command line commands? - Jamal Mazrui
- » RE: C# console application executing command line commands? - Katherine Moss
- » Re: C# console application executing command line commands? - Littlefield, Tyler
- » RE: C# console application executing command line commands? - Katherine Moss
- » Re: C# console application executing command line commands? - Jacob Kruger
- » Re: C# console application executing command line commands? - black ares
- » Re: C# console application executing command line commands? - black ares
- » Re: C# console application executing command line commands? - black ares
- » RE: C# console application executing command line commands? - DaShiell, Jude T. CIV NAVAIR 1490, 1, 26
- » Re: C# console application executing command line commands? - Dave
- » RE: C# console application executing command line commands? - Katherine Moss
- » Re: C# console application executing command line commands? - Littlefield, Tyler
- » Re: C# console application executing command line commands? - Jacob Kruger
- » Re: C# console application executing command line commands? - Jacob Kruger
- » Re: C# console application executing command line commands? - Jacob Kruger
- » RE: C# console application executing command line commands? - Katherine Moss
- » Re: C# console application executing command line commands? - Littlefield, Tyler
- » RE: C# console application executing command line commands? - Øyvind Lode
- » RE: C# console application executing command line commands? - Øyvind Lode
- » RE: C# console application executing command line commands? - Katherine Moss
- » RE: C# console application executing command line commands? - Katherine Moss
- » Re: C# console application executing command line commands? - Littlefield, Tyler
- » RE: C# console application executing command line commands? - Katherine Moss
- » Re: C# console application executing command line commands? - Littlefield, Tyler
- » RE: C# console application executing command line commands? - Katherine Moss
- » Re: C# console application executing command line commands? - black ares
- » Re: C# console application executing command line commands? - Jacob Kruger
- » Re: C# console application executing command line commands? - Jacob Kruger
- » Re: C# console application executing command line commands? - Littlefield, Tyler
- » Re: C# console application executing command line commands? - Martin Slack
- » Re: C# console application executing command line commands? - Jacob Kruger
- » Re: C# console application executing command line commands? - Jacob Kruger
- » RE: C# console application executing command line commands? - DaShiell, Jude T. CIV NAVAIR 1490, 1, 26
- » Re: C# console application executing command line commands? - Jacob Kruger