SgDotNet
Singapore Professional .NET User Group -For Cool Developers

Shell commands in C#

rated by 0 users
This post has 3 Replies | 2 Followers

Top 50 Contributor
Posts 49
samsudeen_arif Posted: 08-02-2005 4:10 PM
Hi,

During my good old days I used to happily execute shell commands from my VB applications. Can anyone advise me if I can continue to do the same in C#. If so will there be any security implications involved.

Thanks,
Samsudeen

Top 25 Contributor
Posts 180
This post might give you some clue:

http://www.msfn.org/board/lofiversion/index.php/t8712.html

I didn't try it, but that's a good question which I'll need something similiar soon.

regards,
choongseng

my development sketch book my personal blog

Top 25 Contributor
Posts 146

 choongseng wrote:
This post might give you some clue:

http://www.msfn.org/board/lofiversion/index.php/t8712.html

 

Yes, it's one of those question that I have at the moment also. 

I also came across using the following:

AppDomain newDomain = AppDomain.CreateDomain("newDomain");

newDomain.ExecuteAssembly("C:\windows\notepad.exe");

 

I have not tried this, and wonder how this differs from Process.Start().  Maybe if time allows, I will dig deeper.

Knowledge, Hardwork, Patience...
Top 25 Contributor
Posts 232
 Cyrus Crypt wrote:

AppDomain newDomain = AppDomain.CreateDomain("newDomain");

newDomain.ExecuteAssembly("C:\windows\notepad.exe");

I have not tried this, and wonder how this differs from Process.Start().  Maybe if time allows, I will dig deeper.

Process.Start() creates a new process to host the application by default. Before .Net was introduced, Win32 must run any application into its own process in isolation so that when one process is stopped or crashed, other processes can continue to operate. I believe one of the primary reason that the Process component was carried forward is for backward compatibility. 

.Net introduces the AppDomain which is a lightweight unit for apllication isolation, fault tolerance and security. A process can now host multiple application domains. The CLR can guarantee that one application domain can run indepently of another application domain in the same process. This is a much better usage of resources comparing with the Win32 Process.   

Page 1 of 1 (4 items) | RSS
Copyright SgDotNet 2004-2009
Powered by Community Server (Commercial Edition), by Telligent Systems