strFilter= "JPG|JPEG|JPE|GIF|BMP|DIB|TIF|TIFF|PNG|PCX|TXT|PDF" 'Include just these file types Set FSO = CreateObject("Scripting.FileSystemObject") 'These objects are needed to locate Set Shell = CreateObject("WScript.Shell") 'and run files scriptFile = Wscript.ScriptName scriptFolder= FSO.GetParentFolderName(Wscript.ScriptFullName) 'Location of Script folder strApp= FSO.GetParentFolderName(scriptFolder) &"\i_view32.exe" 'Location of Irfanview executable file strDesktop= Shell.SpecialFolders("Desktop") 'Location of current user desktop strTempfile= strDesktop & "\listfile.txt" 'Temporary file to hold file list strShortcut= strDesktop & "\" & Replace(scriptFile,".vbs",".lnk",1,1,1) 'Desktop shortcut for the script If FSO.FileExists(strApp) then 'Check that App file exists If NOT FSO.FileExists(strShortcut) then Make_link 'Create a shortcut if none exists strApp = chr(34) & strApp & chr(34) 'Add quote marks in case name contains spaces Select Case Wscript.Arguments.Count 'How many files were passed? Case 0 Shell.Run strApp 'No files.Just open Irfanview Case 1 If Suffix(WScript.Arguments(0))= "TXT" then 'One file. Check what type Shell.Run strApp &" /filelist=" & WScript.Arguments(0), 1, true 'Open Irfanview with text file ElseIf FSO.Fileexists(strTempfile) then Add_to_list(strTempfile) 'or add to file list, if there is one Else Shell.Run strApp & " " & Wscript.Arguments(0) 'or open normally End If Case Else Add_to_list(strTempfile) End Select Else 'Cannot find Irfanview msgbox "Irfanview could not be found at .. " & strApp End If Set shell = Nothing Set FSO = Nothing Wscript.Quit Sub Add_To_list(listfile) 'Builds the file list Set f1 = FSO.OpenTextFile(listfile, 8, True) 'Open list for appending For n=0 to Wscript.Arguments.Count-1 'Check which files to include If Checkout(WScript.Arguments(n),strFilter)=True then f1.WriteLine Wscript.Arguments(n) 'Add this one to list Next Set f1 = FSO.GetFile(listfile) mysize = f1.size 'Record present size of temp file Shell.Run strApp &" /killmesoftly", 1, true 'Close any existing Irfanview windows Shell.Run strApp &" /filelist=" & listfile, 1, true 'Open Irfanview, then wait for it to be closed If f1.size = mysize then FSO.deletefile(listfile) 'Delete temp file if size is unchanged Set f1 = Nothing End Sub Function Checkout(filetype,filter) 'Check the filetype extension If len(filter)<2 then Checkout=True : Exit function 'Accept everything if filter is empty filetype ="|" & Suffix(filetype) & "|" 'Add delimiters to ends of suffix filter = "|" & filter & "|" ' and of filter If Instr(1,filter,filetype,1)=0 then Checkout=False else Checkout=True 'Accept only if specified file type End Function Function Suffix(filename) 'General function to return file suffix dot=InstrRev(filename,".") If dot=0 then Suffix = "None" Else Suffix= Ucase(Right(filename, len(filename)-dot)) End Function Sub Make_link 'Creates a shortcut to the Irfanview executable file set ShellLink = Shell.CreateShortcut(strShortcut) ShellLink.TargetPath = WScript.ScriptFullName ShellLink.WindowStyle = 1 ShellLink.IconLocation = strApp & ",1" ShellLink.Description = "Irfanview launcher shortcut" ShellLink.WorkingDirectory = strDesktop ShellLink.Save End Sub