ToddMurray Posted November 13, 2007 Share Posted November 13, 2007 Taking the posted code by Sean Hart I'm working on a function that allows you to write a file to All Users. I have managed to get the function to write to the users but the login i'm using to limit who it affects is having a problem. CODE Func FileCopyAllUsers($source, $dest, $flag, $attrib) Dim $i, $error, $ExpandEnvStrings, $profiledir, $curdir, $search, $dir ; init variables $i = 1 $error = 0 $ExpandEnvStrings = Opt("ExpandEnvStrings",1) $profiledir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList", "ProfilesDirectory") $source = @ScriptDir & "\" & $source $attrib = $attrib ; change directory to profile directory $curdir = @WorkingDir FileChangeDir($profiledir) ; Go through all directories $search = FileFindFirstFile("*.*") $dir = FileFindNextFile($search) While @error = 0 ; Checks to ensure the target is a directory If StringRegExp(FileGetAttrib($dir), "D", 0) <> 0 Then Switch $attrib Case 1; User Profiles If $dir <> "All Users" Or $dir <> "Default User" Or StringRegExp(FileGetAttrib($dir), "SHD", 0) = 0 Then FileCopy($source, $profiledir & "\" & $dir & $dest, $flag) EndIf Case 2; Default User Profile If $dir = "Default User" Then FileCopy($source, $profiledir & "\" & $dir & $dest, $flag) EndIf Case 3; User Profiles + Default User Profile If $dir <> "All Users" Or StringRegExp(FileGetAttrib($dir), "SHD", 0) = 0 Then FileCopy($source, $profiledir & "\" & $dir & $dest, $flag) EndIf Case 4; All Users Profile If $dir = "All Users" Then FileCopy($source, $profiledir & "\" & $dir & $dest, $flag) EndIf Case 5; User Profiles + All Users Profile If $dir = "Default User" Or StringRegExp(FileGetAttrib($dir), "SHD", 0) = 0 Then FileCopy($source, $profiledir & "\" & $dir & $dest, $flag) EndIf Case 6; Default User Profile + All Users Profile If $dir = "Default User" Or $dir = "All Users" Then FileCopy($source, $profiledir & "\" & $dir & $dest, $flag) EndIf Case 7; User Profiles + Default User Profile + All Users Profile If StringRegExp(FileGetAttrib($dir), "SHD", 0) = 0 Then FileCopy($source, $profiledir & "\" & $dir & $dest, $flag) EndIf Case 8; System Profiles If StringRegExp(FileGetAttrib($dir), "SHD", 0) <> 0 Then FileCopy($source, $profiledir & "\" & $dir & $dest, $flag) EndIf Case 9; User Profiles + System Profiles If $dir <> "All Users" Or $dir <> "Default User" Then FileCopy($source, $profiledir & "\" & $dir & $dest, $flag) EndIf Case 10; Default User Profile + System Profiles If $dir = "Default User" Or StringRegExp(FileGetAttrib($dir), "SHD", 0) <> 0 Then FileCopy($source, $profiledir & "\" & $dir & $dest, $flag) EndIf Case 11; User Profiles + Default User Profile + System Profiles If $dir <> "All Users" Then FileCopy($source, $profiledir & "\" & $dir & $dest, $flag) EndIf Case 12; All Users Profile + System Profiles If $dir = "All Users" Or StringRegExp(FileGetAttrib($dir), "SHD", 0) <> 0 Then FileCopy($source, $profiledir & "\" & $dir & $dest, $flag) EndIf Case 13; User Profiles + All Users Profile + System Profiles If $dir <> "Default User" Then FileCopy($source, $profiledir & "\" & $dir & $dest, $flag) EndIf Case 14; Default User Profile + All Users Profile + System Profiles If $dir = "All Users" Or $dir = "Default User" Or StringRegExp(FileGetAttrib($dir), "SHD", 0) <> 0 Then FileCopy($source, $profiledir & "\" & $dir & $dest, $flag) EndIf Case 15; User Profiles + Default User Profile + All Users Profile + System Profiles FileCopy($source, $profiledir & "\" & $dir & $dest, $flag) EndSwitch EndIf $dir = FileFindNextFile($search) $i = $i + 1 WEnd ; Put settings back and change back to previous directory Opt("ExpandEnvStrings",$ExpandEnvStrings) FileChangeDir($curdir) EndFunc ; === END FileCopyAllUsers === The issue i'm working on is the Acrobat 8 Updater so when I call the function I use the following. FileCopyAllUsers("AdobeUpdaterPrefs.dat", "\Local Settings\Application Data\Adobe\Updater5\AdobeUpdaterPrefs.dat", 9, 15) The option works to apply it to all profiles, but not the selective Case statements that include the StringRegExp(FileGetAttrib($dir), "SHD", 0). Can anyone help me with this? Link to comment Share on other sites More sharing options...
ToddMurray Posted November 13, 2007 Author Share Posted November 13, 2007 I figured out and corrected the problem. I'll be posting my full code into the original tread.http://www.autoitscript.com/forum/index.ph...egWriteAllUsers Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now