' ---------------------------------------------------------- ' Script d'affichage d'un fond d'écran à partir d'une ' adresse Internet ou d'un fichier local ' Syntaxe: ' setwallpaper ' Paramètre: ' : peut être, au choix : ' - soit un URL de téléchargement (http://www.../doc/image.jpg) ' - soit un nom de fichier local ' ' Ce script nécessite le contrôle ActiveX "jcb.ocx" ' ' JC BELLAMY © 2002 ' ---------------------------------------------------------- On Error Resume Next Dim args,shell,fso Set args = Wscript.Arguments Set shell = WScript.CreateObject("WScript.Shell") Set fso = WScript.CreateObject("Scripting.FileSystemObject") jcbCOM="jcb.tools" TestCOMExists jcbCOM,"jcb.ocx" set tools = wscript.CreateObject(jcbCOM,"event_") If args.count=0 Then wscript.quit vbTextCompare=1 param=args(0) p=InStr(1,param,"http://", vbTextCompare) If p=1 Then URL=param p=InStrRev(param,"/") FileName=shell.ExpandEnvironmentStrings("%windir%") & "\Web\Wallpaper\" & mid(param,p+1) res=tools.GetWebFile(URL,FileName) Else FileName=param res=fso.FileExists(FileName) End If If res Then tools.SetDesktop FileName Wscript.quit '-------------------------------------------------------------------- ' Fonction de récupération du répertoire courant Function GetPath() Dim path path = WScript.ScriptFullName GetPath = Left(path, InStrRev(path, "\")) End Function '-------------------------------------------------------------------- Sub TestCOMExists(name,module) ' Vérification d'installation d'un objet COM on error resume next clef="HKCR\" & name & "\" dummy = shell.RegRead(Clef) if err.number<>0 then ' contrôle ActiveX non enregistré pathmodule=getpath()& module If not fso.fileExists(pathmodule) Then Mess = "Le contrôle ActiveX " & name & " est requis." & VBCRLF Mess=Mess & "Il est contenu dans le fichier " & module & VBCRLF Mess=Mess & "Or ce fichier n'a pas été trouvé." & VBCRLF MsgBox Mess, vbOKOnly + vbExclamation wscript.quit End If err.clear shell.Run "regsvr32.exe /s " & chr(34) & pathmodule & chr(34), SW_SHOWNORMAL,true dummy = shell.RegRead("HKCR\" & name & "\") if err.number<>0 then Mess = "Le contrôle ActiveX " & name & " n'a pas pu être enregistré" MsgBox Mess, vbExclamation wscript.quit end if end if End Sub '--------------------------------------------------------------------