Solved

how to use JScripts to detect following ...

Posted on 2001-09-03
17
349 Views
Last Modified: 2007-11-27

How to extract the version code for (WSH)Windows Script Host,VML and XML in JScripts?
 
Thank you.


The Target Browser is: Microsoft Internet Explorer 5.0+
0
Comment
Question by:sina2000
  • 10
  • 6
17 Comments
 

Author Comment

by:sina2000
ID: 6452599

How to extract the version code for (WSH)Windows Script Host,VML and XML in JScripts?
 
Thank you.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6452687
I would think some modification to this:

   bMSvmAvailable = oClientCaps.isComponentInstalled("{89820200-ECBD-11CF-8B85-00AA005B4383}","componentid");
   sMSvmVersion   = oClientCaps.getComponentVersion("{89820200-ECBD-11CF-8B85-00AA005B4383}","componentid");
   if (sMSvmVersion != "") sMSvmVersion = "Version " + sMSvmVersion;
   sNeg = (bMSvmAvailable) ? "" : "not ";
   alert("Browser component: " + sMSvmVersion + " is " + sNeg + "installed.");

I would have to look for the objectid of wsh, vml and xml
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6452690
<MSIE:CLIENTCAPS ID="oClientCaps" />
0
 

Author Comment

by:sina2000
ID: 6452698

Waiting...   :-)

0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6452704
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6452709
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6452967
I cannot find the VML one.

You can use WSH to look in the registry for
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Advanced INF Setup\MSVML

The ComponentVersion should give the value too

You can use WSH to give it's own version:
WScript.Echo("This is WSH version", WScript.Version)

Michel
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6452995
AHA - looked at the wrong key!!!

oClientCaps.getComponentVersion("{10072CEC-8CC1-11D1-986E-00A0C955B42F}","componentid")
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 300 total points
ID: 6453110
Here is the script I have so far:

<HTML xmlns:MSIE>
<head>
<SCRIPT LANGUAGE="JavaScript"><!-- // cloak
/* Nailing down the browser name and version
   please let me know if your browser chokes on this.
   (c) 1996-2001 Michel Plungjan michel@irt.org */

var appVer   = navigator.appVersion.toLowerCase();
var agt      = navigator.userAgent.toLowerCase();
var bName    = navigator.appName;
var ie       = false;
var iePos    = agt.indexOf('msie');
var operaPos = agt.indexOf('opera');
var ns6Pos   = agt.indexOf('netscape6');
var version  = parseFloat(appVer);
var sE = uL = sL = '';
var bL = navigator.language;
if (!bL) bL = 'N/A';

if (iePos!=-1 && operaPos==-1) {
   ie = true;
   version = parseFloat(agt.substring(iePos+5,agt.indexOf(';',iePos)));
}
else if (operaPos!=-1) {
   version = parseFloat(agt.substring(operaPos+5,agt.indexOf('[',operaPos)));
   bName= "Opera";
}
else if (ns6Pos !=-1) {
   version = parseFloat(agt.substring(ns6Pos+10));
}
if (ie) {
   sE = ScriptEngine() + ' v' +
        ScriptEngineMajorVersion()+'.'+
        ScriptEngineMinorVersion()+
        ' build '+ScriptEngineBuildVersion();
   uL  = navigator.userLanguage;
   bL  = navigator.browserLanguage;
   sL  = navigator.systemLanguage;
}
Text  = 'userAgent and appVersion:<PRE>'
Text +=     'navigator.userAgent : ' + navigator.userAgent;
Text += '<BR>navigator.appName   : ' + navigator.appName;
Text += '<BR>navigator.appVersion: ' + navigator.appVersion;
Text += '</PRE>Parsed Browser details<PRE>';
Text +=     'Browser make        : ' + bName;
Text += '<BR>Browser version     : ' + version;
if (ie) {
   Text += '<BR>Scripting engine    : ' + sE;
   Text += '<BR>userLanguage        : ' + uL;  
   Text += '<BR>browserLanguage     : ' + bL;  
   Text += '<BR>systemLanguage      : ' + sL;  
}  
else Text += '<BR>browserLanguage     : ' + bL;  
Text += '</PRE>';
document.write(Text);

