System Environment Variables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to capture information into an Excel Spreadsheet specifically a
couple of System Environment Variables like Computername, Username, etc. Is
this possible?
Please explain if this is possible. Thanks in advance. BD
 
you can get the username using VBA with the following command

application.UserName

To the best of my knowledge, for other system variables you'll have to do a
Windows API call
 
BD

Try this little "pulled off the groups" goodie to get a whack of stuff in a
message box.

Sub LISTENVIRON()
Dim new_value As String
Dim Txt As String
Dim i As Integer
i = 1
Do
new_value = Environ$(i)
If Len(new_value) = 0 Then Exit Do
Txt = Txt & new_value & vbCrLf
i = i + 1
Loop

Txt = Txt & "UserName = " & Application.UserName & vbCrLf
Txt = Txt & "Active Printer = " & Application.ActivePrinter & vbCrLf
Txt = Txt & "Default Path = " & Application.DefaultFilePath & vbCrLf
Txt = Txt & "Library Path = " & Application.LibraryPath & vbCrLf
Txt = Txt & "Operating System = " & Application.OperatingSystem & vbCrLf
Txt = Txt & "Organisation Name = " & Application.OrganizationName & vbCrLf
Txt = Txt & "Start Up Path = " & Application.StartupPath & vbCrLf
Txt = Txt & "Excel Version = " & Application.Version & vbCrLf
Txt = Txt & "Current Workbook Path = " & Application.ActiveWorkbook.Path & _
vbCrLf
Txt = Txt & "Active Workbook Name = " & Application.ActiveWorkbook.Name
MsgBox Txt
End Sub


Gord Dibben MS Excel MVP
Gord Dibben MS Excel MVP
 
Ok - thanks - so what interface are you using here - Excel or VB - I also
thought there was a KB article that would let these variables some how appear
-

Thanks again.
BD
 
Gord,
Thanks for the information, but how do you do this? This all has to be
silent behind the scenes stuff which I didn't mention. The reason for the
request is we have over 1000 machines and we are trying to determine which
notebooks have a recalled battery. We have an application that will dump the
information to a .csv file and I can use the information there, but it only
provides the serial number of the machine and battery - it also provides a
"Y" or "N" and only Sony batteries are being recalled. So I have been using
..bat and .cmd files to push this app to the notebook, using the set command
and capture the computername and username in one file and then save it to a
server, but without the username and computername in the file but when the
file is created, I user %username%%computername%.csv as the file name - I
don't want to have to key in 1000 computername and usernames into the .csv.
If this makes sense, I would appreciate any better way to handle this.

Thanks in advance.
BD
 
Thanks for the information, but how do you do this? This all has to be
silent behind the scenes stuff which I didn't mention. The reason for the
request is we have over 1000 machines and we are trying to determine which
notebooks have a recalled battery. We have an application that will dump the
information to a .csv file and I can use the information there, but it only
provides the serial number of the machine and battery - it also provides a
"Y" or "N" and only Sony batteries are being recalled. So I have been using
..bat and .cmd files to push this app to the notebook, using the set command
and capture the computername and username in one file and then save it to a
server, but without the username and computername in the file but when the
file is created, I user %username%%computername%.csv as the file name - I
don't want to have to key in 1000 computername and usernames into the .csv.
If this makes sense, I would appreciate any better way to handle this.

Thanks in advance.
BD
 
Thanks for the information, but how do you do this? This all has to be
silent behind the scenes stuff which I didn't mention. The reason for the
request is we have over 1000 machines and we are trying to determine which
notebooks have a recalled battery. We have an application that will dump the
information to a .csv file and I can use the information there, but it only
provides the serial number of the machine and battery - it also provides a
"Y" or "N" and only Sony batteries are being recalled. So I have been using
..bat and .cmd files to push this app to the notebook, using the set command
and capture the computername and username in one file and then save it to a
server, but without the username and computername in the file but when the
file is created, I user %username%%computername%.csv as the file name - I
don't want to have to key in 1000 computername and usernames into the .csv.
If this makes sense, I would appreciate any better way to handle this.

Thanks in advance.
BD
 
Looks to me that you should modify the way you create your CSV file to
include the informations you need into it. You are saying it is created from
a BAT file ?
Post the BAT file content if possible...
 
How many CSV files do you have ?
Do you combine them into one file ?
A simple command line could combine them into one file and include the
filenames into it...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top