473,789 Members | 2,740 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Run command line code form my App...

Tim
Hi,

I want to run some command line instructions from within my C# windows forms
application. Basically when the application closes I want to logoff the
session if it was started remotely.

So how do I run text as if I was typing it into the command line?

Tim
Jan 3 '06 #1
2 8138
Tim <ti*@home.com > wrote:
I want to run some command line instructions from within my C# windows forms
application. Basically when the application closes I want to logoff the
session if it was started remotely.

So how do I run text as if I was typing it into the command line?


See http://www.pobox.com/~skeet/csharp/faq/#process.start for starting
another process. If you need to run commands which are built into the
shell, you'll need to run the shell explicitly.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 3 '06 #2
Use the Process class and execute the program you want to run. If it's a
built-in cmd-command you want to run, just start "cmd.exe /c commandname"

The /c tells cmd to terminate when done and the commandname is the internal
command (and optional parameters) you want it to perform.

Arild

"Tim" <ti*@home.com > wrote in message
news:FH******** ************@ne ws20.bellglobal .com...
Hi,

I want to run some command line instructions from within my C# windows
forms application. Basically when the application closes I want to logoff
the session if it was started remotely.

So how do I run text as if I was typing it into the command line?

Tim

Jan 3 '06 #3

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

Similar topics

1
8915
by: Matt | last post by:
I used to execute a command line script in IIS 4 using Dynuexec. This is a third part server object I installed on the server (http://www.dynu.com/dynuexec.asp). I installed this object onto my Windows 2003 Server and I cannot run the script from an ASP. No error is generated on the screen or in the event log. I think this has something to do with IIS not being able to access cmd.exe from IIS or maybe with COM permissions? Not sure though....
0
1353
by: Jon Paal | last post by:
what would be the command line code to add an image as a resource to a dll ?
3
2757
by: edfialk | last post by:
Hi, all I'm trying to do is load the php_mapscript.so library into php. Here's the php file: Code: dl("php_mapscriot.so") if (extension_loaded("MapScript")) echo "works!"; else echo "doesn't work!";
1
1546
by: gdarian216 | last post by:
okay I had a code that asked user to input a file name and instead i changed it to take the input from the command line. I now want to output results of some functions to an output file. I have one function that is suppose to count the words in the file but it isnt working I have a test file with two lines in it. abc def ghi gk ades and my program will output the file with the correct counter values but I have a lot of other junk...
11
2731
ironmonkey69
by: ironmonkey69 | last post by:
Right now, I have this python script that lets me choose which column of a text file that I can zero out. Them column nubmer is stored as the variable 'elem'. I also was given a sample of taking in command line arguements. I was wondering if anyone could help me intergrate this into the code so that from the command line I can input a number and have the script zero out the column. beginning text file: #Number of Bits 12 #Data 0 0 0...
0
2367
by: Liam Se Imihaf | last post by:
Hi all, I have a problem get the "command line" of a process in C# for some processes (ie, tomcat5.exe). I am using Win2003. I can use wmci as in: wmic process where name="tomcat5.exe" get processId, commandLine. This gives the process id and the command line. Now below C# code does not give me the command line.
6
5491
code green
by: code green | last post by:
The following code is part of a script actioned by a web form if(isset($_POST))#the form has been submitted { if($pls = $_POST) #hidden variable in pricesCostForm { $levels = array(); for($c=0;$c<$pls;$c++) { if(isset($_POST)) $levels = trim($_POST);
1
1937
by: Zygor1 | last post by:
Without going into details; I have the need to pass a string containing double backslashes \\ from the DOS command line and convert these to single backslashes in the code. The problem is if I do this from within perl code directly it is no problem but when I attempt to pass a string from the command line, it seems to lose something in the translation and when I try to do the replace it does not work. So the question is HOW to pass the...
0
1156
by: SCastro | last post by:
I can't remember the command line/code which has a "-1" to cause any alert/information window to not pop-up when you run a report.
0
9666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10410
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9020
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5418
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4093
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3701
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.