Sign in to follow this  
Followers 0
cypher175

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

6 posts in this topic

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..??

Share this post


Link to post
Share on other sites



ok thanks, but what about my 2nd question..??

Share this post


Link to post
Share on other sites

well how can i use autoit to determine the user ID for the HKEY_USERS\User ID key..??

Share this post


Link to post
Share on other sites

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

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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