Sign in to follow this  
Followers 0
Guiguit59

Create script to resolve profil.bak issue.

5 posts in this topic

Hi,

I want to create a script to resolve profil.bak issue on Windows 7.

My problem is how to do a search of the registry key from the user name.

Registry key for exemple: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-21-4138206758-3315363207-xxxxxxxx-xxxx.bak.

After i want to rename this key.

Share this post


Link to post
Share on other sites



Guiguit59,

Welcome to the AutoIt forums.

But please pay attention to where you post - the "AutoIt Technical Discussion" section where you started this thread is not for general support questions.  I have moved it for you, but would ask you to be more careful in future.

M23

 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

Try this example :

For $i = 1 To 10
    $var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList", $i)
    If @error <> 0 Then ExitLoop
    MsgBox(4096, "SubKey #" & $i & " under HKLM\Software: ", $var)
Next

Then Check out the other REG examples like RegWrite()

Share this post


Link to post
Share on other sites

I actually already wrote something for this, it's probably not as awesome as other coders can put together and I could do better now since I have gotten better at this but at-least its an example you can build from. 

 

#RequireAdmin
$sPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"


RunWait(@ComSpec & ' /c REG EXPORT "' & $sPath & '" C:\BeforeProfileFix.reg /f')

For $i = 1 To 40

    $sub = RegEnumKey($sPath, $i)

        If @error Then ExitLoop

        If StringInStr($sub, ".bak") Then
            RunWait(@ComSpec & ' /c REG DELETE "' & $sPath & '\' & StringTrimRight($sub, 4) & '" /f')
            Sleep(200)
            RunWait(@ComSpec & ' /c REG COPY  "' & $sPath & '\' & $sub & '" "' & $sPath & '\' & StringTrimRight($sub, 4) & '" /s')
            Sleep(200)
            RunWait(@ComSpec & ' /c REG DELETE "' & $sPath & '\' & $sub & '" /f')
        Else
            EndIf


Next

MsgBox(0, "BoCC Automation", "Profile Fix has been implimented" & @CRLF & @CRLF & "A copy of the registry is saved to C: if you need to restore old settings" & @CRLF & "Please reboot the machine to have changes take effect")
$Reboot = MsgBox(4, "BoCC Automation", "Reboot Now?")
If $Reboot = 6 Then Shutdown(6)

 

Share this post


Link to post
Share on other sites

Thanks for all

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