473,756 Members | 5,595 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I pull up data from the Command Prompt using VBA?

7 New Member
hey guys,

I need to do a program in VBA that runs the command prompt and gets data from there. Then I should be able to manipulate the data in VBA and store it in a table.

Do you have any suggestions, tips, sample codes, ideas? Any help will be highly appreciated.

THANK YOU!!!
Jun 13 '07 #1
8 4776
dima69
181 Recognized Expert New Member
hey guys,

I need to do a program in VBA that runs the command prompt and gets data from there. Then I should be able to manipulate the data in VBA and store it in a table.

Do you have any suggestions, tips, sample codes, ideas? Any help will be highly appreciated.

THANK YOU!!!
I am not sure of what you mean by "running the command prompt". Do you mean like running another application using VBA Shell commmand ? In that case, I think, the most common and reliable way to exchange data between application is by creating (temporary) files. So the major scheme would be like this:
1) From VBA: Run external application (using Shell)
2) From external application, create output file
3) From VBA: Read the file created in 2) and store the data in a table.
Jun 13 '07 #2
beginner4e
7 New Member
I am not sure of what you mean by "running the command prompt". Do you mean like running another application using VBA Shell commmand ? In that case, I think, the most common and reliable way to exchange data between application is by creating (temporary) files. So the major scheme would be like this:
1) From VBA: Run external application (using Shell)
2) From external application, create output file
3) From VBA: Read the file created in 2) and store the data in a table.
I thought of creating it as a file, but then I will not be able to manipulate the date. I want to be able to extract data even if the data has been changed in the Command Prompt. I thought also that I could use the Shell function, but all it does (or it did for me) is reading the first line from MS Office, and it doesnt go any further. What I want to do is, write a code, so that i can get an userID from the command propmt with all his information. If its saved as a file, then I will not be able to access it from any computer, but the one the files are saved on + I will not be able to update the data automatically, whenever changed in the command prompt....:(
Jun 13 '07 #3
dima69
181 Recognized Expert New Member
I thought of creating it as a file, but then I will not be able to manipulate the date. I want to be able to extract data even if the data has been changed in the Command Prompt. I thought also that I could use the Shell function, but all it does (or it did for me) is reading the first line from MS Office, and it doesnt go any further. What I want to do is, write a code, so that i can get an userID from the command propmt with all his information. If its saved as a file, then I will not be able to access it from any computer, but the one the files are saved on + I will not be able to update the data automatically, whenever changed in the command prompt....:(
I still cannot understand what are you trying to do and what data do you need to get.
Jun 13 '07 #4
beginner4e
7 New Member
I still cannot understand what are you trying to do and what data do you need to get.
ok, I will try to explain again.

So, I have data in the Command Prompt - userIDs, names...whateve r. I want to create a code in VBA that will execute the Command Prompt, and let me extract data the same way I would in the Command Prompt.

So, let's say I am in the command prompt and I am trying to see a specific user info, then i just open the program and type: net user userID /domain. and i get all the info of this person (userID, name, address...). With the VBA code, I want to execute the command prompt and then I want to be able to sort the data I get - say, just the userID and full name, without having the rest of the info...

Does it make sense now?
Jun 13 '07 #5
dima69
181 Recognized Expert New Member
ok, I will try to explain again.

So, I have data in the Command Prompt - userIDs, names...whateve r. I want to create a code in VBA that will execute the Command Prompt, and let me extract data the same way I would in the Command Prompt.

So, let's say I am in the command prompt and I am trying to see a specific user info, then i just open the program and type: net user userID /domain. and i get all the info of this person (userID, name, address...). With the VBA code, I want to execute the command prompt and then I want to be able to sort the data I get - say, just the userID and full name, without having the rest of the info...

Does it make sense now?
What if you redirect the output to the file, something like
Expand|Select|Wrap|Line Numbers
  1. net user userID /domain >1.txt
Jun 13 '07 #6
beginner4e
7 New Member
What if you redirect the output to the file, something like
Expand|Select|Wrap|Line Numbers
  1. net user userID /domain >1.txt
I thought about it, but I am still using the command prompt and my goal is to transfer all the activities to VBA. And also if I had 150 uses, then i would have 150 txt files that the code had to process. And also the .txt file is taking just the current info, but what if tomorrow somebody using the command prompt changed part of their info...then the program wouldnt give correct info...

I thought that it would be a good way to do it, but unfortunately it doesnt help. I am trying now to find a way to use VBA code to execute all these command prompt functions...It is pretty challenging, but i think its not impossible. Just i need to find the way to make these 2 programs exchange info and that will be it...I thought of using the shell func, using cmd.exe, but it gives me just the license info...

Do you have any ideas? Also, these libraries - kernel32.dll and/or netapi32.dll may be helpful, but I dont really know how to use them...
Jun 13 '07 #7
dima69
181 Recognized Expert New Member
I thought about it, but I am still using the command prompt and my goal is to transfer all the activities to VBA. And also if I had 150 uses, then i would have 150 txt files that the code had to process. And also the .txt file is taking just the current info, but what if tomorrow somebody using the command prompt changed part of their info...then the program wouldnt give correct info...

I thought that it would be a good way to do it, but unfortunately it doesnt help. I am trying now to find a way to use VBA code to execute all these command prompt functions...It is pretty challenging, but i think its not impossible. Just i need to find the way to make these 2 programs exchange info and that will be it...I thought of using the shell func, using cmd.exe, but it gives me just the license info...

Do you have any ideas? Also, these libraries - kernel32.dll and/or netapi32.dll may be helpful, but I dont really know how to use them...
Maybe you can find an answer in using Windows API functions, some of them can provide system information. There is a simple and usefull (and free) application called API-Guide which lists those functions, syntax and examples.
Jun 14 '07 #8
beginner4e
7 New Member
Maybe you can find an answer in using Windows API functions, some of them can provide system information. There is a simple and usefull (and free) application called API-Guide which lists those functions, syntax and examples.
I will try...Honestly, I don't know anything about these API functions, but I will definately check it out. Thank you! If you come up with another idea, please let me know.

Thanks again!
Jun 14 '07 #9

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

Similar topics

6
2623
by: EAS | last post by:
Is there any way of using Python to open a command prompt?
6
14596
by: Paul Deverson | last post by:
I'm a newbie to MySQL and am really confused about when I should be using the Command Line Client and when the DOS prompt. I'm using Windows XP and I've just installed MySQL 4.1.10. I can use the Command Line Client to logon as 'root'. It prompts me for a password and then I can create databases, etc. from the mysql prompt. However, if I wanted to logon as a different user, I'm not sure how to do it.
4
2532
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 this menu? thanks, glenn
1
1403
by: David Lozzi | last post by:
It use to be so easy in ASP, but now in ASP.NET i'm lost and confused. I'm trying to connect to a SQL database, open a table via a SQL string. Then take the returning recordset and do what I want to it: pull two fields, pull all fields, loop through the recordset, etc. But i'm lost... -- David Lozzi
34
6870
by: Roman Mashak | last post by:
Hello, All! I'm implementing simple CLI (flat model, no tree-style menu etc.). Command line looks like this: <command> <param1> <param2> ... <paramN> (where N=1..4) And idea is pretty simple: 1) get whole string of input line 2) preset table of strings matching <command> 3) preset table of function calls
9
2495
by: Endless Story | last post by:
My last version of Python was 2.4, running smoothly on XP with path c: \Python24 - no need even to include this path in PATH; everything worked as it's supposed to at the command line. Just installed Python 2.5, after uninstalling 2.4 (and also 2.3 which had lingered). Now if I open a shell in Windows Python is not available! Here are the symptoms: - If I open a shell using "Command line here" with XP Powertools, then enter "python"...
2
10031
by: Gil_H | last post by:
Hi, I'm trying to run a script over unix on a remote machine. In order to automate it, the procedure requests the following: 1. Using SSH connection. 2. Operating a command on the remote machine. 3. Expecting password or (yes/no) request and authorize it. I get an error (I thing that it occures at the last part (3) of the password request).
1
2457
by: beginner4e | last post by:
hi guys, I am trying to pull up some user information from the command prompt using VB. I read a lot about using the shell function and so on and so forth, but I don't really know how to start it. Could you please give me some suggestions? Or sample codes? Here is a part of the code I did: p.startinfo.useshellexecute = false p.startinfo.redirectstandardoutput = true p.startinfo.filename = "cmd.exe" p.startinfo.arguments = "user"...
4
2540
by: bkamrani | last post by:
Hi, This is a basic problem, but I want to print help content in a Command Prompt in WinXP and scrolling back to see the first lines. If I start a command prompt and run python, and then for example, it starts showing the help, which can be controlled by page or raw using Spacebar or Enter but after this ends, it seems that I can't scroll back to see again the first lines. In the Command Prompt Properties, layout tab, my Screen...
0
9456
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
9873
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
9846
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,...
0
9713
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
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, 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...
1
7248
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
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
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.