considerscs
asked on
VBScript or Bat file to pull IP and Hostname and put into Microsoft Outlook Subject Line
We would like to get a vbscript or bat file that can pull the computers IP address plus the hostname of the computer and put this into the subjectline on a new email.
The reason behind this is to help streamline support with those customers who never want to give us the correct information in their tickets.
Is this even possible?
We have a third party app that we can add this to their support icon in their system tray as an option for them to click and easily send us the email.
The reason behind this is to help streamline support with those customers who never want to give us the correct information in their tickets.
Is this even possible?
We have a third party app that we can add this to their support icon in their system tray as an option for them to click and easily send us the email.
Try this VBScript. I've literally just cobbled it together from code I found using Google, so it might need tweaking:-
dim NIC1, Nic, StrIP, CompName
Set NIC1 = GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration")
For Each Nic in NIC1
if Nic.IPEnabled then
StrIP = Nic.IPAddress(i)
Set WshNetwork = WScript.CreateObject("WScript.Network")
CompName= WshNetwork.Computername
set oShell = CreateObject("WScript.Shell")
oShell.Run "mailto:someone@somewhere.com?subject=Hostname=%22"&CompName&"%22%20IP=%22"&StrIP&"%22"
wscript.quit
end if
next
ASKER
Yes we want to pull all local IPv4 addresses from the machines.
We want the script to run and pull this information plus the host name and start their outlook (we use exchange), then open a new email with the hostname and ip address in the subject. Then they can type their issue and hit send.
We want the script to run and pull this information plus the host name and start their outlook (we use exchange), then open a new email with the hostname and ip address in the subject. Then they can type their issue and hit send.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This did it perfectly.
Thanks for all the help.
Thanks for all the help.
No problem, good luck with it.
Steve
Steve
mailto:user@domain.com?sub
so you could use that from a batch file together with the IP, depending upon whether you want an internal IP etc. There are a number of ways I suggest there depending upon what works for you -- there could quite easily be 2,3,4 or more IP addresses on a particular machine, e.g. virtual network cards for XP mode, VMWare etc, wireless at same time as wired etc.
Some of the ways I get the IP there you can see which IP is being used to get to a certain host for instance, i.e. maybe to get back to where you want to connect to them from.
http://scripts.dragon-it.co.uk/links/batch-get-tcpip-subnet
@echo off
for /f "tokens=3,4 delims= " %%a in ('route print ^| find " 0.0.0.0"') do (set gateway=%%a) & (set ipaddress=%%b)
START "mailto:helpdesk@mydomain.
which will send an email with something like this:
Computer:PCNAME.Domain:dom
You could do without the variable of properly configured email if you have an SMTP host available by sending straight to that, lots of ways, e.g. this is one I use:
http://scripts.dragon-it.co.uk/links/email-from-batch
Steve