Skip to content

Instantly share code, notes, and snippets.

@ezhov-da
Last active March 10, 2019 12:24
Show Gist options
  • Save ezhov-da/bd29005eac133813ee58ecac74be900f to your computer and use it in GitHub Desktop.
Save ezhov-da/bd29005eac133813ee58ecac74be900f to your computer and use it in GitHub Desktop.
Run application
@echo off
echo Started script: E:\_git_local_data_\trunk\java\groovy-scripts\src\main\groovy\ru\ezhov\groovy\appRunnable.groovy
echo "================================================================================="
E:\java_library\groovy-2.4.12\bin\groovy.bat E:\_git_local_data_\trunk\java\groovy-scripts\src\main\groovy\ru\ezhov\groovy\appRunnable.groovy
def listApplicationsPath = [
'E:/apps/ConEmuPack.161206/ConEmu64.exe' : '0',
'E:/Programs/KeePass/KeePass.exe' : '0',
'\"C:/Program Files (x86)/Mozilla Firefox/firefox.exe\"' : '0',
'\"C:/Program Files (x86)/FreeCommander/FreeCommander.exe\"': '0',
'E:/Programs/Notepad++/notepad++.exe' : '0',
'E:/Users/ezhov_da/AppData/Local/riot/Riot.exe' : '0',
'E:/Programs/ideaIC-2017.1.3.win/bin/idea64.exe' : '0'
]
printSelected(listApplicationsPath)
def scanner = new Scanner(System.in)
def number = 0
while (scanner.hasNextLine()) {
def selectedNumber = scanner.nextLine()
try {
number = Integer.parseInt(selectedNumber)
break
} catch (any) {
println("Input data is not number...")
}
}
println("Selected number: ${number}")
if (number == -1){
println("Exit...")
System.exit(0)
}
start(listApplicationsPath, number)
private void printSelected(Map<String, String> listApplicationsPath) {
println(
"""Select number which application must be run:
0 : All application"""
)
def counter = 1
listApplicationsPath.forEach { k, v ->
println("${counter} : ${k}")
counter++
}
println()
println("""-1 : EXIT""")
}
private void start(Map<String, String> listApplicationsPath, int number) {
def counter = 1
listApplicationsPath.forEach { k, v ->
if (number == 0 || number == counter) {
def runtime = Runtime.getRuntime()
print("Start: ${k}.")
runtime.exec(k)
print(" Start complete.")
println(" Wait ${v}.")
println(counter)
Thread.sleep(Integer.parseInt(v))
}
counter++
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment