Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2669
  • Last Modified:

Detect operating system using vbscript or javascript

I need to be able to detect  a users operating system and reroute him to the correct portal for an application I manage (Vista/XP/ThinClientMS2003).  I am currently using navigator.useragent to detect operating system, but I am finding that many users have installed applications that have altered this string rendering it useless (IE toolbars).

Is there a more accurate way of detecting the operating system that will not be effected by third party applications?  We are operating in an secure intranet is that helps anything.  VB or Java is fine.

Thanks
function checkOS()
{
 
  if((navigator.userAgent.indexOf('Windows NT 6.0') != -1))
    {
    OpSys = "<p align='center'><font size='5' face='calibri'><a href = 'http://eam-forms.bigoil.com/web/eamprod2.htm'>Continue to Infor EAM  - Vista</a></font></p>";
    document.getElementById('OSPage').innerHTML = OpSys;
    }
  else if((navigator.userAgent.indexOf('Windows NT 5.1') != -1))
    {
    OpSys = "<p align='center'><font size='5' face='calibri'><a href = 'http://eam-forms.bigoil.com/web/eamprod1.htm'>Continue to EAM - XP</a></font></p>";
    document.getElementById('OSPage').innerHTML = OpSys;
    }
  else if((navigator.userAgent.indexOf('Windows NT 5.2') != -1))
    {
    OpSys = "<p align='center'><font size='5' face='calibri'><a href = 'http://eam-forms.bigoil.com/web/eamprod1.htm'>Continue to EAM - Citrix</a></font></p>";
    document.getElementById('OSPage').innerHTML = OpSys;
    }
  else
  	{
  	OpSys = "<p align='center'><font size='5' face='calibri'>Warning: You are using an operating system that is not authorized by Bigoil.</font></p>";
  	document.getElementById('OSPage').innerHTML = OpSys;
  	}
  return OpSys;
 
}
 
var OpSys = checkOS();
 
document.write('<p align="center"><font face="calibri" color="FFFFFF">'+ navigator.userAgent);
document.write('APPVERSION' + navigator.platform);

Open in new window

0
lawrencebenson
Asked:
lawrencebenson
  • 3
  • 3
  • 3
1 Solution
 
Donald StewartNetwork AdministratorCommented:
try this script .vbs

strComputer = "."  
  
Set objWMIService = GetObject("winmgmts:" _  
  
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")  
  
Set objOS = objWMIService.ExecQuery ("select * from Win32_OperatingSystem  
  
where Primary=true")  
  
For Each osInfo in objOS  
  
wscript.echo osInfo.caption & vbtab & osInfo.version  
  
Next  

Open in new window

0
 
lawrencebensonAuthor Commented:
What does this script do?  Not really familiar with the syntax.
0
 
Donald StewartNetwork AdministratorCommented:
It uses WMI to query the info

looks like word wrap had it messed up a little should read as below

strComputer = "."  
  
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")  
  
Set objOS = objWMIService.ExecQuery ("select * from Win32_OperatingSystem where Primary=true")  
  
For Each osInfo in objOS  
  
wscript.echo osInfo.caption & vbtab & osInfo.version  
  
Next

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
RobSampsonCommented:
lawrence....looks like you're using JavaScript....Dave has posted VBScript code.  You should be able to put the code in VBScript tags....

Regards,

Rob.
0
 
lawrencebensonAuthor Commented:
I am getting an error that says "ActiveX compnent can't create object: 'GetObject' when I run the page with this script...
0
 
Donald StewartNetwork AdministratorCommented:
Do you get this error when you run the code on it's own?
0
 
RobSampsonCommented:
You may be running the page with anonymous access.  Try using Integrated Windows Authentication on that page, and the GetObject call should work correctly.

Regards,

Rob.
0
 
lawrencebensonAuthor Commented:
Does that require IIS?  This is running on a Unix server so I am not sure if I can use Integrated Windows Authentication.
0
 
RobSampsonCommented:
Are you using Apache?  This might help to configure that:

http://www.scribd.com/doc/6075648/Configuring-Apache-Web-Server-For-Single-SignOn-with-Likewise

There's a section called:
Install mod_auth_kerb_centeris and mod_auth_pam Authentication

Regards,

Rob.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now