Convert VBScript code to javascript (i.e. JScript) code -


how convert following vbscript javascript?

<script type="text/vbscript">    function sayhello()     msgbox "hello"  hkey_local_machine = "&h80000002" uninstallregkey = "software\\microsoft\\windows\\currentversion\\uninstall" stdregpro = "winmgmts:{impersonationlevel=impersonate}!\\\\.\\root\\default:stdregprov"  set objreg=getobject(stdregpro)  objreg.enumkey hkey_local_machine, uninstallregkey, arrsubkeys msgbox arrsubkeys    end function  </script> 

any appreciated.

thanks, lok.

you can, if use jscript (microsoft's implementation of javascript windows) , information e.g.

  1. calling wmi methods jscript
  2. troubles wmi in jscript

(found googling "jscript wmi").

evidence:

function showuninstall() {     var hkey_local_machine = 0x80000002;     var uninstallregkey = "software\\microsoft\\windows\\currentversion\\uninstall";     var stdregpro = "winmgmts:{impersonationlevel=impersonate}!//./root/default:stdregprov";     var objreg = getobject(stdregpro);      var menumkey = objreg.methods_.item("enumkey");     var ipenumkey = menumkey.inparameters.spawninstance_();     ipenumkey.hdefkey = hkey_local_machine;     ipenumkey.ssubkeyname = uninstallregkey;      var mgetstringvalue = objreg.methods_.item("getstringvalue");     var ipgetstringvalue = mgetstringvalue.inparameters.spawninstance_();     ipgetstringvalue.hdefkey = hkey_local_machine;     ipgetstringvalue.svaluename = "displayname";      var openumkey = objreg.execmethod_(menumkey.name, ipenumkey);     if (0 === openumkey.returnvalue) {         var anames = openumkey.snames.toarray();         ( var = 0; < anames.length; ++i) {             ipgetstringvalue.ssubkeyname = uninstallregkey + "\\" + anames[i];             var opgetstringvalue = objreg.execmethod_(mgetstringvalue.name, ipgetstringvalue);             if (0 === opgetstringvalue.returnvalue) {                 wscript.echo(opgetstringvalue.svalue);             } else {                 wscript.echo("error: getstringvalue.returnvalue =", opgetstringvalue.returnvalue);             }         }     } else {         wscript.echo("error: enumkey.returnvalue =", openumkey.returnvalue);     } } 

output:

cscript 26907078.js 7-zip 4.65 activestate activetcl 8.5.2.0 error: getstringvalue.returnvalue = 1 adobe flash player 15 plugin error: getstringvalue.returnvalue = 1 cmake 2.8, cross-platform, open-source build system acrobat.com ... 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -