Delphinus Posted May 15, 2008 Share Posted May 15, 2008 Greetings fellow coders, I have a script that changes the desktop wallpaper on a WinXP SP3 machine. The script works fine under the administrator login but I need it to run under a user account with no administrator privileges but it will not change the wallpaper. If anyone has any ideas I would greatly appreciate the help. The code I have: expandcollapse popup#NoTrayIcon #include <GUIConstants.au3> #region ### START Koda GUI section ### Form= $gMain = GUICreate("Select Wallpaper", 154, 211, -1, -1, BitOR($WS_CAPTION, $WS_POPUP)) GUICtrlCreateGroup("Classification", 8, 8, 137, 161) $rd_Unclass = GUICtrlCreateRadio("Unclassified", 40, 32, 81, 17) GUICtrlSetState(-1, $GUI_CHECKED) $rd_Conf = GUICtrlCreateRadio("Confidential", 40, 56, 81, 17) $rd_Secret = GUICtrlCreateRadio("Secret", 40, 80, 81, 17) $rd_TS = GUICtrlCreateRadio("Top Secret", 40, 104, 81, 17) $rd_SCI = GUICtrlCreateRadio("SCI", 40, 128, 81, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $bt_OK = GUICtrlCreateButton("OK", 24, 176, 51, 25, 0) $bt_Cancel = GUICtrlCreateButton("Cancel", 80, 176, 51, 25, 0) GUISetState(@SW_SHOW) #endregion ### START Koda GUI section ### Form= Local $files[5] = ["Unclassified.bmp", "Confidential.bmp", "Secret.bmp", "TopSecret.bmp", "SCI.bmp"] Local $nMsg, $iCurSel, $iOrigSel $iInitial = RegRead("HKLM\Software\SSCC\BC", "") If @error Then RegWrite("HKCU\Control Panel\Desktop", "WallPaper", "REG_SZ", @WindowsDir & "\Banner.bmp") RegWrite("HKCU\Control Panel\Desktop", "WallpaperStyle", "REG_SZ", "2") If @OSVersion = "WIN_VISTA" Then RunWait(@ComSpec & ' /c reg load HKLM\def "' & @HomeDrive & '\Users\Default\ntuser.dat"', @WindowsDir, @SW_HIDE) Else RunWait(@ComSpec & ' /c reg load HKLM\def "' & @HomeDrive & '\Documents and Settings\Default User\ntuser.dat"', @WindowsDir, @SW_HIDE) EndIf RegWrite("HKLM\def\Control Panel\Desktop", "WallPaper", "REG_SZ", @WindowsDir & "\Banner.bmp") RegWrite("HKLM\def\Control Panel\Desktop", "WallpaperStyle", "REG_SZ", "2") RunWait(@ComSpec & ' /c reg unload HKLM\def', @WindowsDir, @SW_HIDE) EndIf $iOrigSel = RegRead("HKLM\Software\SSCC\BC", "Classification") Switch $iOrigSel Case 1 GUICtrlSetState($rd_Conf, $GUI_CHECKED) Case 2 GUICtrlSetState($rd_Secret, $GUI_CHECKED) Case 3 GUICtrlSetState($rd_TS, $GUI_CHECKED) Case 4 GUICtrlSetState($rd_SCI, $GUI_CHECKED) Case Else $iOrigSel = 0 EndSwitch $iCurSel = $iOrigSel While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $rd_Conf And BitAND(GUICtrlRead($rd_Conf), $GUI_CHECKED) = $GUI_CHECKED $iCurSel = 1 Case $nMsg = $rd_SCI And BitAND(GUICtrlRead($rd_SCI), $GUI_CHECKED) = $GUI_CHECKED $iCurSel = 4 Case $nMsg = $rd_Secret And BitAND(GUICtrlRead($rd_Secret), $GUI_CHECKED) = $GUI_CHECKED $iCurSel = 2 Case $nMsg = $rd_TS And BitAND(GUICtrlRead($rd_TS), $GUI_CHECKED) = $GUI_CHECKED $iCurSel = 3 Case $nMsg = $rd_Unclass And BitAND(GUICtrlRead($rd_Unclass), $GUI_CHECKED) = $GUI_CHECKED $iCurSel = 0 Case $nMsg = $bt_OK If $iCurSel <> $iOrigSel Then RegWrite("HKLM\Software\SSCC\BC", "Classification", "REG_DWORD", $iCurSel) FileCopy($files[$iCurSel], @WindowsDir & "\Banner.bmp", 9) RunWait("rundll32.exe user32.dll,UpdatePerUserSystemParameters ,1,True", @ScriptDir, @SW_HIDE) EndIf Exit Case $nMsg = $bt_Cancel Exit EndSelect WEnd Link to comment Share on other sites More sharing options...
spudw2k Posted May 15, 2008 Share Posted May 15, 2008 I believe you have to be an admin to write to HKEY_LOCAL_MACHINE. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Delphinus Posted May 15, 2008 Author Share Posted May 15, 2008 Then how does a user change the wallpaper via desktop properties? Link to comment Share on other sites More sharing options...
Administrators Jon Posted May 18, 2008 Administrators Share Posted May 18, 2008 Example 3:http://support.microsoft.com/kb/q97142/ Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Delphinus Posted May 19, 2008 Author Share Posted May 19, 2008 Thanks Jon but that's not what I am looking for. I was hoping to get a bit more help than to just have examples thrown at me. I wouldn't have gotten as far as I did without doing some research. Turns out, the reason I couldn't do it as a user was that I was trying to write to the windows directory. That's something that isn't allowed as a user. I rewrote the program to have the registry reference an ini file that stores the path to the .bmp files I want to use as backgrounds. Link to comment Share on other sites More sharing options...
Administrators Jon Posted May 19, 2008 Administrators Share Posted May 19, 2008 Thanks Jon but that's not what I am looking for. I was hoping to get a bit more help than to just have examples thrown at me. I wouldn't have gotten as far as I did without doing some research.An exact example of the API call to change the desktop background in a totally supported way that will work on all versions of Windows rather than a nasty reg hack that likely won't?Fine. My help here is done. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Delphinus Posted May 19, 2008 Author Share Posted May 19, 2008 Yes, that changes the desktop but not in the way that I was trying to change it. Didn't mean to offend but all you did was throw an example at me without even looking at the code I wrote. Link to comment Share on other sites More sharing options...
spudw2k Posted May 19, 2008 Share Posted May 19, 2008 Then how does a user change the wallpaper via desktop properties?Any user can write to their own NTUSER.DAT file (mounted as HKEY_CURRENT_USER when logged in) Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Administrators Jon Posted May 19, 2008 Administrators Share Posted May 19, 2008 From the script I'm not quite sure what you are trying to do. You are writing to the Default User wallpaper - but that is only used when a brand new user profile is created - it doesn't change existing wallpapers. Are you trying to change the wallpaper for ALL users that have already logged into a machine? Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Delphinus Posted May 19, 2008 Author Share Posted May 19, 2008 I want to change it for the current user that is logged in when they run the script and for any user that already has a profile on the machine (including administrators) and for any new user that will login and create a new profile, ie the 'default user'. 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