if (document.all) window.onload=show;
function show() {
   if (!ie) return;
   browserComponentAvailable = oClientCaps.isComponentInstalled("{89820200-ECBD-11CF-8B85-00AA005B4383}","componentid");
   browserComponentVersion   = oClientCaps.getComponentVersion("{89820200-ECBD-11CF-8B85-00AA005B4383}","componentid");
   vmlComponentAvailable = oClientCaps.isComponentInstalled("{10072CEC-8CC1-11D1-986E-00A0C955B42F}","componentid");
   vmlComponentVersion   = oClientCaps.getComponentVersion("{10072CEC-8CC1-11D1-986E-00A0C955B42F}","componentid");
   
//WScript.Echo("This is WSH version", WScript.Version)
   if (browserComponentVersion != "") browserComponentVersion = "Version " + browserComponentVersion;
   sNeg = (browserComponentAvailable) ? "" : "not ";
   msVers  = "<pre>Browser component: " + browserComponentVersion + " is " + sNeg + "installed.<br>";
   if (vmlComponentVersion != "") vmlComponentVersion = "Version " + vmlComponentVersion;
   sNeg = (vmlComponentAvailable) ? "" : "not ";
   msVers += "VML component    : " + vmlComponentVersion + " is " + sNeg + "installed.";
   myText.innerHTML=msVers;
}
// uncloak --></SCRIPT>
<STYLE><!--
@media all {
   MSIE\:CLIENTCAPS {behavior:url(#default#clientcaps)}
}
--></STYLE>
</head>
<body>
<MSIE:CLIENTCAPS ID="oClientCaps" />
<pre id="myText"></pre>
</body>
0
 

Author Comment

by:sina2000
ID: 6455148
Many thanks ...But how can I get the version of WSH in common HTML document ? :-)
0
 

Author Comment

by:sina2000
ID: 6455531

var arrComponents=new Array(
new Array('Address Book','{7790769C-0471-11D2-AF11-00C04FA35D02}'),
new Array('Windows Desktop Update NT','{89820200-ECBD-11CF-8B85-00AA005B4340}'),
new Array('DirectAnimation','{283807B5-2C60-11D0-A31D-00AA00B92C03}'),
new Array('DirectAnimation Java Classes','{4F216970-C90C-11D1-B5C7-0000F8051515}'),
new Array('DirectShow&reg;','{44BBA848-CC51-11CF-AAFA-00AA00B6015C}'),
new Array('Dynamic HTML Data Binding','{9381D8F2-0288-11D0-9501-00AA00B911A5}'),
new Array('Dynamic HTML Data Binding for Java','{4F216970-C90C-11D1-B5C7-0000F8051515}'),
new Array('Internet Connection Wizard','{5A8D6EE0-3E18-11D0-821E-444553540000}'),
new Array('Internet Explorer 5 Web Browser','{89820200-ECBD-11CF-8B85-00AA005B4383}'),
new Array('Internet Explorer Classes for Java','{08B0E5C0-4FCB-11CF-AAA5-00401C608555}'),
new Array('Internet Explorer Help','{45EA75A0-A269-11D1-B5BF-0000F8051515}'),
new Array('Internet Explorer Help Engine','{DE5AED00-A4BF-11D1-9948-00C04F98BBC9}'),
new Array('Windows Media Player','{22D6F312-B0F6-11D0-94AB-0080C74C7E95}'),
new Array('NetMeeting NT','{44BBA842-CC51-11CF-AAFA-00AA00B6015B}'),
new Array('Offline Browsing Pack','{3AF36230-A269-11D1-B5BF-0000F8051515}'),
new Array('Outlook Express','{44BBA840-CC51-11CF-AAFA-00AA00B6015C}'),
new Array('Task Scheduler','{CC2A9BA0-3BDD-11D0-821E-444553540000}'),
new Array('Microsoft virtual machine','{08B0E5C0-4FCB-11CF-AAA5-00401C608500}'),
new Array('VRML 2.0 Viewer','{90A7533D-88FE-11D0-9DBE-0000C0411FC3}'),
new Array('Wallet','{1CDEE860-E95B-11CF-B1B0-00AA00BBAD66}'),
new Array('Vector Markup Language (VML)','{10072CEC-8CC1-11D1-986E-00A0C955B42F}')
);

var arrPlugins=new Array(
new Array('Adobe&reg; SVG Viewer','Adobe.SVGCtl',3),
new Array('Macromedia&reg; Shockwave Player','SWCtl.SWCtl',9),
new Array('Macromedia&reg; Flash Player','ShockwaveFlash.ShockwaveFlash',6),
new Array('Apple&reg; QuickTime Player','QuickTime.QuickTime',0),
new Array('Real Player G2','rmocx.RealPlayer G2 Control',0),
new Array('Onflow&reg; Player','IEOnflow.IEOnflow1',8)
);

var sNoDetect='????';
var oClientCaps;


 
function getComponentInfo(sParam){
try {
var bInstalled=oClientCaps.isComponentInstalled(sParam,'ComponentID');
if (!bInstalled) {var sReturn='??????';}
else {var sReturn='??????';sReturn+='????: '+oClientCaps.getComponentVersion(sParam,'ComponentID').replace(/,/g,'.');}
}
catch (er) { var sReturn=sNoDetect;}
return sReturn;
}

function getPluginsVersion(sParam,iParam){
for (h=iParam;h>-2;h--) {
if (h==-1) return sNoDetect;
if (h==0) var sPluginsName=sParam;
else var sPluginsName=sParam+'.'+h.toString();
try {var oTempPluginsObject=new ActiveXObject(sPluginsName);break;}
catch (ex) {continue;}
}
if (h==0) return('??????');
else return('??????????: '+h.toString()+'.0');
}

function getXML2Version(){         /*  Microsoft XML2 Parser  */
var sParam='Msxml2.DOMDocument';var iParam=5;
for (h=iParam;h>-2;h--) {
if (h==-1) return sNoDetect;
if (h==0) var sPluginsName=sParam;
else var sPluginsName=sParam+'.'+h.toString()+'.0';
try {var oTempPluginsObject=new ActiveXObject(sPluginsName);break;}
catch (ex) {continue;}
}
if (h==0) return('??????');
else return('??????????: '+h.toString()+'.0');
}

function getXMLVersion(){         /*  Microsoft XML DOM  */
var sParam='Microsoft.XMLDOM';var iParam=3;
for (h=iParam;h>-2;h--) {
if (h==-1) return sNoDetect;
if (h==0) var sPluginsName=sParam;
else var sPluginsName=sParam+'.'+h.toString()+'.0';
try {var oTempPluginsObject=new ActiveXObject(sPluginsName);break;}
catch (ex) {continue;}
}
if (h==0) return('??????');
else return('??????????: '+h.toString()+'.0');
}

/*function getWSHVersion(){           Windows Script Host ????  
try { var sReturn=oWSHObject.Version+'.'+oWSHObject.BuildVersion; }
catch (er) { var sReturn=sNoDetect;}
return sReturn;
}*/

function getPlatform(){         /*  ????????  */
try { var sReturn=navigator.platform; }
catch (er) { var sReturn=sNoDetect;}
return sReturn;
}

function getBrowserName(){         /*  ??????????  */
var sReturn=navigator.appVersion;
var SPeXt=(navigator.userAgent.indexOf("Opera")!=-1 && navigator.userAgent.indexOf("5.")>0) ? "op" : (document.all) ? "ie" : (document.layers) ? "nn" : (!document.all && document.getElementById) ? "mo":"";
var arrVersion=sReturn.split("[");
if (SPeXt=="op"){arrVersion=sReturn.split("(");arrVersion[1]="Opera "+arrVersion[0];}
sInfo=sReturn.split(";");
if(SPeXt=="mo"){
nnbrws=navigator.userAgent.split(";");
if (nnbrws[4]) if (nnbrws[4].match("Netscape")){nnbrws=nnbrws[4].split("Netscape");sInfo[1]="Netscape"+nnbrws[1];}
else{nnbrws=nnbrws[4].split(")");sInfo[1]="Mozilla"+nnbrws[0];}}
if (SPeXt=="ie" || SPeXt=="mo") return(sInfo[1]);else return(navigator.appName+' '+arrVersion[0]);
return(navigator.appName+sReturn);
}

function getSystemName(){         /*  ????????  */
var sReturn=navigator.userAgent.toLowerCase();
var sWin='Microsoft&reg; Windows ';
try {
if (sReturn.indexOf('win')!=-1) {
if((sReturn.indexOf('nt')!=-1) && (sReturn.indexOf('5.1')!=-1)) return(sWin+'XP');
if((sReturn.indexOf('nt')!=-1) && (sReturn.indexOf('5.0')!=-1)) return(sWin+'2000');
if (sReturn.indexOf('nt')!=-1) return(sWin+'NT 4.0');
if((sReturn.indexOf('98')!=-1) && (sReturn.indexOf('9x')!=-1)) return(sWin+'Me');
if (sReturn.indexOf('98')!=-1) return(sWin+'98');
if (sReturn.indexOf('95')!=-1) return(sWin+'95');
}
if(sReturn.indexOf('IRIX')!=-1) return('Irix');
if(sReturn.indexOf('Mac')!=-1) return('Macintosh');
}
catch (er) { var sReturn=sNoDetect;}
return sReturn;
}

// Windows 2000 - Mozilla/4.0 (compatible; MSIE 6.0b; Windows NT 5.0)
// Windows XP     - Mozilla/4.0 (compatible; MSIE 6.0b; Windows NT 5.1)
// Windows Me     - Mozilla/4.0 (compatible; MSIE 6.0b; Windows 98; Win 9x 4.90)
// Windows 98     - Mozilla/4.0 (compatible; MSIE 6.0b; Windows 98)
// Windows 95     - Mozilla/4.0 (compatible; MSIE 6.0b; Windows 95)

function getLanguageCode(sParam){
var sReturn=sParam;
try {
if (sReturn.indexOf('zh-cn')!=-1) return('????????('+sReturn+')');
if (sReturn.indexOf('zh-sg')!=-1) return('????????('+sReturn+')');
if (sReturn.indexOf('en')!=-1) return('????('+sReturn+')');
if (sReturn.indexOf('ar')!=-1) return('????????('+sReturn+')');
if (sReturn.indexOf('fr')!=-1) return('????('+sReturn+')');
if (sReturn.indexOf('ko')!=-1) return('????('+sReturn+')');
if (sReturn.indexOf('ja')!=-1) return('????('+sReturn+')');
if (sReturn.indexOf('Spanish')!=-1) return('????????('+sReturn+')');
if (sReturn.indexOf('ru')!=-1) return('????('+sReturn+')');
}
catch (er) { var sReturn=sNoDetect;}
return sReturn;
}

function getUserLanguage(){         /*  ????????  */
try { var sReturn=getLanguageCode(navigator.userLanguage); }
catch (er) { var sReturn=sNoDetect;}
return sReturn;
}

function getBrowserLanguage(){         /*  ??????????  */
try { var sReturn=getLanguageCode(navigator.browserLanguage); }
catch (er) { var sReturn=sNoDetect;}
return sReturn;
}

function getSystemLanguage(){         /*  ????????  */
try { var sReturn=getLanguageCode(navigator.systemLanguage); }
catch (er) { var sReturn=sNoDetect;}
return sReturn;
}

function getColorDepth(){         /*  ????????????(Color Depth)  */
try { var sReturn=window.screen.colorDepth+'??'; }
catch (er) { var sReturn=sNoDetect;}
return sReturn;
}

function getBufferDepth(){         /*  ????????????(Buffer Depth)  */
try { var sReturn=window.screen.bufferDepth; }
catch (er) { var sReturn=sNoDetect;}
return sReturn;
}

function getScreenAvailHeight(){         /*  ??????????????  */
try { var sReturn=window.screen.availHeight+'????'; }
catch (er) { var sReturn=sNoDetect;}
return sReturn;
}

function getScreenAvailWidth(){         /*  ??????????????  */
try { var sReturn=window.screen.availWidth+'????'; }
catch (er) { var sReturn=sNoDetect;}
return sReturn;
}

function getScreenHeight(){         /*  ??????????????  */
try { var sReturn=window.screen.height+'????'; }
catch (er) { var sReturn=sNoDetect;}
return sReturn;
}

function getScreenWidth(){         /*  ??????????????  */
try { var sReturn=window.screen.width+'????'; }
catch (er) { var sReturn=sNoDetect;}
return sReturn;
}

function getUpdateInterval(){         /*  ??????????  */
try { var sReturn=window.screen.updateInterval+'????'; }
catch (er) { var sReturn=sNoDetect;}
return sReturn;
}

function getFontSmoothing(){         /*  ????????????????  */
try { if (window.screen.fontSmoothingEnabled) var sReturn='????';else var sReturn='????'; }
catch (er) { var sReturn=sNoDetect;}
return sReturn;
}

function getJavaEnabled(){         /*  Java??????(Microsoft&reg; virtual machine)  */
try { if (oClientCaps.javaEnabled) var sReturn='????';else var sReturn='????'; }
catch (er) { var sReturn=sNoDetect;}
return sReturn;
}

function getCookieEnabled(){         /*  ??????Cookies  */
try { if (navigator.cookieEnabled) var sReturn='????';else var sReturn='????'; }
catch (er) { var sReturn=sNoDetect;}
return sReturn;
}

function getConnectionType(){         /*  ????????  */
var sReturn;
try {
switch (oClientCaps.connectionType) {
case 'lan' : sReturn='??????????(LAN)????';break;
case 'modem' : sReturn='??????????????(Modem)????';break;
case 'offline' : sReturn='????????';break;
default : sReturn=sNoDetect;break;
}
}
catch (er) { var sReturn=sNoDetect;}
return sReturn;
}

function getScriptEngineInfo(){         /*  ????????(Scripting Engine)  */
var sReturn='';
try {
sReturn+=ScriptEngine()+' ';
sReturn+=ScriptEngineMajorVersion()+".";
sReturn+=ScriptEngineMinorVersion()+".";
sReturn+=ScriptEngineBuildVersion();
}
catch (er) { var sReturn=sNoDetect;}
return sReturn;
}

function getCPUClass(){         /*  ??????(CPU)  */
var sReturn;
try {
switch (navigator.cpuClass) {
case 'Alpha' : sReturn='Digital??????(Alpha)';break;
case 'x86' : sReturn='Intel??????(x86)';break;
case '68K' : sReturn='Motorola??????(68K)';break;
case 'PPC' : sReturn='Motorola??????(PPC)';break;
default : sReturn=sNoDetect;break;
}
}
catch (er) { var sReturn=sNoDetect;}
return sReturn;
}

function getWindowsPath(){         /*  ????????????(Windows)  */
try {
var oFileObject=new ActiveXObject("Scripting.FileSystemObject");
var sReturn=oFileObject.GetSpecialFolder(0);
}
catch (er) { var sReturn=sNoDetect;}
return sReturn;
}

function getSystemPath(){         /*  ????????????(System)  */
try {
var oFileObject=new ActiveXObject("Scripting.FileSystemObject");
var sReturn=oFileObject.GetSpecialFolder(1);
}
catch (er) { var sReturn=sNoDetect;}
return sReturn;
}

function getTemporaryPath(){         /*  ??????????????(Temporary)  */
try {
var oFileObject=new ActiveXObject("Scripting.FileSystemObject");
var sReturn=oFileObject.GetSpecialFolder(2);
}
catch (er) { var sReturn=sNoDetect;}
return sReturn;
}


function initComponents(){
oClientCaps=document.createElement('<rdl:clientCaps id=idClientCaps>');
document.body.appendChild(oClientCaps);
//oWSHObject=new ActiveXObject("WScript");
}

/* Part of RDL(TM) - Written by Rain1977 */
/* HomeSite: http://www.dhtmlet.com  E-Mail: rainer@mail.hf.ah.cn */
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6456021
If you can tell me how to create a WScript object then I can tell you how to get the version. After looking hard on the net I only came up with how to create a SHELL object.

Sorry


<script>
    try
    {
        var srvpk, regkey, shell;
     
        shell = new ActiveXObject( "WScript.Shell" );
        regkey = "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\CSDVersion";
        srvpk  = shell.RegRead( regkey );
         
        document.write( "Current Service Pack: " + srvpk );
    }
    catch( e )
    {
        document.write("Error: " + e.description );
    }
</script>
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6456148
PS: Next time do NOT bother accepting a comment as answer if you only feel like giving a C grade - I am only trying to help you and do not want to be punished because I did not have time or knowledge to solve ALL your problems!!!

Michel
0
 

Author Comment

by:sina2000
ID: 6456242
I am terribly sorry to bother you with my questions. Please forgive me for any uneasy feelings concerning my letter. I didn't quite understand you because of my clumsy English. Sorry again.
:-P

Thank you for your kind help !  ^_*
0
 

Author Comment

by:sina2000
ID: 6456260
I am terribly sorry because of my clumsy English.  Please forgive me .

:-)
0
 
LVL 1

Expert Comment

by:Computer101
ID: 6457538
sina2000,
Do you have any problem with me changing the grade.  Based on your comments, I do not think you would mind.

Thank you
Computer101
Community Support Moderator
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6723841
I would be very pleased if you did!

Thanks

Michel
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now