Sign in to follow this  
Followers 0
JohnS

[Newbie] If-Then and Do-Until

3 posts in this topic

Hello. This is my first post here, although I have been reading for a while trying to learn something.

But now it's time for me to ask for some help, because this is to much for me and cannot get any help from the help file.

I am trying to apply some registry tweaks during a Windows unattended installation, so that I have a icon view in a Classic Control Panel.

They only get applyed after logging in and after Control Panel has opened once. If I apply it and then open Control Panel for the first time it will overide the settings I want.

So, I have a script that:

-First verifies it the key I want is already applyed. If yes, the script exits.

- Second, if it is not applyed, it will open Control Panel and close it and then apply the tweak.

- Third, it wil be doing second step util the tweak gets applyed.

Only, it's not working because SyntaxCheck gives me an error about Else that I can't understand.

Can someone help me, please?

Thanks in advance

$var = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags\1\Shell", "Vid")
If $var = "{0057D0E0-3573-11CF-AE69-08002B2E1262}" Then exit
        Else
            Do Run(@HomeDrive & '\ControlPanel.exe')
WinWait("Control ","")
WinClose("Control ", "")

; Control Panel Classic View Tweak
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\WebView\BarricadedFolders", "shell:controlpanelfolder","REG_Dword", "0")
; Control Panel Icon View
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags\1\Shell", "Vid", "REG_SZ", "{0057D0E0-3573-11CF-AE69-08002B2E1262}")

Until $var = "{0057D0E0-3573-11CF-AE69-08002B2E1262}"
EndIf

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

in your code you are NOT reading the variable again to get/test the new $var

While 1
    $var = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags\1\Shell", "Vid")
    If $var = "{0057D0E0-3573-11CF-AE69-08002B2E1262}" Then
        Exit
    Else
        Run(@HomeDrive & '\ControlPanel.exe')
        WinWait("Control ", "")
        WinClose("Control ", "")
        
      ; Control Panel Classic View Tweak
        RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\WebView\BarricadedFolders", "shell:controlpanelfolder", "REG_Dword", "0")
      ; Control Panel Icon View
        RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags\1\Shell", "Vid", "REG_SZ", "{0057D0E0-3573-11CF-AE69-08002B2E1262}")
    EndIf
WEnd

or

$var = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags\1\Shell", "Vid")
If $var = "{0057D0E0-3573-11CF-AE69-08002B2E1262}" Then
    Exit
Else
    Do
        Run(@HomeDrive & '\ControlPanel.exe')
        WinWait("Control ", "")
        WinClose("Control ", "")
        
      ; Control Panel Classic View Tweak
        RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\WebView\BarricadedFolders", "shell:controlpanelfolder", "REG_Dword", "0")
      ; Control Panel Icon View
        RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags\1\Shell", "Vid", "REG_SZ", "{0057D0E0-3573-11CF-AE69-08002B2E1262}")
        
        $N_var = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags\1\Shell", "Vid")
        
    Until $N_var = "{0057D0E0-3573-11CF-AE69-08002B2E1262}"
EndIf

1

if ... then exit

2

if.... then

exit

endif

3

if...... then

exit

else

; do this

endif

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

Thank you, I will study your script.

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