我有以下批处理文件
@echo off
setlocal enableextensions enabledelayedexpansion
rem // Read all lines from this batch file that begin with `php72 ` and iterate over them:
for /F "delims=" %%C in ('
findstr /BIC:"php72 " "%~f0"
') do (
rem // Execute the currently iterated `php72` command line:
start %%C
SET checktasklist=true
FOR /L %%A IN (1,1,30) DO (
FOR /F %%x IN ('IF "!checktasklist!" == "true" tasklist /NH /FI "IMAGENAME eq php72.exe"') DO (
IF "%%x" == "php72.exe" (
timeout /T 1 /NOBREAK >NUL
) ELSE (
SET checktasklist=false
)
)
)
taskkill /IM "php72.exe" /F > nul 2>&1
)
rem // Avoid to fall into the `php72` command lines another time:
exit /B
php72 ../simulation.php --version 0.9.0.4 --hashsimmilar false --thinkahead 0 --detailed 0 --outfile catacombs.outfile.csv --workingdir "C:/xampp/htdocs/rpg_prog/" --customfight 1,2,,,,1,,,1,,0,0,0,Catacombs1
php72 ../simulation.php --version 0.9.0.4 --hashsimmilar false --thinkahead 1 --detailed 0 --outfile catacombs.outfile.csv --workingdir "C:/xampp/htdocs/rpg_prog/" --customfight 1,2,,,,1,,,1,,0,0,0,Catacombs1
php72 ../simulation.php --version 0.9.0.4 --hashsimmilar false --thinkahead 2 --detailed 0 --outfile catacombs.outfile.csv --workingdir "C:/xampp/htdocs/rpg_prog/" --customfight 1,2,,,,1,,,1,,0,0,0,Catacombs1
.... continued with 190 lines of more simmilar lines like the above
我要在此批处理文件中执行的操作是运行每个php72.exe ...
命令,等待30秒,但前提是它们仍在运行,并且如果它们仍在30秒后运行,请终止它们,并转到下一个php72.exe ...
行。
我已经设法实现了这一目标,但是在大多数情况下,php72.exe
文件将在0.8秒内运行,但是我仍然执行tasklist /NH...
命令30次,这会使速度变慢。这就是为什么我要在其中放置局部变量的原因,即如果任务在迭代后没有运行,则无需再次测试剩余的迭代次数。
现在,我收到"true" was unexpected at this time.
这个错误。我不明白为什么会这样,或者我怎么能达到我想要的行为。任何帮助将不胜感激。
答案 0 :(得分:1)
问题在于部分library(shiny)
ui <- fluidPage(
titlePanel("Update Slider - Isolate reaction?"),
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30),
actionButton("set1", "set slider 'bins'$value=20"),
actionButton("set2", "'ISOLATED' set slider 'bins'$value=20 ")
),
mainPanel(
textOutput("sliderValue")
)
)
)
# Define server logic
server <- function(input, output, session) {
output$sliderValue <- renderText({ saved_bins(); })
update <- reactiveVal(TRUE)
saved_bins <- reactiveVal(30)
observeEvent(input$bins, {
if (update()) saved_bins(input$bins) else update(TRUE)
})
observeEvent(input$set1,{
updateSliderInput(session,"bins",value=20)
})
observeEvent(input$set2,{
## Is there any possibility to update the slider without 'sliderValue' changing?
#isolate does not work
update(FALSE)
updateSliderInput(session,"bins",value=20)
})
}
shinyApp(ui = ui, server = server)
:由于它出现在IF "!checktasklist!" == "true"
中,因此未转义的for /F
符号会转换为空格,因此您需要像这样对它们进行转义:
=
您还可以将标志变量 ...
FOR /F %%x IN ('IF "!checktasklist!" ^=^= "true" ...') DO (
...
的FALSE值更改为空,而只需使用checktasklist
即可:
if defined
基于original script的完全不同的方法:
如何替换行:
...
SET "checktasklist=true"
FOR /L %%A IN (1,1,30) DO (
FOR /F %%x IN ('if defined checktasklist tasklist /NH /FI "IMAGENAME eq php72.exe"') DO (
IF "%%x" == "php72.exe" (
timeout /T 1 /NOBREAK >NUL
) ELSE (
SET "checktasklist="
)
)
)
...
通过这个:
start "" /B %%C
这应该在完成每个start "" /B cmd /C %%C ^& taskkill /IM "timeout.exe" /F ^> nul 2^>^&1
过程之后终止timeout
过程。