Sign in to follow this  
Followers 0
semiono

RunOnce*

8 posts in this topic

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. ;)

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by ajag

Rule #1: Always do a backup         Rule #2: Always do a backup (backup of rule #1)

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 a

start

For $i = 1 to 100

...

Run($exec)

RegDelete("HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce", $name)

next go to start (while the $names exist)

;)

Edited by semiono

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

Good! Thanks! ;)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I'm unexperienced ;)

Why RegDelete( ..$KeyName) is has't work here correctly? Only one pass per one step. Why?

$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

Wend

and...

Is it possible to optimizate this code like HKLM\HKCU to one logical section? > While HKLM\HKCU Wend

Edited by semiono

Share this post


Link to post
Share on other sites

Your RegDelete should probably be:

RegDelete("HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce\" & $KeyName)

(see help file entry)

Share this post


Link to post
Share on other sites

#8 ·  Posted (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 by semiono

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0