RBrown1375 Posted October 24, 2012 Share Posted October 24, 2012 I was wondering if there was a way in AutoIT to install a standard windows background for windows 7. The script below works fine for XP SP3 but fails on Windows 7 and I think it needs Admin Perms but I'm not sure. Please let me know if its possible. Cheers! if not exist "C:\Windows\System32\oobe\Info" mkdir "C:\Windows\System32\oobe\Info" if not exist "C:\Windows\System32\oobe\Info\backgrounds" mkdir "C:\Windows\System32\oobe\Info\backgrounds" copy "\\mitfile\userdata\everyone\bg\backgroundDefault.jpg" "C:\Windows\System32\oobe\Info\backgrounds" REG ADD "HKCU\Control Panel\Desktop" /V Wallpaper /T REG_SZ /F /D "C:\Windows\System32\oobe\Info\backgrounds\backgroundDefault.jpg" REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background" /V OEMBackground /T REG_DWORD /F /D 1 Link to comment Share on other sites More sharing options...
JScript Posted October 24, 2012 Share Posted October 24, 2012 Read this link: JS http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
guinness Posted October 24, 2012 Share Posted October 24, 2012 That code isn't AutoIt syntax. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
JScript Posted October 24, 2012 Share Posted October 24, 2012 @guinnessI was wondering if there was a way in AutoIT to install a standard windows background for windows 7.JS http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
guinness Posted October 24, 2012 Share Posted October 24, 2012 Whoops, sorry. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
RBrown1375 Posted October 24, 2012 Author Share Posted October 24, 2012 (edited) Thanks for the response. The code snippit you sent will change the background at the login screen, but I need it to change the background image on the desktop so that all machines will have the same background. I'm going to deliver this with SCCM. The environment will be Win 7 x64 and x86. I started the code in for a Batch file but I want to do it in a code I trust. The last three packages I built in AutoIT worked perfectly. Thanks Edited October 24, 2012 by RBrown1375 Link to comment Share on other sites More sharing options...
BrewManNH Posted October 24, 2012 Share Posted October 24, 2012 Are you on an AD domain? It can be done very easily with group policy if that's the case. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
RBrown1375 Posted October 24, 2012 Author Share Posted October 24, 2012 I am on the AD domain but it fails on the our GPO's. If you have a work around for GPO or correct settings I'll check them against our settings. But so far our GPO attemps failed. Link to comment Share on other sites More sharing options...
BrewManNH Posted October 24, 2012 Share Posted October 24, 2012 This is where I set the policy:User Configuration (Enabled) Windows Settings Administrative Templates Desktop Active Desktop Enable Active Desktop = Enabled Active Desktop Wallpaper Wallpaper Name: <location of the wallpaper file> use exact path Example: Using a local path: C:windowswebwallpaperhome.jpg Example: Using a UNC path: ServerShareCorp.jpg Wallpaper Style: Tile Policy Setting Enable Active Desktop Enabled Allows HTML and JPEG Wallpaper If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
RBrown1375 Posted October 24, 2012 Author Share Posted October 24, 2012 I'll give it a try. Thanks. Link to comment Share on other sites More sharing options...
RBrown1375 Posted October 24, 2012 Author Share Posted October 24, 2012 I'm going to try and do a script. The GPO's here are so messed up I'd spend weeks trying to get it to work. I just hope one of them isn't blocking the script. If you know of a road map I could follow to do this that would be great. Thanks Link to comment Share on other sites More sharing options...
BrewManNH Posted October 24, 2012 Share Posted October 24, 2012 You only need to put it into one GP that affects the user's you're looking to apply this for, as long as you can identify one GP that does that, you shouldn't need to worry about what the rest are doing, as long as there isn't another GP that sets a background wallpaper. As to a guide to straightening out group policy, I haven't found one yet that's useful for any occasion. I just set them as I see them working best. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
RBrown1375 Posted October 25, 2012 Author Share Posted October 25, 2012 Thanks for the replys and I know this isn't the forum for GPO's, butits just wierd that I addedit to the GPO for Win 7 and if I look at the properties of the desktop the correct image is there, but it is not the image I see on the desk top. I'll keep digging and thank you for yoru responses. Cheers Link to comment Share on other sites More sharing options...
RBrown1375 Posted October 30, 2012 Author Share Posted October 30, 2012 The GPO's around here are pretty bad and I don't have time to work on them. I wrote this VBscript and it works if I run it by hand but fails in SCCM 2007 and I want to run this in Autoit since I trust it more than VBScript. Can someone tell me if Autoit can do the same thing as this VBS code? Thanks ***This runs frist to delete the registry setting Wallpaper to get around Windows 7 bugs*** const HKEY_CURRENT_USER = &H80000001 strComputer = "." Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!" &_ strComputer & "rootdefault:StdRegProv") strKeyPath = "Control PanelDesktop" strStringValueName = "Wallpaper" oReg.DeleteValue HKEY_CURRENT_USER,strKeyPath,strStringValueName ***This runs next to add the new background and set it to strech*** Dim wshShell Dim sUserName Set oShell = CreateObject("WScript.Shell") Set oFSO = CreateObject("Scripting.FileSystemObject") Set WshShell = WScript.CreateObject("WScript.Shell") sUserName = wshShell.ExpandEnvironmentStrings("%USERNAME%") '''If the Operating System is Windows XP set the background to c:WindowsResourcesThemesMIT.bmp If WshShell.RegRead ("HKLMSOFTWAREMicrosoftWindows NTCurrentVersionCurrentVersion") = "5.1" Then sWinDir = oFSO.GetSpecialFolder(0) sWallPaper = "%systemdrive%WindowswebwallpaperwindowsMIT.bmp" oShell.RegWrite "HKCUControl PanelDesktopWallpaper", sWallpaper oShell.Run "%windir%System32RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters", 1, True '''Otherwise, if the Operating System is Windows 7, set the Theme to C:WindowsResourcesThemesMIT.Theme ElseIf WshShell.RegRead ("HKLMSOFTWAREMicrosoftWindows NTCurrentVersionCurrentVersion") = "6.1" Then sWinDir = oFSO.GetSpecialFolder(0) sWallPaper = "%systemdrive%WindowswebwallpaperwindowsMIT.bmp" oShell.RegWrite "HKCUControl PanelDesktopWallpaper", sWallpaper oShell.Run "%windir%System32RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters", 1, True End If Link to comment Share on other sites More sharing options...
RBrown1375 Posted October 30, 2012 Author Share Posted October 30, 2012 Just as an update, thanks for the help but I got it to work in AutoIT and here is my code if someone needs it. Cheers ; Include a bitmap found in "C:test.bmp" with the compiled program and put it in "D:mydirtest.bmp" when it is run Local $b = True If $b = True Then FileInstall("E:bgbmpMit.bmp", "C:WindowsWebWallpaperWindowsmit.bmp") RegDelete("HKEY_CURRENT_USERControl PanelDesktop", "wallpaper") ;Deletes the Regkey because of Windows 7 Bug Sleep(3000) $wallpaper = FileOpenDialog(@WindowsDir & "", "C:WindowsWebWallpaperWindows(MIT.bmp)", 1) WallpaperChange($wallpaper) Func WallpaperChange($image) ;Desktop Position: Stretch RegWrite("HKEY_CURRENT_USERControl PanelDesktop", "Wallpaper", "REG_SZ", "C:WindowsWebWallpaperWindowsMit.bmp") RegWrite("HKEY_CURRENT_USERControl PanelDesktop", "WallpaperStyle", "REG_SZ", 2) RegWrite("HKEY_CURRENT_USERControl PanelDesktop", "TileWallpaper", "REG_SZ", 0) ;;;;;;;;;;;;;;;;;;;;;;;;;; EndFunc ;==> WallpaperChange Link to comment Share on other sites More sharing options...
PhoenixXL Posted October 30, 2012 Share Posted October 30, 2012 (edited) If its only the Desktop Wallpaper Changer then I have made a script with GUI earlier, tried hard but wasnt able to make the fade in and out effect seen as by default in Win7 WallpaperChanger GUI - no fading options expandcollapse popup#NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=....Change Wallpaper.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** If @Compiled Then RegWrite("HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionRun", @ScriptName, "REG_SZ", @ScriptFullPath) Global $search #include-once _Singleton(Binary("XPhoenix|TestX"),0) OnAutoItExitRegister("_exit") Dim $iniread,$iniread0,$iniread1 Global Const $GUI_DROPACCEPTED = 8 Global Const $GUI_SHOW = 16 Global Const $GUI_HIDE = 32 Global Const $GUI_ENABLE = 64 Global Const $GUI_DISABLE = 128 Global Const $GUI_EVENT_CLOSE = -3 Global Const $GUI_CHECKED = 1 Global Const $tagSECURITY_ATTRIBUTES = "dword Length;ptr Descriptor;bool InheritHandle" Global Const $GUI_UNCHECKED = 4 Global Const $BS_DEFPUSHBUTTON = 0x0001 Global Const $BS_PUSHLIKE = 0x1000 Global Const $GUI_EVENT_DROPPED = -13 Global Const $GUI_FOCUS = 256 Global $Images,$time,$Gfolder,$continue=True,$gUI,$default="",$ir,$no=1,$RANDOM=True,$it,$z Global $imgformats[11] $imgformats[0]="JPG" $imgformats[1]="TIF" $imgformats[2]="RLE" $imgformats[3]="PNG" $imgformats[4]="GIF" $imgformats[5]="BMP" $imgformats[7]="TIFF" $imgformats[8]="JFIF" $imgformats[9]="JPEG" $imgformats[10]="JPE" $imgformats[6]="DIB" $directory=@AppDataDir&"Wallpaper" DirCreate($directory) $lNi=$directory&"Data.ini" $Data="ïèª~¦A&â?NS-1-22994-65311`-123551||=123123" HotKeySet("+!c","_toogle") If _checkdirectory(0)=0 Then _guicreate(0) Func _guicreate($pwm) $gUI=GUICreate("Window",450,200,-1,-1,-1,0x00000018) $label=GUICtrlCreateLabel("Type the Path of the Image or...",10,10,160,20) If $pwm=0 Then $input=GUICtrlCreateInput("Drag Your Folder Containing Image Here",10,40,430,30) $type=GUICtrlCreateInput("45000",10,110,430,30) EndIf If $pwm=1 Then If $ir<>"" Then $input=GUICtrlCreateInput($ir,10,40,430,30) Else $input=GUICtrlCreateInput($iniread,10,40,430,30) EndIf If $it<>"" Then $type=GUICtrlCreateInput($it,10,110,430,30) Else $type=GUICtrlCreateInput($iniread0,10,110,430,30) EndIf EndIf GUICtrlSetState(-1, $GUI_DROPACCEPTED) $label1=GUICtrlCreateLabel("Type The Time Interval Of Change Of Wallpaper in Milliseconds(Decimal Value Supported) ",10,80,439,20) $ok=GUICtrlCreateButton("&OKAY",310,150,60,40,$BS_DEFPUSHBUTTON) $cancel=GUICtrlCreateButton("E&XIT",380,150,60,40) $browse=GUICtrlCreateButton("B&ROWSE",240,150,60,40) $ChangeR=GUICtrlCreateCheckbox("RA&NDOM",10,150,90,40,$BS_PUSHLIKE) If $RANDOM=True Then GUICtrlSetState(-1,$GUI_CHECKED) If $RANDOM=False Then GUICtrlSetState(-1,$GUI_UNCHECKED) GUISetState(@SW_SHOW,$gUI) While 1 $sMsg=GUIGetMsg() Switch $sMsg Case $ok If GUICtrlRead($ChangeR)=$GUI_CHECKED Then $RANDOM=True If GUICtrlRead($ChangeR)=$GUI_UNCHECKED Then $RANDOM=False $ir=GUICtrlRead($input) $it=GUICtrlRead($type) If $ir="" Or $type="" Or $ir="Drag Your Folder Containing Image Here" Then MsgBox(64,"Information","Type The Path Of The Folder",0,$gUI) GUICtrlSetData($input,"") GUICtrlSetState($input,$GUI_FOCUS) ContinueLoop ElseIf $it<10000 Then MsgBox(64,"Information","The Timer Should Be Minimum 10 Seconds",0,$gUI) GUICtrlSetData($type,10000) ContinueLoop ElseIf Not FileExists($ir) Then MsgBox(16,"Error","The File '"&$ir&"' Doesn't Exist.",0,$gUI) ContinueLoop ElseIf StringInStr(FileGetAttrib($ir),"D",1)=0 Then MsgBox(16,"Error","The File '"&$ir&"' is not a Directory",0,$gUI) ContinueLoop EndIf GUISetState(@SW_DISABLE,$gUI) If _findfileandchangepaper(_checkslash($ir),$it,0)=True Then GUIDelete($gUI) _checkdirectory($ir,$it) _traytip() _findfileandchangepaper(_checkslash($ir),$it) ExitLoop EndIf Case $browse $Gfolder=FileSelectFolder("Folder With Images","",1,$default,$gUI) $default=$Gfolder _checkdirectory($default,"0",True) GUICtrlSetData($input,$Gfolder) Case $cancel Exit Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc Func _traytip() Local $x=TimerInit() While TimerDiff($x)<=12000 ToolTip("To Change The Settings Press Shift+Alt+C",Default,Default,"Information",1,5) Sleep(10) WEnd ToolTip("") EndFunc Func _findfileandchangepaper($folder,$time,$pwm=1) Local $suicude=0 $search=FileFindFirstFile($folder&"*.*") While 1 $file=FileFindNextFile($search) If @error Then ExitLoop $suicude+=1 WEnd For $i In $imgformats $search=FileFindFirstFile($folder&"*."&$i) If $search=-1 Then $suicude-=1 If $suicude=0 Then $continue=True MsgBox(64,"Information","There Are No Image Files In The Directory Or The Image Files Are Currently Not Supported",0,$gUI) Return False EndIf While 1 $file=FileFindNextFile($search) If @error Then ExitLoop $Images&=$file&"|" WEnd Next If $pwm=0 Then Return True $continue=False $z=$folder AdlibRegister('_change',$time) While 1 Sleep(10) WEnd EndFunc Func _change() $split=StringSplit($Images,"|",1) If $RANDOM Then ChangeDesktopWallpaper($z&$split[Random(1,$split[0],1)],2) If Not $RANDOM Then ChangeDesktopWallpaper($z&$split[$no],2) $no+=1 EndIf If $no=$split[0] Then $no=1 EndFunc Func _checkslash($2check) If StringRight($2check,1)="" Then Return $2check If StringRight($2check,1)<>"" Then Return $2check&"" EndFunc Func _checkdirectory($folderx,$time="45000",$edit=False) If $folderx="0" Then $iniread2=IniRead($lNi,$Data,"Random","0") $iniread=IniRead($lNi,$Data,"Folder","0") $iniread0=IniRead($lNi,$Data,"Time","0") $iniread1=IniRead($lNi,$Data,"Default",'""') If $iniread="0" Or $iniread0="0" Or $iniread2="0" Then Return 0 Else $default=$iniread1 $RANDOM=$iniread2 _findfileandchangepaper(_checkslash($iniread),$iniread0) EndIf ElseIf $edit=True Then IniWrite($lNi,$Data,"Default",$folderx) ElseIf $folderx<>"0" Then IniWrite($lNi,$Data,"Folder",$folderx) IniWrite($lNi,$Data,"Time",$time) IniWrite($lNi,$Data,"Random",$RANDOM) EndIf EndFunc Func _toogle() AdlibUnRegister('_change') $Images="" _guicreate(1) EndFunc Func _exit() FileClose($search) Exit EndFunc Func DebugLog($Message, $Line = @ScriptLineNumber) If Not @Compiled Then ConsoleWrite("(" & $Line & "): " & $Message & @CRLF) EndIf EndFunc ;==>DebugLog Func _Singleton($sOccurenceName, $iFlag = 0) Local Const $ERROR_ALREADY_EXISTS = 183 Local Const $SECURITY_DESCRIPTOR_REVISION = 1 Local $pSecurityAttributes = 0 If BitAND($iFlag, 2) Then ; The size of SECURITY_DESCRIPTOR is 20 bytes. We just ; need a block of memory the right size, we aren't going to ; access any members directly so it's not important what ; the members are, just that the total size is correct. Local $tSecurityDescriptor = DllStructCreate("dword[5]") Local $pSecurityDescriptor = DllStructGetPtr($tSecurityDescriptor) ; Initialize the security descriptor. Local $aRet = DllCall("advapi32.dll", "bool", "InitializeSecurityDescriptor", _ "ptr", $pSecurityDescriptor, "dword", $SECURITY_DESCRIPTOR_REVISION) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then ; Add the NULL DACL specifying access to everybody. $aRet = DllCall("advapi32.dll", "bool", "SetSecurityDescriptorDacl", _ "ptr", $pSecurityDescriptor, "bool", 1, "ptr", 0, "bool", 0) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then ; Create a SECURITY_ATTRIBUTES structure. Local $structSecurityAttributes = DllStructCreate($tagSECURITY_ATTRIBUTES) ; Assign the members. DllStructSetData($structSecurityAttributes, 1, DllStructGetSize($structSecurityAttributes)) DllStructSetData($structSecurityAttributes, 2, $pSecurityDescriptor) DllStructSetData($structSecurityAttributes, 3, 0) ; Everything went okay so update our pointer to point to our structure. $pSecurityAttributes = DllStructGetPtr($structSecurityAttributes) EndIf EndIf EndIf Local $handle = DllCall("kernel32.dll", "handle", "CreateMutexW", "ptr", $pSecurityAttributes, "bool", 1, "wstr", $sOccurenceName) If @error Then Return SetError(@error, @extended, 0) Local $lastError = DllCall("kernel32.dll", "dword", "GetLastError") If @error Then Return SetError(@error, @extended, 0) If $lastError[0] = $ERROR_ALREADY_EXISTS Then If BitAND($iFlag, 1) Then Return SetError($lastError[0], $lastError[0], 0) Else Exit -1 EndIf EndIf Return $handle[0] EndFunc ;==>_Singleton Func ChangeDesktopWallpaper($bmp,$style) ;=============================================================================== ; Usage: _ChangeDesktopWallPaper(@WindowsDir & '' & 'zapotec.bmp') ; Parameter(s): $bmp - Full Path to BitMap File (*.bmp) ; Requirement(s): None. ; Return Value(s): On Success - Returns 0 ; On Failure - -1 ;=============================================================================== If Not FileExists($bmp) Then Return -1 ;The $SPI* values could be defined elsewhere via #include - if you conflict, ; remove these, or add if Not IsDeclared "SPI_SETDESKWALLPAPER" Logic Local $SPI_SETDESKWALLPAPER = 20 Local $SPIF_UPDATEINIFILE = 1 Local $SPIF_SENDCHANGE = 2 Local $REG_DESKTOP= "HKEY_CURRENT_USERControl PanelDesktop" ;Don't tile - just center If $style=0 Or $style=2 Then RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 0) RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", $style) Else RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", $style) RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", 0) EndIf RegWrite($REG_DESKTOP, "Wallpaper", "REG_SZ", $bmp) DllCall("user32.dll", "int", "SystemParametersInfo","int", $SPI_SETDESKWALLPAPER, "int", 1, "str", $bmp, "int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE)) Return 0 EndFunc;==>_ChangeDestopWallpaper Edited October 30, 2012 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
RBrown1375 Posted October 31, 2012 Author Share Posted October 31, 2012 I'll take a look at your script, but right now I'm trying to figure out why my script runs just fine by hand, but fails with SCCM 2007. SCCM delivers the script, adds the BMP, but doesn't seem to want to write to the registry, I added this to the script above: Local $sUserName = "MyName" ;Domain Admin level Local $sPassword = "MyPassword" RunAs($sUserName, @ComputerName, $sPassword, 0, @SystemDir) But even with these permissions, it doesn't write to the registry. If I right click the script and do a "run as admin" it works everytime. I will look your script over later and thank you for posting it.I do have SCCM set to run it as Admin as well and I have made sure no GPO is stopping it from writing to the registry. Just in time for Halloween- Spooky! Cheers 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