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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check function Question

Status
Not open for further replies.

pbanacos

IS-IT--Management
Apr 21, 2006
34
US
Hello,

I need some help with the code below. This code will fail to run successfully if this location in the registry doesnt exist. HKCU\\Printers\\DeviceOld. That would be great if we could see if it is valid before we proceed with the function or popup a message saying the location doesnt exist. I would appreciate any help.

Thanks

Paul,


var WshShell = WScript.CreateObject ( "WScript.Shell" );
var retval = "";

var fso = new ActiveXObject("Scripting.FileSystemObject");
var a = fso.CreateTextFile("c:\\Default.txt", true);

retval += DefaultPrinters(retval);
a.WriteLine ("\r\nYour Default Printer is a: " +retval);

function DefaultPrinters(DefaultPrinter)
{

retval = WshShell.RegRead ("HKCU\\Printers\\DeviceOld");

return retval;
}
 
[tt]
var WshShell = WScript.CreateObject ( "WScript.Shell" );
var retval = "";

var fso = new ActiveXObject("Scripting.FileSystemObject");
var a = fso.CreateTextFile("c:\\Default.txt", true);

retval += DefaultPrinters();
a.WriteLine ("Your Default Printer is a: " +retval);
[red]a.close()[/red];

function DefaultPrinters()
{
try {
[red]var [/red]retval = WshShell.RegRead ("HKCU\\Printers\\DeviceOld");
} catech (e) {
var retval="error: "+e.number+";description: "+e.description;
//if you want message, else comment it out
WScript.echo (e.number + "\n" + e.description);
}
return retval;
}
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top