473,687 Members | 3,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Run command line code form my App...


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?

Jan 3 '06 #1
2 8131
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.


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

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?


Jan 3 '06 #3

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

Similar topics

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....
by: Jon Paal | last post by:
what would be the command line code to add an image as a resource to a dll ?
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!";
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...
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...
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.
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);
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...
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.
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,...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
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...
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
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.