Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for defprn.js

(view source code of defprn.js as plain text)

  1. // Define CR/LF
  2. jsCrLf = String.fromCharCode( 13, 10 );
  3.  
  4. // Check for command line arguments (none required)
  5. objArgs = WScript.Arguments;
  6. if ( objArgs.length != 0 ) {
  7. 	strMsg = jsCrLf;
  8. 	strMsg = strMsg + "DefPrn.js,  Version 1.00" + jsCrLf;
  9. 	strMsg = strMsg + "Display default printer and port";
  10. 	strMsg = strMsg + jsCrLf + jsCrLf;
  11. 	strMsg = strMsg + "Usage:  CSCRIPT.EXE  DEFPRN.JS";
  12. 	strMsg = strMsg + jsCrLf + jsCrLf;
  13. 	strMsg = strMsg + "Written by Rob van der Woude" + jsCrLf;
  14. 	strMsg = strMsg + "http://www.robvanderwoude.com";
  15. 	WScript.Echo( strMsg );
  16. 	WScript.Quit(1);
  17. }
  18.  
  19. // Connect to shell
  20. var WshShell = WScript.CreateObject ( "WScript.Shell" );
  21.  
  22. // Read printer info from registry
  23. strPrn = WshShell.RegRead ( "HKCU\\Printers\\DeviceOld" );
  24.  
  25. // Format printer info
  26. arrPrn  = strPrn.split( "," );
  27. arrPort = arrPrn[2].split( ":" );
  28.  
  29. // Display the result
  30. strMsg = jsCrLf + "Default printer is " + arrPrn[0] + " on " + arrPort[0];
  31. WScript.Echo( strMsg );
  32.  

page last modified: 2024-04-16; loaded in 0.0048 seconds