Mygposts said:
I need a batch file that a user can click on and have it display their user
name, machine name and ip addresses for that machine.
I should display a command window displaying:
I am logged on as XXX
My computer name is XXX
My IP addresses are XXXXXXXX, XXXXXXX
I have one that works, but it displays the ipconfig commands and adds
clutter.
ipconfig | FIND /I "ip address"
@echo I am logged in as %username%. My computer name is %computername%.
pause
How can this be cleaned up so they see "My IP address is (ip address)"
instead of ipconfig | FIND /I "ip address"
I can't resist Spamcop's galant invitation? Here you go:
@echo off
echo\
echo I am logged on as %UserName%.
echo My computer's name is %ComputerName%.
echo My IP settings are
ipconfig | find "." | find /i /v "suffix"
echo\
echo Press the Space bar to close this window.
pause > nul
If you want something a little more upmarket then this VB Script file should
fit the bill. You must unwrap any lines that your newsreader has wrapped
around, then remove the line numbers and save it as c:\xyz.vbs. You then
invoke it with this command:
wscript c:\xyz.vbs
[01] Set oWshShell = CreateObject("WScript.Shell")
[02] Set oWMIService = GetObject("winmgmts:\\.\root\cimv2")
[03] Set colNetAdapters = oWMIService.ExecQuery _
[04] ("Select * from Win32_NetworkAdapterConfiguration Where
IPEnabled=True")
[05] MacAddress = ""
[06] LF = Chr(10)
[07]
[08] For Each oNetAdapter In colNetAdapters
[09] If MacAddress = oNetAdapter.MACAddress then Exit For
[10] MacAddress = oNetAdapter.MACAddress
[11] sLine = oWshShell.ExpandEnvironmentStrings("User Name: %UserName%") &
LF _
[12] & oWshShell.ExpandEnvironmentStrings("Computer Name: %ComputerName%")
& LF _
[13] & "MAC Address: " & oNetAdapter.MACAddress & LF _
[14] & "DHCP Enabled: " & oNetAdapter.DHCPEnabled & LF _
[15] & Compile("IP Address",oNetAdapter.IPAddress) & LF _
[16] & Compile("Default Gateway", oNetAdapter.DefaultIPGateway) & LF _
[17] & Compile("Subnet Mask", oNetAdapter.IPSubnet) & LF _
[18] ' & Compile("DNS_Server", oNetAdapter.DNSServerSearchOrder) & LF
[19] Next
[20] MsgBox sLine, 0, "Status Report"
[21]
[22] Function Compile(Subject, Details)
[23] If IsArray(Details) Then
[24] For i = 0 To UBound(Details)
[25] Line = Subject & ": " & Details(i)
[26] Next
[27] Else
[28] Line = Subject & ": " & Details
[29] End If
[30] Compile = Line
[31] End Function