Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detecting Operating System 1

Status
Not open for further replies.

Geraint1

Programmer
Sep 28, 2001
1
GB
Is it possible to detect the Operating system of the client in vbscript. I need to determine of a user has windows NT, 95 or 98.

Thanks
 
Hello, Geraint1.

It sure can be done. This type of problem is usually classified under the heading of "sniffing". So if you make a search on this keyword, you will find plenty.

It seems not much left for a new personal initiative. It does not. Most of the scripts I find are overstuffed and becoming hard to comprend at the end. If you are not very familiar with sniffing, my script below may be useful as a stepping stone. It is constructed for vbscript and javascript engine crossplatform. Hence, you will find vbscript part not performing in NS. I use only the read-only property userAgent of navigator object which contains by itself alone the complete info on browser, engine and OS of the client. I find using other properties for this purpose such as appName, appCodeName, appVersion unnecessarily burdening.

This introduces the construction. Below is the script itself. Hope you like it.

regards - tsuji
Code:
<HTML><HEAD>
<TITLE>Sniff userAgent - /tsuji/</TITLE>
</HEAD>
<BODY>
<FORM NAME=&quot;vbDetect&quot;>
<P><B>VBScript<BR>
<INPUT TYPE=&quot;Text&quot; NAME=&quot;vbBrowser&quot; SIZE=60 MAXLENGTH=80 VALUE=&quot;VBScript Broswer and OS Detection&quot;><BR>
<INPUT TYPE=&quot;button&quot; NAME =&quot;vbBrowseruserAgent&quot; VALUE=&quot;userAgent&quot;>
<INPUT TYPE=&quot;button&quot; NAME = &quot;vbClear&quot; VALUE=&quot;clear&quot;>
</FORM>
<FORM NAME=&quot;jsDetect&quot;>
<P><B>JavaScript<BR>
<INPUT TYPE=&quot;Text&quot; NAME=&quot;jsBrowser&quot; SIZE=60 MAXLENGTH=80 VALUE=&quot;JavaScript Broswer and OS Detection&quot;><BR>
<INPUT TYPE=&quot;button&quot; NAME=&quot;jsBrowseruserAgent&quot; VALUE=&quot;userAgent&quot;>
<INPUT TYPE=&quot;button&quot; NAME=&quot;jsClear&quot; VALUE=&quot;clear&quot;>
</FORM>
<SCRIPT LANGUAGE=&quot;VBScript&quot;>
<!--
Sub vbBrowserUserAgent_OnClick()
	document.vbDetect.vbBrowser.value = navigator.userAgent
End Sub
Sub vbClear_OnClick()
	document.vbDetect.vbBrowser.value = &quot;VBScript Browser and OS Detection&quot;
End Sub
'-->
</SCRIPT>
<SCRIPT LANGUAGE=&quot;Javascript&quot;>
<!--
function jsBrowseruserAgent_onclick() {
	document.jsDetect.jsBrowser.value = navigator.userAgent
}
function jsClear_onclick() {
	document.jsDetect.jsBrowser.value = &quot;JavaScript Browser and OS Detection&quot;
}
document.jsDetect.jsBrowseruserAgent.onclick = jsBrowseruserAgent_onclick;
document.jsDetect.jsClear.onclick = jsClear_onclick;
//-->
</SCRIPT>
</BODY>
</HTML>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top