473,395 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Command line in C#

Hi,
i have a Win32 application in CSharp and i have to run command "net send
....." (these is a command for windows command-line) from this application,
but i don't know how can i run this command. How class can i use? Or how
command in CSharp exists for this issues?

Thanks a lot
Lubos
Nov 16 '05 #1
5 1559
Have a look at the Process class.

Niki

"Luboš Šlapák" <lu**********@centrum.cz> wrote in
news:O3**************@TK2MSFTNGP09.phx.gbl...
Hi,
i have a Win32 application in CSharp and i have to run command "net send
...." (these is a command for windows command-line) from this application,
but i don't know how can i run this command. How class can i use? Or how
command in CSharp exists for this issues?

Thanks a lot
Lubos

Nov 16 '05 #2
Lubos,

The System.Diagnostics.Process class can be used for this. See, for
example, http://groups.google.com/groups?selm...5B0C239C%40a.a.

HTH,
Nicole
"Luboš Šlapák" <lu**********@centrum.cz> wrote in message
news:O3**************@TK2MSFTNGP09.phx.gbl...
Hi,
i have a Win32 application in CSharp and i have to run command "net send
...." (these is a command for windows command-line) from this application,
but i don't know how can i run this command. How class can i use? Or how
command in CSharp exists for this issues?

Thanks a lot
Lubos

Nov 16 '05 #3
I have yet one question.

The command "net send" return a string value on next line, can i catch this
line and use it in my Win32 application?

If is it possible, how can i catch it?

Thanks
"Nicole Calinoiu" <ni*****@somewhere.net> píše v diskusním příspěvku
news:uW**************@tk2msftngp13.phx.gbl...
Lubos,

The System.Diagnostics.Process class can be used for this. See, for
example, http://groups.google.com/groups?selm...5B0C239C%40a.a.

HTH,
Nicole
"Luboš Šlapák" <lu**********@centrum.cz> wrote in message
news:O3**************@TK2MSFTNGP09.phx.gbl...
Hi,
i have a Win32 application in CSharp and i have to run command "net send
...." (these is a command for windows command-line) from this application, but i don't know how can i run this command. How class can i use? Or how
command in CSharp exists for this issues?

Thanks a lot
Lubos


Nov 16 '05 #4
"Luboš Šlapák" <lu**********@centrum.cz> wrote in
news:%2****************@TK2MSFTNGP11.phx.gbl...
I have yet one question.

The command "net send" return a string value on next line
No, that's output. That's not the same. Executables do have return values,
but that's something completely different.
, can i catch this
line and use it in my Win32 application?
If is it possible, how can i catch it?


Use the Process.StandardOutput property to read the process's output. You'll
find sample code in the documentation entry of that property.

Niki
Nov 16 '05 #5
e.g.

public class ProcessDataRetriever
{
public static string[] GetData(string cmd, string args)
{
using(Process p = new Process())
{
ProcessStartInfo psi = new ProcessStartInfo(cmd, args);
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.CreateNoWindow = true;
p.StartInfo = psi;
p.Start();
ArrayList a = new ArrayList(); string s;
while((s = p.StandardOutput.ReadLine()) != null) a.Add(s);
p.Close();
return (string[])a.ToArray(typeof(string));
}
}
}

"Niki Estner" wrote:
"Luboš Šlapåk" <lu**********@centrum.cz> wrote in
news:%2****************@TK2MSFTNGP11.phx.gbl...
I have yet one question.

The command "net send" return a string value on next line


No, that's output. That's not the same. Executables do have return values,
but that's something completely different.
, can i catch this
line and use it in my Win32 application?
If is it possible, how can i catch it?


Use the Process.StandardOutput property to read the process's output. You'll
find sample code in the documentation entry of that property.

Niki

Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Joe | last post by:
I'm using Python 2.4 on Windows XP SP2. I'm trying to receive a command line argument that is a newline (\n) Here is the command line to use sample.py "\n" Here is a sample.py script
7
by: Steve M | last post by:
I'm trying to invoke a Java command-line program from my Python program on Windows XP. I cannot get the paths in one of the arguments to work right. The instructions for the program describe the...
4
by: lkrubner | last post by:
I'd like to write a PHP script to be used from the command line on a Unix machine. I'd like for the script to put together a string, turn it into a web page, print it, then return control the...
5
by: randyelliott | last post by:
Good Day, I have a MS Access (Access 2000 now upgraded to 2003) database that tracks customer information. One function of this database is to create an encrypted license file for our software,...
34
by: Roman Mashak | last post by:
Hello, All! I'm implementing simple CLI (flat model, no tree-style menu etc.). Command line looks like this: <command> <param1> <param2> ... <paramN> (where N=1..4) And idea is pretty simple: ...
3
by: Double Echo | last post by:
Hi all, I'm using PHP 4.4.2, and use PHP on both the command-line and the web. I am running PHP on SuSE 10 Linux , in a VMware 5.5 workstation, using Apache 2.0.55 , on my Dell laptop. ...
4
by: Bit byte | last post by:
I have a project that I normally build (without problems) from the DevStudio IDE. However, I have embarked on automating all my builds (this test project being one of several). The project...
2
by: Jim | last post by:
Hello, I need a program that will traverse a directory tree to ensure that there are unix-style line endings on every file in that tree that is a text file. To tell text files from others I...
51
by: Ojas | last post by:
Hi!, I just out of curiosity want to know how top detect the client side application under which the script is getting run. I mean to ask the how to know whether the script is running under...
7
by: Jwe | last post by:
Hi, I've written a program which has both a command line interface and Windows form interface, however it isn't quite working correctly. When run from command line with no arguments it should...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.