Link to home
Start Free TrialLog in
Avatar of PeterHing
PeterHingFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Retreive Computer Name - VBScript / ASP

Hi All,

Can anyone explain why when I put this code (found on another post) into my page, nothing happens?

<script language="VBScript">
Set oNetwork = CreateObject("WScript.Network")
sUserName = oNetwork.UserName
sComputerName = oNetwork.ComputerName
MsgBox("UserName = " & sUserName & vbCRLF & "ComputerName = " & sComputername)
</script>

Many Thanks,

Pete
ASKER CERTIFIED SOLUTION
Avatar of ddrudik
ddrudik
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PeterHing

ASKER

ddrudik,

Perfect - Thanks for that - As it now works perfectly - However, the results come back as

PCName.uk.companyname.intranet

Is there a way I can split it down so it just shows the PC Name?

(Points Increased to 300)
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry, missed the comment posting, lsavidge is correct.  If you want to shorthand the split/(0) lines into one:

<%
sComputerFQDN = "PCName.uk.companyname.intranet"
sComputerHostname = split(sComputerFQDN, ".")(0)
%>

I am glad it worked well for you.
Thanks for the question and the points.