home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / wsh.cab / registry.vbs < prev    next >
Text File  |  1997-09-16  |  2KB  |  66 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.  
  15. L_Welcome_MsgBox_Message_Text   = "This script demonstrates how to create and delete registry keys."
  16. L_Welcome_MsgBox_Title_Text     = "Windows Scripting Host Sample"
  17. Call Welcome()
  18.  
  19.  
  20. ' ********************************************************************************
  21. ' *
  22. ' * Registry related methods.
  23. ' *
  24.  
  25. Dim WSHShell
  26. Set WSHShell = WScript.CreateObject("WScript.Shell")
  27.  
  28. WSHShell.Popup "Create key HKCU\MyRegKey with value 'Top level key'"
  29. WSHShell.RegWrite "HKCU\MyRegKey\", "Top level key"
  30.  
  31. WSHShell.Popup "Create key HKCU\MyRegKey\Entry with value 'Second level key'"
  32. WSHShell.RegWrite "HKCU\MyRegKey\Entry\", "Second level key"
  33.  
  34. WSHShell.Popup "Set value HKCU\MyRegKey\Value to REG_SZ 1"
  35. WSHShell.RegWrite "HKCU\MyRegKey\Value", 1
  36.  
  37. WSHShell.Popup "Set value HKCU\MyRegKey\Entry to REG_DWORD 2"
  38. WSHShell.RegWrite "HKCU\MyRegKey\Entry", 2, "REG_DWORD"
  39.  
  40. WSHShell.Popup "Set value HKCU\MyRegKey\Entry\Value1 to REG_BINARY 3"
  41. WSHShell.RegWrite "HKCU\MyRegKey\Entry\Value1", 3, "REG_BINARY"
  42.  
  43. WSHShell.Popup "Delete value HKCU\MyRegKey\Entry\Value1"
  44. WSHShell.RegDelete "HKCU\MyRegKey\Entry\Value1"
  45.  
  46. WSHShell.Popup "Delete key HKCU\MyRegKey\Entry"
  47. WSHShell.RegDelete "HKCU\MyRegKey\Entry\"
  48.  
  49. WSHShell.Popup "Delete key HKCU\MyRegKey"
  50. WSHShell.RegDelete "HKCU\MyRegKey\"
  51.  
  52. ' ********************************************************************************
  53. ' *
  54. ' * Welcome
  55. ' *
  56. Sub Welcome()
  57.     Dim intDoIt
  58.  
  59.     intDoIt =  MsgBox(L_Welcome_MsgBox_Message_Text,    _   
  60.                       vbOKCancel + vbInformation,       _
  61.                       L_Welcome_MsgBox_Title_Text )
  62.     If intDoIt = vbCancel Then
  63.         WScript.Quit
  64.     End If
  65. End Sub
  66.