Jump to content

If Reg Key Not Exist then Install Reg Key..?


 Share

Recommended Posts

Is there any way to check if a registry key is installed in the registry and if its not found to be installed then have it installed..??

And also is there anyway for autoit read/determine what the current users HKEY_USERS\User ID is so it can install a reg key that corresponds to it..??

Link to comment
Share on other sites

  • Developers

This is a script which will retrieve the SID for Local defined user and can be used for the registry key:

ConsoleWrite(GetUserSID(@ComputerName,@UserName) & @CRLF)

Func GetUserSID($ComputerName,$Username)
    Dim $UserSID, $oWshNetwork, $oUserAccount
    $objWMIService = objGet( "winmgmts:{impersonationLevel=impersonate}!//"  & $ComputerName & "/root/cimv2")
    $oUserAccounts = $objWMIService.ExecQuery("Select Name, SID from Win32_UserAccount")

    For $oUserAccount In $oUserAccounts
;~      ConsoleWrite('$oUserAccount.SID = ' & $oUserAccount.SID & @crlf)
;~      ConsoleWrite('$oUserAccount.name = ' & $oUserAccount.Name & @crlf)
;~      ConsoleWrite('$oUserAccount.domain = ' & $oUserAccount.Domain & @crlf & @CRLF)
        If $Username =  $oUserAccount.Name Then Return $oUserAccount.SID
    Next
    Return ""
EndFunc

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...