473,395 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Get computer name

RR
I'm developing a web app and, for the user's convenience, I'd like to
display their local computer name (i.e. the name of the computer the browser
is running on).

I've looked very hard to find a script that will deliver this and I've also
tried some VBScript (which I know nothing about).

I found a script that did this:
var oShell = new ActiveXObject("Shell.Application");

then I thought to run
oShell.ShellExecute to echo %COMPUTERNAME%

But, I get a Permission Denied error.

How do I get the computer name? It's OK if the user has to grant permission
(I haven't found out how to get the Permission Denied to go away).

Thanks,
RR
Jul 20 '05 #1
3 61404
RR
BTW, I want this to run in Internet Explorer.

thanks,
RR
Jul 20 '05 #2
RR wrote:
I'm developing a web app and, for the user's convenience, I'd like to
display their local computer name (i.e. the name of the computer the browser
is running on).

I've looked very hard to find a script that will deliver this and I've also
tried some VBScript (which I know nothing about).

I found a script that did this:
var oShell = new ActiveXObject("Shell.Application");

then I thought to run
oShell.ShellExecute to echo %COMPUTERNAME%

But, I get a Permission Denied error.

How do I get the computer name? It's OK if the user has to grant permission
(I haven't found out how to get the Permission Denied to go away).

Thanks,
RR


var ax = new ActiveXObject("WScript.Network");
document.write(ax.UserName + '<br />');
document.write(ax.ComputerName + '<br />');

But you have to lower your security settings to dangerous and foolishly low
levels in the latest patched release of IE6SP1 to even get this to run.

If you insist on doing this, go to Tools -> Internet Options -> Security tab ->
Internet Zone -> Custom Level...

Change "Initialize and script ActiveX controls not marked as safe" to either
"Prompt" or "Enable"

A better choice might be:

Tools -> Internet Options -> Security tab -> Trusted sites Zone -> Sites...

Enter the domain name of the site you'd like the script to run from in the "Add
this Web site to the zone:" text box and click "Add". If the site is not https:,
you'll need to uncheck the "Require server verification (https:) for all sites
in this zone" checkbox before clicking "Add".

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #3
RR
Thanks Grant, it works well.

I've also added exception code as follows for gracefully handling the case
where
the security hasn't been enabled.

try
{
var ax = new ActiveXObject("WScript.Network");
document.write('User: ' + ax.UserName + '<br />');
document.write('Computer: ' + ax.ComputerName + '<br />');
}
catch (e)
{
document.write('Permission to access computer name is denied' + '<br />');
}

I hope this helps someone else.

cheers,
RR
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jim Scheffler | last post by:
I'm new to VB.NET programming and would like some help on a little project I've got going. How would I go about getting computer information on my local computer, i.e. serial number, hard drive...
4
by: Dr. StrangeDub | last post by:
Leaving network identification/DNS out of the picture, how does one change the name of a computer in a local Workgroup (in C#)? I implemented the SetComputerName() API call and that only seems to...
5
by: z. f. | last post by:
i need to get the computer name from an aspx page. i use System.Windows.Forms.SystemInformation.ComputerName() and it's working fine, but in second thought, it might not be recomended to use the...
0
by: Daylor | last post by:
hi. i have app that im developing in my computer with vs.net 2003 (offcourse). now, this app is running in other computer in the local intranet. in the other computer i dont have vs.net installed...
5
by: ThunderMusic | last post by:
Hi, I want to find the computer name and the company name from the network indentification informations. For the computer name, I found System.Net.Dns.GetHostName(), but I fgound nothing for...
6
by: Spyder | last post by:
When you go to "MyComputer" and get properties and select "Computer Name", you get the Domain or Workgroup a computer belongs to. I have looked thru MSDN library, the Internet, the Registry and in...
1
by: Lamis | last post by:
HI, I need to install a service that changes Host Name, computer name, on all our machines. I have tried to ways: First one: static void RenameHostName() { ManagementClass mComputerSystem =...
2
by: Vincent | last post by:
I have been trying to find some API routines that will allow me to determine the name of the computer that is accessing a file on a server. I have found the NetFileEnum call (returns the names of...
7
by: =?Utf-8?B?TWljaGFlbCBkZSBWZXJh?= | last post by:
to all, I was wondering if anyone has sample code that I can use to get information about a computer in active directory. For example, I want to know the date to when a computer was joined to a...
0
by: BrianT | last post by:
I'm trying to build code that allows the computer name to be changed, then asks the user to reboot to make the change affective. I got the code working when logged in as the local computer...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.