ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   System Environment Variables (https://www.excelbanter.com/excel-discussion-misc-queries/113241-system-environment-variables.html)

bdickert

System Environment Variables
 
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

Jim Thomlinson

System Environment Variables
 
msgbox Environ("UserName") & vbcrlf & Environ("ComputerName")
--
HTH...

Jim Thomlinson


"bdickert" wrote:

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


Kevin B

System Environment Variables
 
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
--
Kevin Backmann


"bdickert" wrote:

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


Gord Dibben

System Environment Variables
 
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


On Fri, 6 Oct 2006 13:41:01 -0700, Jim Thomlinson
wrote:

msgbox Environ("UserName") & vbcrlf & Environ("ComputerName")
--
HTH...

Jim Thomlinson


"bdickert" wrote:

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



bdickert

System Environment Variables
 
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

"Jim Thomlinson" wrote:

msgbox Environ("UserName") & vbcrlf & Environ("ComputerName")
--
HTH...

Jim Thomlinson


"bdickert" wrote:

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


bdickert

System Environment Variables
 
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

"Gord Dibben" wrote:

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


On Fri, 6 Oct 2006 13:41:01 -0700, Jim Thomlinson
wrote:

msgbox Environ("UserName") & vbcrlf & Environ("ComputerName")
--
HTH...

Jim Thomlinson


"bdickert" wrote:

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




bdickert

System Environment Variables
 
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


"Kevin B" wrote:

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
--
Kevin Backmann


"bdickert" wrote:

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


bdickert

System Environment Variables
 
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


"Jim Thomlinson" wrote:

msgbox Environ("UserName") & vbcrlf & Environ("ComputerName")
--
HTH...

Jim Thomlinson


"bdickert" wrote:

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


PapaDos

System Environment Variables
 
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...
--
Festina Lente


"bdickert" wrote:

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


PapaDos

System Environment Variables
 
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...
--
Festina Lente


"bdickert" wrote:

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



All times are GMT +1. The time now is 02:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com