i want to use the "SYSTEMINFO |find/i"Total Physical Memory:"" command and then get the response into a textbox(field) within access.
I have a database of all MachineNames in the company and for each machine name i have a field for the Memory, CPU, WindowsInstallDate etc etc but i want to be able to use a 'refresh/update' CmdButton on the form which will query the machine and update the relevant fields on the form.
i have been able to write the reply into >C:\output.txt and then read the contents of the output.txt file back into access and use that.... but ewwwww!!!! that's very messy!!!
there must be a simple way to set it as a variable?
like -
StrTempMemory = shell(CMD.exe "SYSTEMINFO |find/i'Total Physical Memory:'")
-
and then Textbox.Value = StrTempMemory
i know it's the wrong code but (off the top of my head) it demonstrates what i mean...
I do not believe that what you are requesting can easily be accomplished. What I have done is to create a Public Function that will accept a single Parameter representing the specific Information to be requested. The Function will then read the associated Value from your Output File and return it. The Control Sources of various Text Boxes can then be set to the Function, passing to it the appropriate Argument. I'll simply post the Code along with some sample Calls, and let you make the final determination as to its usefulness, since it still is ' kludgy'. - Public Function fRetrieveSystemInfo(strInfoParameter As String) As Variant
-
Dim strLine As String
-
Dim intPosOfSemiColon As Integer
-
Const conPATH_TO_INFO_FILE As String = "C:\Test\Output.txt"
-
-
Open conPATH_TO_INFO_FILE For Input As #1 ' Open file.
-
-
fRetrieveSystemInfo = Null 'Initialize to NULL
-
-
Do While Not EOF(1) 'Loop until end of file.
-
Line Input #1, strLine 'Read entire Line into variable.
-
If Left$(strLine, Len(strInfoParameter)) = strInfoParameter Then
-
intPosOfSemiColon = InStrRev(strLine, ":") 'Where is the last Semi-Colon?
-
If InStr(strLine, "Directory") > 0 Then 'Unique case
-
'Return the Value (Trimmed), given the specific Parameter
-
fRetrieveSystemInfo = Trim(Mid$(strLine, intPosOfSemiColon - 1))
-
Else
-
'Return the Value (Trimmed), given the specific Parameter
-
fRetrieveSystemInfo = Trim(Mid$(strLine, intPosOfSemiColon + 1))
-
End If
-
End If
-
Loop
-
-
Close #1 ' Close file.
-
End Function
- Debug.Print fRetrieveSystemInfo("Host Name")
-
ADEZII
- Debug.Print fRetrieveSystemInfo("OS Name")
-
Microsoft Windows XP Professional
- Debug.Print fRetrieveSystemInfo("OS Version")
-
5.1.2600 Service Pack 3 Build 2600
- Debug.Print fRetrieveSystemInfo("OS Manufacturer")
-
Microsoft Corporation
- Debug.Print fRetrieveSystemInfo("OS Configuration")
-
Member Workstation
- Debug.Print fRetrieveSystemInfo("OS Build Type")
-
Multiprocessor Free
- Debug.Print fRetrieveSystemInfo("System Up Time")
-
15 Days, 7 Hours, 13 Minutes, 32 Seconds
- Debug.Print fRetrieveSystemInfo("BIOS Version")
-
DELL - 7
- Debug.Print fRetrieveSystemInfo("Windows Directory")
-
C:\WINDOWS
- Debug.Print fRetrieveSystemInfo("System Directory")
-
C:\WINDOWS\system32
- Debug.Print fRetrieveSystemInfo("Total Physical Memory")
-
1,790 MB
- Debug.Print fRetrieveSystemInfo("Virtual Memory: In Use")
-
52 MB
- Debug.Print fRetrieveSystemInfo("Logon Server")
-
\\RPACFSO2
- Debug.Print fRetrieveSystemInfo("Nonsense String")
-
Null
- 'As the Control Source of a Text Box displaying Total Physical Memory:
-
=fRetrieveSystemInfo("Total Physical Memory")
4 4939 - You may use program's StdOut stream to omit temporary file. However it isn't much more simpler.
- You may use WinAPI GlobalMemoryStatus() function. However you may find it too much messy too.
- You may accept this imperfect world and let your program do all messy job for you.
Damn :(
that's a suprise :(
shtoopid kompooterz
I do not believe that what you are requesting can easily be accomplished. What I have done is to create a Public Function that will accept a single Parameter representing the specific Information to be requested. The Function will then read the associated Value from your Output File and return it. The Control Sources of various Text Boxes can then be set to the Function, passing to it the appropriate Argument. I'll simply post the Code along with some sample Calls, and let you make the final determination as to its usefulness, since it still is ' kludgy'. - Public Function fRetrieveSystemInfo(strInfoParameter As String) As Variant
-
Dim strLine As String
-
Dim intPosOfSemiColon As Integer
-
Const conPATH_TO_INFO_FILE As String = "C:\Test\Output.txt"
-
-
Open conPATH_TO_INFO_FILE For Input As #1 ' Open file.
-
-
fRetrieveSystemInfo = Null 'Initialize to NULL
-
-
Do While Not EOF(1) 'Loop until end of file.
-
Line Input #1, strLine 'Read entire Line into variable.
-
If Left$(strLine, Len(strInfoParameter)) = strInfoParameter Then
-
intPosOfSemiColon = InStrRev(strLine, ":") 'Where is the last Semi-Colon?
-
If InStr(strLine, "Directory") > 0 Then 'Unique case
-
'Return the Value (Trimmed), given the specific Parameter
-
fRetrieveSystemInfo = Trim(Mid$(strLine, intPosOfSemiColon - 1))
-
Else
-
'Return the Value (Trimmed), given the specific Parameter
-
fRetrieveSystemInfo = Trim(Mid$(strLine, intPosOfSemiColon + 1))
-
End If
-
End If
-
Loop
-
-
Close #1 ' Close file.
-
End Function
- Debug.Print fRetrieveSystemInfo("Host Name")
-
ADEZII
- Debug.Print fRetrieveSystemInfo("OS Name")
-
Microsoft Windows XP Professional
- Debug.Print fRetrieveSystemInfo("OS Version")
-
5.1.2600 Service Pack 3 Build 2600
- Debug.Print fRetrieveSystemInfo("OS Manufacturer")
-
Microsoft Corporation
- Debug.Print fRetrieveSystemInfo("OS Configuration")
-
Member Workstation
- Debug.Print fRetrieveSystemInfo("OS Build Type")
-
Multiprocessor Free
- Debug.Print fRetrieveSystemInfo("System Up Time")
-
15 Days, 7 Hours, 13 Minutes, 32 Seconds
- Debug.Print fRetrieveSystemInfo("BIOS Version")
-
DELL - 7
- Debug.Print fRetrieveSystemInfo("Windows Directory")
-
C:\WINDOWS
- Debug.Print fRetrieveSystemInfo("System Directory")
-
C:\WINDOWS\system32
- Debug.Print fRetrieveSystemInfo("Total Physical Memory")
-
1,790 MB
- Debug.Print fRetrieveSystemInfo("Virtual Memory: In Use")
-
52 MB
- Debug.Print fRetrieveSystemInfo("Logon Server")
-
\\RPACFSO2
- Debug.Print fRetrieveSystemInfo("Nonsense String")
-
Null
- 'As the Control Source of a Text Box displaying Total Physical Memory:
-
=fRetrieveSystemInfo("Total Physical Memory")
NeoPa 32,556
Expert Mod 16PB
There is no interface I'm aware of that allows VBA code to interact with a command prompt or any of it's possible commands.
You could screen-scrape from the Command Prompt window using the Windows API (Fish provides a link) or you can pipe the results to a file and read the contents later into memory. If I needed to do this I'd use the latter approach certainly.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Andreas Paasch |
last post by:
According to the manual for PHP, I should be able to run a shell command
within php.
I'm trying to copy some php files from one location to another one using
exec() but fail.
...
|
by: Yann.K |
last post by:
Hello.
Using Tkinter, i would create a widget which display a shell command return.
This return is long, and i would display a real time display (like with the
tail -f commande on Linux)
I...
|
by: Siemel Naran |
last post by:
Hi. I'm writing a command shell that reads commands from standard input.
At this point I have the command in a std::string. Now I want to execute
this command in the shell. From the Borland...
|
by: zhiwei wang |
last post by:
I remember that there is a function that could invoke shell command
such as "rm" "cp", directly in .c file. But I could not recall its
name, and I googled with nothing meaningful. I vaguely...
|
by: Tommy Lu |
last post by:
Hi, wondering if there is a way to interact the shell command with the
C# program? For example, if I type
c:\>ver
it then suppose to return the version of the OS I am currently using...
or
...
|
by: nyousfi |
last post by:
Hi
I have a Client Control that works absolutely beautifully but I need
to popup a browser window using this control but cant.
I thought the easiest way to do this would be to Run a Shell...
|
by: jcrouse |
last post by:
I apologize for starting another thread but the old one had a weird subject
line. Anyways...here is the code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As...
|
by: Kevin Mansel via .NET 247 |
last post by:
Ok, basically this is my problem. I'm building a console app tocall a dos program. So i'm using the Shell command to call theprogram, now depending on what happens, I want to read theoutput that...
|
by: ¹é¿ø¼® |
last post by:
Hello, everybody.
I want to call any shell command from php script using shell_exec(). The
problem is that the next line of the php script would not be run until a few
minutes after running the...
|
by: davidholmes |
last post by:
I need to load a csv file into excel with the shell command. My code works fine as long as excel is not already running but if there is another instance of excel open the shell command opens a new...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
| |