473,398 Members | 2,120 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,398 software developers and data experts.

C# Command Prompt

Hi all,

Why when i create ProcessStartInfo to execute "cmd.exe" with arguments "nbstat -a 192.168.1.2" gives me a error " nbstat is not recognized as internal or external command" but in a normal(not a cmd executed by c#) command prompt it works!

Any ideas?

Many thanks,
Sebastian
Feb 25 '12 #1
9 4233
sorry the command is "nbtstat"...
Feb 25 '12 #2
PsychoCoder
465 Expert Mod 256MB
Show us how you're calling the process, seeing it may help get you a solution faster because then we'll be able to see how you're doing it.
Feb 26 '12 #3
Hi, thanks for the answer,
the code;

System.Diagnostics.Process process1;
process1 = new System.Diagnostics.Process();
process1.EnableRaisingEvents = false;
string strCmdLine;
strCmdLine = "/C nbtstat -a 192.168.2.110 | find \"Endereço MAC\" > teste.txt";
System.Diagnostics.Process.Start("CMD.exe", strCmdLine);
process1.Close();


Thanks,
Sebastian
Feb 27 '12 #4
GaryTexmo
1,501 Expert 1GB
Wow, I get the same result. That makes no sense either... I can run notepad.exe just fine and it's in the exact same folder location.

What are you trying to do? I googled around and it seems like people using nbtstat are usually trying to find a MAC address. If this is the case for you there are apparently other ways to do this that you may want to look into.

Definitely messed up behaviour though. I couldn't find any explanations over google... I'm as boggled as you are.
Feb 28 '12 #5
PsychoCoder
465 Expert Mod 256MB
I used the following code and got no error at all, show us the cose you're using.

Expand|Select|Wrap|Line Numbers
  1. public static void Process()
  2. {
  3.     var process1 = new System.Diagnostics.Process {EnableRaisingEvents = false};
  4.     const string strCmdLine = "/C nbtstat -a 192.168.2.110 | find \"Endereço MAC\" > teste.txt";
  5.     System.Diagnostics.Process.Start("CMD.exe", strCmdLine);
  6.     process1.Close();
  7.  
  8. }
Feb 28 '12 #6
I'll try your solution PhysoCoder thank you for your answer i'll give the feedback...

by the way Gary Texmo i did it in console application (not windows form) and it worked... i understand the difference but...

thank you all for the answer...

Sebastian
Feb 28 '12 #7
didn't work in windows form... maybe some kind of configuration of Visual studio...

thank you again!
Feb 28 '12 #8
GaryTexmo
1,501 Expert 1GB
See that's extra weird because I was doing mine in a console application and it was still telling me it couldn't find nbtstat. As I mentioned, I tried notepad (which is in the exact same folder) and it worked fine. My code was roughly equivalent to PsychoCoder's.

Glad it works magically for you though!
Feb 28 '12 #9
Yeah really weird...

my come in console is the similar or the same...
above is listed my code:


Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. public void cmdFunc(string ip)
  4.         {
  5.             System.Diagnostics.Process process1;
  6.             process1 = new System.Diagnostics.Process();
  7.             process1.EnableRaisingEvents = false;
  8.             string strCmdLine;
  9.             strCmdLine = "/C nbtstat -A "+ip+" | find \"Endereço MAC\" > teste.txt";
  10.  
  11.             System.Diagnostics.Process.Start("CMD.exe", strCmdLine);
  12.             process1.Close();
  13.             MessageBox.Show(strCmdLine);
  14.  
  15.  
  16.         }
  17.  

Hope you find a solution!
Feb 28 '12 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: msuk | last post by:
All, I am trying to use Regasm from the command prompt and have to keep putting the full file path of where my assembley is located. Does anyone know how to set it up so wherever I run the...
3
by: Rog | last post by:
Yes, I am guessing that typing cmd in the run windows will bring up the command prompt, but not the vs.net command prompt. Is there a switch(s) for accessing the vs.net command prompt? Or...
4
by: glenn | last post by:
I keep reading all sorts of books on VS that keep telling me to click on Tools/Visual Studio Command prompt to run this program or that program. However, I do not have such a menu choice. Where is...
4
by: Thomas Johnson | last post by:
I am trying to find out how to access the VS 2003 .Net command prompt. I am trying to execute the 'csc' command against a module but have no idea where to find the command prompt. Here's a stupid...
1
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...
6
by: Jwolf | last post by:
I have .net 2002 edu version and when it installed there was a shortcut to the .net command prompt. My CLR disk is scratched so I can't reinstall and so I just downloaded express. I dont know...
11
by: gert365 | last post by:
I'm working on a scirpt to be used on a windows machine and I need to automate a user's input on the command prompt. For example I'm using os.system('mycommand') to excute the commands I want. ...
6
by: Shooter4Life8 | last post by:
Hi, I am having trouble figureing out the best way to open a command prompt then write lines to it in VB.NET. Currently I have this code, but it execute's too fast I think because Dim psi As...
4
by: =?Utf-8?B?WUlndWNoaQ==?= | last post by:
Hi , I want to run a batch file from the c# code. Every time i run the batch file command prompt is displayed. I do not want to show this command prompt. Is there any way to suppress the...
4
by: Peter Nimmo | last post by:
Hi, I am writting a windows application that I want to be able to act as if it where a Console application in certain circumstances, such as error logging. Whilst I have nearly got it, it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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...
0
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,...
0
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...

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.