home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / wsh.cab / registry.js < prev    next >
Text File  |  1997-09-16  |  3KB  |  70 lines

  1. // Windows Script Host Sample Script
  2. //
  3. // ------------------------------------------------------------------------
  4. //               Copyright (C) 1996-1997 Microsoft Corporation
  5. //
  6. // You have a royalty-free right to use, modify, reproduce and distribute
  7. // the Sample Application Files (and/or any modified version) in any way
  8. // you find useful, provided that you agree that Microsoft has no warranty,
  9. // obligations or liability for any Sample Application Files.
  10. // ------------------------------------------------------------------------
  11. //
  12. // This sample demonstrates how to write/delete entries in the registry. 
  13.  
  14. var vbOKCancel = 1;
  15. var vbInformation = 64;
  16. var vbCancel = 2;
  17.  
  18. var L_Welcome_MsgBox_Message_Text   = "This script demonstrates how to create and delete registry keys.";
  19. var L_Welcome_MsgBox_Title_Text     = "Windows Scripting Host Sample";
  20. Welcome();
  21.  
  22.  
  23. // ********************************************************************************
  24. // *
  25. // * Registry related methods.
  26. // *
  27.  
  28. var WSHShell = WScript.CreateObject("WScript.Shell");
  29.  
  30. WSHShell.Popup("Create key HKCU\\MyRegKey with value 'Top level key'");
  31. WSHShell.RegWrite("HKCU\\MyRegKey\\", "Top level key");
  32.  
  33. WSHShell.Popup("Create key HKCU\\MyRegKey\\Entry with value 'Second level key'");
  34. WSHShell.RegWrite("HKCU\\MyRegKey\\Entry\\", "Second level key");
  35.  
  36. WSHShell.Popup("Set value HKCU\\MyRegKey\\Value to REG_SZ 1");
  37. WSHShell.RegWrite("HKCU\\MyRegKey\\Value", 1);
  38.  
  39. WSHShell.Popup("Set value HKCU\\MyRegKey\\Entry to REG_DWORD 2");
  40. WSHShell.RegWrite("HKCU\\MyRegKey\\Entry", 2, "REG_DWORD");
  41.  
  42. WSHShell.Popup("Set value HKCU\\MyRegKey\\Entry\\Value1 to REG_BINARY 3");
  43. WSHShell.RegWrite("HKCU\\MyRegKey\\Entry\\Value1", 3, "REG_BINARY");
  44.  
  45. WSHShell.Popup("Delete value HKCU\\MyRegKey\\Entry\\Value1");
  46. WSHShell.RegDelete("HKCU\\MyRegKey\\Entry\\Value1");
  47.  
  48. WSHShell.Popup("Delete key HKCU\\MyRegKey\\Entry");
  49. WSHShell.RegDelete("HKCU\\MyRegKey\\Entry\\");
  50.  
  51. WSHShell.Popup("Delete key HKCU\\MyRegKey");
  52. WSHShell.RegDelete("HKCU\\MyRegKey\\");
  53.  
  54. //////////////////////////////////////////////////////////////////////////////////
  55. //
  56. // Welcome
  57. //
  58. function Welcome() {
  59.     var WSHShell = WScript.CreateObject("WScript.Shell");
  60.     var intDoIt;
  61.  
  62.     intDoIt =  WSHShell.Popup(L_Welcome_MsgBox_Message_Text,
  63.                               0,
  64.                               L_Welcome_MsgBox_Title_Text,
  65.                               vbOKCancel + vbInformation );
  66.     if (intDoIt == vbCancel) {
  67.         WScript.Quit();
  68.     }
  69. }
  70.