semiono Posted December 21, 2009 Share Posted December 21, 2009 Please, help! For $i = 1 to 100 $name = RegEnumVal("HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce", $i) if @error <> 0 Then ExitLoop $exec = RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce", $name) Run($exec) RegDelete("HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce", $name) next I need to get full loop at $name1 $name2 ...etc. Howto? What is here 1 to 100? Is it limitted by 100 variables? P/S. WinXp RunOnce not works in my desktop! It's a tweak. Link to comment Share on other sites More sharing options...
ajag Posted December 21, 2009 Share Posted December 21, 2009 (edited) Please, help! For $i = 1 to 100 $name = RegEnumVal("HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce", $i) if @error <> 0 Then ExitLoop $exec = RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce", $name) Run($exec) RegDelete("HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce", $name) next What is here 1 to 100? For $i = 1 To 100 : Next means, that the code between For and Next will be executed 100 times. The variable "i" is incremented every time by 1 (started by 1). What exactly are you trying to do? A-Jay Edited December 21, 2009 by ajag Rule #1: Always do a backup Rule #2: Always do a backup (backup of rule #1) Link to comment Share on other sites More sharing options...
semiono Posted December 21, 2009 Author Share Posted December 21, 2009 (edited) per example[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce]"var" = "calc.exe""zzz" = "notepad.exe""abcd" = "cmd.exe /c start /w la-la..."I need script to execute all of the values founds here.?---I need some like astartFor $i = 1 to 100...Run($exec)RegDelete("HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce", $name)next go to start (while the $names exist) Edited December 21, 2009 by semiono Link to comment Share on other sites More sharing options...
ajag Posted December 21, 2009 Share Posted December 21, 2009 Maybe this will give you a hint $i = 1 While 1 ; Get (first/next) key name $KeyName = RegEnumVal("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce", $i) ; exit if there is no more if @error <> 0 Then ExitLoop ; get key value $KeyValue = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce", $KeyName) ; show what we have... MsgBox(4096, "RegInfo", $KeyName & " = " & $KeyValue) ; point to next entry $i = $i + 1 Wend A-Jay Rule #1: Always do a backup Rule #2: Always do a backup (backup of rule #1) Link to comment Share on other sites More sharing options...
semiono Posted December 22, 2009 Author Share Posted December 22, 2009 Good! Thanks! Link to comment Share on other sites More sharing options...
semiono Posted December 22, 2009 Author Share Posted December 22, 2009 (edited) I'm unexperienced Why RegDelete( ..$KeyName) is has't work here correctly? Only one pass per one step. Why?expandcollapse popup$i = 1 While 1 $KeyName = RegEnumVal("HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce", $i) if @error <> 0 Then ExitLoop $KeyValue = RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce", $KeyName) Run($KeyValue, "", @SW_HIDE) Sleep(500) ; as alternative external command is worked good here! <<< ShellExecute("reg.exe", 'delete HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce /v' & ' "' & $KeyName & '" /f', "", "", @SW_HIDE) ; has problem! <<<< ;RegDelete("HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce", $KeyName) $i = $i + 1 Wend $i = 1 While 1 $KeyName = RegEnumVal("HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce", $i) if @error <> 0 Then ExitLoop $KeyValue = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce", $KeyName) Run($KeyValue, "", @SW_HIDE) Sleep(500) ShellExecute("reg.exe", 'delete HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce /v' & ' "' & $KeyName & '" /f', "", "", @SW_HIDE) ;RegDelete("HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce", $KeyName) $i = $i + 1 Wendand...Is it possible to optimizate this code like HKLM\HKCU to one logical section? > While HKLM\HKCU Wend Edited December 22, 2009 by semiono Link to comment Share on other sites More sharing options...
whim Posted December 22, 2009 Share Posted December 22, 2009 Your RegDelete should probably be: RegDelete("HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce\" & $KeyName) (see help file entry) Link to comment Share on other sites More sharing options...
semiono Posted December 22, 2009 Author Share Posted December 22, 2009 (edited) No! RegDelete() is workig. But my logic how to use $variable here... is lame (algorithm problem...) \" & $KeyName - good idea, but it's should has an other problem. Edited December 22, 2009 by semiono Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now