Wachtwoord vergeten?

Wachtwoord vergeten
Vul hier uw email adres in. U ontvangt dan een nieuw wachtwoord.

HOWTO: Use the Windows Script Host to Read, Write, and Delete Registry Keys

Gepost op 16-10-2003 - Overige Microsoft Producten - 0 reacties


De informatie in dit artikel is van toepassing op:

  • Microsoft Visual FoxPro 3.0 Standard Edition
  • Microsoft Visual FoxPro 3.0b Standard Edition
  • Microsoft Visual FoxPro 5.0 Standard Edition
  • Microsoft Visual FoxPro 5.0a
  • Microsoft Visual FoxPro 6.0 Professional Edition

Dit artikel is eerder gepubliceerd onder NL244675

Samenvatting

IMPORTANT: This article contains information about editing the registry. Before you edit the registry, make sure you understand how to restore it ifa problem occurs. For information about how to do this, view the "Restoring the Registry" Help topic in Regedit.exe or the "Restoring a Registry Key" Help topic in Regedt32.exe.


The Microsoft Windows Script Host (WSH) is a tool that allows you to run Microsoft Visual Basic Scripting Edition and Microsoft JScript natively within the base operating system, either on Microsoft Windows 95 or Microsoft Windows NT 4.0. It also includes several COM automation methods that allow you to do several handy tasks easily through the Windows Script Host Object Model.


The Microsoft Windows Script Host is integrated in Windows 98. It is available for Windows NT 4.0 from within the Windows NT 4.0 Option Pack.It is also available for download from the following site:The Windows Script Host provides several useful methods to read, write, and delete registry keys easily. The RegWrite function's third parameter allows the programmer to specify the type of data added to the registry. RegWrite supports strType as REG_SZ, REG_EXPAND_SZ, REG_DWORD and REG_BINARY. If another data type is passed as strType, RegWrite returns E_INVALIDARG.

Meer informatie

WARNING: Using Registry Editor incorrectly can cause serious problems thatmay require you to reinstall your operating system. Microsoft cannotguarantee that problems resulting from the incorrect use of Registry Editorcan be solved. Use Registry Editor at your own risk.


For information about how to edit the registry, view the "Changing Keys andValues" Help topic in Registry Editor (Regedit.exe) or the "Add and DeleteInformation in the Registry" and "Edit Registry Data" Help topics inRegedt32.exe. Note that you should back up the registry before you edit it.If you are running Windows NT or Windows 2000, you should also update your EmergencyRepair Disk (ERD).


The Microsoft Visual FoxPro code below demonstrates several examples of reading, writing, and deleting registry keys and values.

WSHShell = CreateObject("WScript.Shell") *!* Create Registry KeysWSHShell.Popup( "Create key HKCU\MyRegKey with value 'Top level key'")WSHShell.RegWrite( "HKCU\MyRegKey\", "Top level key") WSHShell.Popup( "Create key HKCU\MyRegKey\Entry with value 'Second level key'")WSHShell.RegWrite( "HKCU\MyRegKey\Entry\", "Second level key") WSHShell.Popup( "Set value HKCU\MyRegKey\Value to REG_SZ 1")WSHShell.RegWrite ("HKCU\MyRegKey\Value", 1) WSHShell.Popup( "Set value HKCU\MyRegKey\Entry to REG_DWORD 2")WSHShell.RegWrite( "HKCU\MyRegKey\Entry", 2, "REG_DWORD") WSHShell.Popup( "Set value HKCU\MyRegKey\Entry\Value1 to REG_BINARY 3")WSHShell.RegWrite( "HKCU\MyRegKey\Entry\Value1", 3, "REG_BINARY") *!* Read Registry KeyslcValue1 = WSHShell.RegRead("HKCU\MyRegKey\")WSHShell.Popup("Value of HKCU\MyRegKey: " + lcValue1) lcValue2 = WSHShell.RegRead("HKCU\MyRegKey\Entry\")WSHShell.Popup("Value of HKCU\MyRegKey\Entry\: " + lcValue2) lcValue3 = WSHShell.RegRead("HKCU\MyRegKey\Value")WSHShell.Popup("Value of HKCU\MyRegKey\Value: " + lcValue3) lnValue1 = WSHShell.RegRead("HKCU\MyRegKey\Entry")WSHShell.Popup("Value of HKCU\MyRegKey\Entry: " + ALLTRIM(STR(lnValue1))) lnValue3 = WSHShell.RegRead("HKCU\MyRegKey\Entry\Value1")WSHShell.Popup("Value of HKCU\MyRegKey\Entry\Value1: " + ALLTRIM(STR(lnValue3(1)))) *!* Delete Registry KeysWSHShell.Popup( "Delete value HKCU\MyRegKey\Entry\Value1")WSHShell.RegDelete( "HKCU\MyRegKey\Entry\Value1") WSHShell.Popup ("Delete key HKCU\MyRegKey\Entry")WSHShell.RegDelete( "HKCU\MyRegKey\Entry\") WSHShell.Popup ("Delete key HKCU\MyRegKey")WSHShell.RegDelete( "HKCU\MyRegKey\")

Referenties


You can find the papers below on the following Web site:White paper:Windows Script Host: A Universal Scripting Host for Scripting Languages


Technical Paper: Windows Script Host Programmer's Reference


For additional information about using Visual FoxPro and the Windows Script Host, please click the article numbers below to view the article in the Microsoft Knowledge Base:

244677HOWTO: Create a Desktop Shortcut Using the Windows Script Host

244676HOWTO: Map, Delete and Enumerate Network Drives Using the Windows Script Host

PrintPrint RSS reactiesRSS reacties BookmarkBookmark

Gekoppelde tags

Download, FoxPro, Update, Visual Basic, Windows 2000, Windows 95, Windows 98, Windows NT

Reacties
Nog geen reacties geplaatst.

Winkelmandje

Het winkelmandje is leeg

Inloggen
Als u hierboven op de knop 'bestellen' klikt krijgt u een overzicht van de door uw gewenste producten. Indien het overzicht compleet en correct is kunt via de wizard de verdere gegevens invullen en uw bestelling afronden. In het bestelproces kunt u altijd op 'vorige' drukken om terug te gaan in het proces. Bij Perrit staan vertrouwen, privacy en veiligheid op de eerste plaats, wij zullen uw gegevens dan ook met uiterste zorgvuldigheid behandelen en nooit doorgeven aan derden.

Perrit.nl Sherwood Rangers 29 Hengelo

Perrit.nl telefoon: +31 74 750 12 20

Kenniscentrum - HOWTO: Use the Windows Script Host to Read, Write, and Delete Registry Keys
Perrit Kenniscentrum - HOWTO: Use the Windows Script Host to Read, Write, and Delete Registry Keys