1 Nis 2010

Window kayıtdefterinden okuma yapmak (Regedit)

Windows'ta regedit'ten (kayıt defteri) okuma, yazma yapmak isteyebilirsiniz.
Aşağıdaki kodlar vbs ile yazılmıştır.

'Regedit.vbs
Option Explicit
Dim WSHShell, RegKey, komutOne, komutTwo, komutThree
Dim objFSO, objFSOText, objFolder, objFile
Dim strDirectory,strFile
strDirectory = "C:\"
strFile = "Mntr_Sonuc.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Set objFolder = objFSO.CreateFolder(strDirectory)
Set WSHShell = CreateObject("WScript.Shell")
RegKey = "HKLM\SOFTWARE\MONITORING\"
komutOne= WSHShell.RegRead(RegKey & "status")
komutTwo= WSHShell.RegRead(RegKey & "processresult")
komutThree= WSHShell.RegRead(RegKey & "errorcode")
Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
objFile.Write(komutTwo)
'WScript.echo "Status: " & komutOne & ", ProcessResult: " & komutTwo & ", ErrorCode: " & komutThree



Buradaki kod Regeditten HKEY_Local_Machine\SOFTWARE\MONITORING dizinindeki
status, processresult, errorcode ait sonuçları C:\Mntr_Sonuc.txt dosyasına yazar.
Not: Sizde bu MONITORING dizini olmayabilir.

Hiç yorum yok:

Yorum Gönder