473,698 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting Info From Command Prompt

Hello all:

I have yet another question to ask the gurus of C#. I am trying to get
a list of all the connected computers on our domain. The only way I
know how is by going to the command prompt and typing net view. Is
there a way to use this list in a program? Is there a better way to
accomplish this task?

Thanks,

- John -
Nov 16 '05 #1
3 2045
If you choose to use net view and parse the output - you can use process
class to start "net view" command and redirect the output to a variable

or you can use WMI to get that information

HTH
John

"John Smith" <oh******@hotma il.com> wrote in message
news:ep******** ********@TK2MSF TNGP12.phx.gbl. ..
Hello all:

I have yet another question to ask the gurus of C#. I am trying to get a
list of all the connected computers on our domain. The only way I know
how is by going to the command prompt and typing net view. Is there a way
to use this list in a program? Is there a better way to accomplish this
task?

Thanks,

- John -

Nov 16 '05 #2
John,

I know of a couple of ways that you can get this information. One is to use
the System.Director yServices. You can use this class enumerate through the
computers in a domain. The other way is to use the System.Process class and
use NET VIEW and save the output in a string. I have posted a sample of each
below to demonstrate.

I hope this helps
-------------

//System.Director yServices
string path = "WinNT://<domain>";
string username = @"<domain>\<use rname>";
string password = "<password> ";
DirectoryEntry domain = new DirectoryEntry( path, username, password);
DirectoryEntrie s computers = domain.Children ;
computers.Schem aFilter.Add("Co mputer");
foreach(Directo ryEntry computer in computers)
{
Console.WriteLi ne(computer.Nam e);
}

//System.Process
ProcessStartInf o pi = new ProcessStartInf o();
pi.FileName = "NET";
pi.Arguments = "VIEW";
pi.UseShellExec ute = false;
pi.RedirectStan dardOutput = true;
pi.UseShellExec ute = false;
Process p = new Process();
p.StartInfo = pi;
p.Start();
string s = p.StandardOutpu t.ReadToEnd();
Console.WriteLi ne(s);

Nov 16 '05 #3
Wow, that's awesome guys, thanks for the tips.
Nov 16 '05 #4

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

Similar topics

1
1829
by: bidalah | last post by:
Hello, I am looking for basic info on installing and using MSDE. I am trying to install and play with MSDE on my PC (Win2000). I finally managed to work my way through installation, and named instances but I am finding no information on how to simply START the database engine and get to a sql prompt! I have manually started the MSSQL and SQLAGENT services, and tried running sqlservr.exe and osql.exe (just guessing) without success. ...
1
1905
by: Jay Feldman | last post by:
I've seen some messages about the screen flashing black for a few moments when executing a program in vb.net this may be because the command prompt settings were changed. when the command prompt is set to full screen mode instead of window mode, some monitors don't seem to be able to take it. when this happened to my computer, the screen would go black (for however long the command prompt window had to appear) and the monitor (new, 17"...
1
1043
by: emma_middlebrook | last post by:
Hi If I'm developing a console application, I'd rather not have to go to the project settings and edit the command line arguments each time and then run. Is there a way I can get a console box displayed automatically in the bin directory (also knowing which configuration the project was build under) so I can type in the program name and arguments in directly?
3
4373
by: dcruncher4 | last post by:
It is possible that we may be asked to restore a production tape, say 3 yrs later. We would prefer redirect restore for that. I am documenting a process to do a redirect restore. We take production backups via Legato. The big question is that how to get information about tablespace and containers from the tape backup. A search on this told me that db2ckbkp is the command to go for. I tested it on a backup residing on unix file system...
0
8672
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
8600
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
9021
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 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...
1
8892
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,...
1
6518
isladogs
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...
0
4361
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
4614
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3038
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
3
1998
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.