Sign in with
Sign up | Sign in
Your question

WScript RegRead error

Last response: in Windows XP
Share
December 18, 2009 8:03:53 AM

can anyone help me with ths error :

I am using the below statement to read the registry for default printer.

var sDefault = ""
var oShell = new ActiveXObject("wscript.Shell");
var sRegVal = 'HKCU\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows\\Device'

sDefault = oShell.RegRead(sRegVal)
GetDefaultPrinter = sDefault


What would regRead return in case it does not find the registry, I am not able to trap that, instead I am getting a javascript error like unable to read registry key ''HKCU\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows\\Device'


More about : wscript regread error

December 18, 2009 11:31:51 AM

I'm not versed in scripts, but when I export a registry key and view the bat file the path looks like this:

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion]

This is on Win 7 so obviously the registry is laid out different to XP.

There are no double back slashes though and HKCU isn't used, rather it's HKEY_CURRENT_USER

I'm too lazy to fire up XP to have a look at the differences, but have you tried exporting the part of the registry pertaining to your javascript and modifying the path accordingly?

Like I said, I have absolutely no experience with js so excuse me if this post makes it plainly (painfully) obvious :) 
m
0
l
December 21, 2009 2:47:04 AM

thank you but what i am looking in this path is default printer which is correct in XP as i see. Also i get to see the output i.e the default printer there.

HKCU is only the abbrv. for HKEY_CURRENT_USER.

can you or anyone help me with this specific error :

var sDefault = ""
var oShell = new ActiveXObject("wscript.Shell" );
var sRegVal = 'HKCU\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows\\Device'

sDefault = oShell.RegRead(sRegVal)
GetDefaultPrinter = sDefault


What would regRead return in case it does not find the registry, I am not able to trap that, instead I am getting a javascript error like unable to read registry key ''HKCU\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows\\Device'

m
0
l
December 31, 2009 2:59:07 AM

can anyone help me with this, any idea ?

I am using the below statement to read the registry for default printer.

var sDefault = ""
var oShell = new ActiveXObject("wscript.Shell" );
var sRegVal = 'HKCU\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows\\Device'

sDefault = oShell.RegRead(sRegVal)
GetDefaultPrinter = sDefault


What would regRead return in case it does not find the registry, I am not able to trap that, instead I am getting a javascript error like unable to read registry key ''HKCU\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows\\Device'
m
0
l
!