Martin said:
Is it possible to make the caption of "My Computer" to include the
workstation name?
Hi
Here is a vbscript that creates a shortcut on the desktop in this format:
<username> on <computername> (IP <IP address>)
e.g
TorgeirB on Y4035380 (IP 111.194.155.108)
If the user double click on it, it will start msinfo32.exe (System Info).
It also deletes all existing shortcuts with the filter
"<username> on *.lnk" to cleanup old links (necessary
because computer name and IP address can change).
It can be launched from e.g. a logon script or Run in registry
etc. (put the code below in a text file with extension .vbs and
launch it with wscript.exe "<path to vbs file>").
'--------------------8<----------------------
Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("scripting.FileSystemObject")
Set oWshNet = CreateObject("WScript.Network")
sUserName = oWshNet.UserName
sComputerName = oWshNet.ComputerName
sDesktopPath = oShell.SpecialFolders("Desktop") & "\"
sWinSysDir = oFSO.GetSpecialFolder(1).Path & "\"
' remove old shortcut if it exist
On Error Resume Next
oFSO.DeleteFile sDesktopPath & sUserName & " on *.lnk", True
On Error Goto 0
' get IP address
aNICstatus = GetIPAddresses
sIp = aNICstatus(UBound(aNICstatus))
sIp = "136.164.48.108"
Set oShellLink = oShell.CreateShortcut(sDesktopPath & sUserName _
& " on " & sComputerName & " (IP " & sIp & ").lnk")
sLinkTargetPath = oShellLink.TargetPath
' if you want an empty targetpath:
oShellLink.TargetPath = ""
'If you want to start msinfo32.exe if you click on the link.
On Error Resume Next
sMsInfoPath = "" ' init value
sMsInfoPath = oShell.Regread _
("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msinfo32.exe\")
On Error Goto 0
oShellLink.TargetPath = sMsInfoPath
' if you don't want msinfo32's icon, use another one instead
'oShellLink.IconLocation = sWinSysDir & "Shell32.dll, 21"
' create the shortcut
oShellLink.Save
Function GetIPAddresses()
'=====
' Based on a Michael Harris script, modified be Torgeir Bakken
'
' Returns array of IP Addresses as output
' by ipconfig or winipcfg...
'
' Win98/WinNT have ipconfig (Win95 doesn't)
' Win98/Win95 have winipcfg (WinNt doesn't)
'
' Note: The PPP Adapter (Dial Up Adapter) is
' excluded if not connected (IP address will be 0.0.0.0)
' and included if it is connected.
'=====
set sh = createobject("wscript.shell")
set fso = createobject("scripting.filesystemobject")
Set Env = sh.Environment("PROCESS")
if Env("OS") = "Windows_NT" then
workfile = Env("TEMP") & "\" & fso.gettempname
sh.run "%comspec% /c ipconfig >" & Chr(34) & workfile & Chr(34),0,true
else
'winipcfg in batch mode sends output to
'filename winipcfg.out
workfile = "winipcfg.out"
sh.run "winipcfg /batch" ,0,true
end if
set sh = nothing
set ts = fso.opentextfile(workfile)
data = split(ts.readall,vbcrlf)
ts.close
set ts = nothing
fso.deletefile workfile
set fso = nothing
arIPAddress = array()
index = -1
for n = 0 to ubound(data)
data(n) = replace(data(n),vbCr,"")
if instr(data(n),"IP Address") then
parts = split(data(n),":")
'if trim(parts(1)) <> "0.0.0.0" then
if instr(trim(parts(1)), "0.0.0.0") = 0 then
index = index + 1
ReDim Preserve arIPAddress(index)
arIPAddress(index)= trim(cstr(parts(1)))
end if
end if
next
GetIPAddresses = arIPAddress
End Function
'--------------------8<----------------------