472,334 Members | 2,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,334 software developers and data experts.

get the return value executed in dos command

how to execute a command in dos in vb 6.,


ping a computer on dos
and then
print the return value on a listbox.,

tnx a lot.
Oct 26 '07 #1
10 23657
8,435 Expert 8TB
Probably depends on what version of VB you're using. But you should be able to use Shell or ShellExecute to run the command, and use a batch file to determine the return code and write it to a file. Then read that file when you get back to your VB code.
Oct 26 '07 #2
469 256MB
Killer has a great idea.

I have been playing about with batch files lately, try:

Expand|Select|Wrap|Line Numbers
  1. REM Pinging...
  3. Ping [ipaddress] > Log.txt
The results will then be output to Log.txt in the directory where your batch file is located.

Now open this file in VB and process the data to find what you require.
<do you know how to create batch files?>
Open Notepad > enter text above > save as > extension .bat not .txt
Oct 26 '07 #3
How to send the default value of ipaddress on the bat., file

Do I need to edit the content of .bat.,
open the batch file in vb then
changes its content then save
and run the batch file.,

Oct 30 '07 #4
Below is a working code which would run from VB or VBA on a Windows machine to execute any DOS command and display the result in a message box. I have used a Ping example, but any other command should work. Batch files are almost obsolete, although the DOS gurus still do a lot with it. The Windows scripting can do a lot more than the batch files.
Expand|Select|Wrap|Line Numbers
  1.     ExecuteDos "Ping sunrisetelecom.com"
  3. Function ExecuteDos(Comm As String)
  4.     Set objShell = CreateObject("WScript.Shell")
  5.     Set objExecObject = objShell.Exec("%comspec% /c " & Comm)
  6.     MsgBox objExecObject.StdOut.ReadAll()
  7. End Function
Oct 30 '07 #5
i got a runtime error when i run the script.,
runtime err: 438
"object doesn't support this property or method"

is there any reference i must include.,
i am using OS 98

Oct 30 '07 #6
8,435 Expert 8TB
Which line produces the error?
Oct 30 '07 #7
Which line produces the error?
the error points to line 5.,
Oct 30 '07 #8
the error points to line 5.,
Sorry xxoulmate...I don't even have a 98 installation around to re-produce the error, I have XP and 2003 servers around me.

Try Putting a set statement in your AutoExec.bat file something like below make sure the path of the Command.com file is correct:
Oct 30 '07 #9
8,435 Expert 8TB
Hm... so from the sound of it, the WScript.Shell object doesn't support the Exec method. Perhaps you have an old version of the scripting runtime. Have you tried Windows Update?
Oct 30 '07 #10
Hi, the above code is working fine. But before executing the command, command prompt is opening for a second and after that only we'r getting the values. Instead of that how to hide the command prompt that is showing for one sec/ upto the result.

Sasi A
Mar 5 '09 #11

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

Similar topics

by: Vipul Pathak | last post by:
Hello Friends ! I have the Following Code, that Executes a Stored Procedure and Attempt to read a Returned Integer Value from the StoredProc....
by: Sara Shoemaker | last post by:
Hi all - I am trying to launch a web browser from within my code for Linux. The problem is that I am getting no failure code back when the...
by: Sam | last post by:
In our C++ program, we are using the system call to execute another C++ program synchronously. The program executed by system runs without error...
by: tshad | last post by:
I am trying to set up a class to handle my database accesses. I can't seem to figure out how to get the return value from my dataReader from...
by: hans.bonefaas | last post by:
Hi all, I hope someone can help me with the following problem in ASP.net. I want to edit the information for a record in a database (MS Access)....
by: Andrew Robinson | last post by:
Are these two equivalent? Is one better than the other? I tend to go with #1 but started wondering.... Thanks, 1: using (SqlConnection cn =...
by: arnuld | last post by:
1.) we usually say /return 0/ indicates success e.g #include <iostream> int main() { int i=3; std::cout << i << std::endl; return 0;
by: Steven | last post by:
Hello, In English version of Windows Vista, run a command (for example icacls.exe) as administrator from Command Prompt, i can determine if the...
by: Jeff | last post by:
Hey ..NET 2.0 I have a stored procedure which calculates a value and return that value. I'm wondering if I should use ExecuteNonQuery,...
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...

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.