Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @ ECHO OFF
- setlocal enabledelayedexpansion
- REM Usage, pass in file types you want to execute command line.
- REM or set the following variable to define the default types to be executed
- REM e.g. set filtypes=exe bat msi
- set filetypes=exe bat msi
- REM Works with file and folder names that include spaces
- REM Easiest way to use this is probably to set filetypes to a default
- REM Copy the script to the folder with whatever you want executed
- REM double click the batch file
- REM Switch to whatever drive letter this is being run from (e.g. "c:")
- %~d1
- REM change in to the directory of where this script is being run
- cd "%~dp0"
- set argCount=0
- set regexes=
- REM count how many arguments were passed in
- for %%x in (%*) do Set /A argCount+=1
- REM if arguments were passed in, overwrite the default types with the passed in ones
- if %argCount% gtr 0 set filetypes=%*
- REM put together full expressions to be used to search for the files
- REM e.g. "C:\tmp\*.exe C:\tmp\*.bat C:\tmp\*.msi"
- for %%r in (%filetypes%) do (
- set regexes=!regexes! *.%%r
- )
- REM go through all of the regular expressions
- REM use them to search the current directory for matching files
- REM (2 if conditional to cover commandline run vs gui run)
- REM then execute those files as long as it is not this file
- echo %regexes%
- for %%f in (%regexes%) do (
- if not %%f == %0 (
- if not "%~dp0%%f" == %0 (
- echo ********************************
- echo executing %%f
- call "%%f"
- )
- )
- )
- pause
- @ ECHO ON
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement