Здравствуйте, гость ( Вход | Регистрация )

> Run .bat file with execandwait()
neves
сообщение 3.4.2020, 17:40
Сообщение #1


***

Novice
Сообщений: 64
Регистрация: 4.10.2019
Группа: Пользователи
Наличность: 0
Пользователь №: 19.419
Возраст: 19



I have very long .bat file with many settings, which STARTS and .exe file. I wanna execute this .bat file using execandwait() function, but it waits for the cmd to be executed and doesn't waits for the script in bat to be executed.
Example:
Lets say I have this test.bat file:
Код
START C:\Windows\NOTEPAD.EXE

With notepad.exe is hard to see the problem, so change the path to any application which loads slower. (Ex: D:\Game\CLIENT.EXE)
Then I start this script:
Код
--lua
wait(1000)
execandwait("D:\\test.bat")

And script stops before the given .EXE is executed.
Does anyone faced this problem and can it be solved?
Пользователь в офлайнеDelete PostОтправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения
 
Ответить в эту темуОткрыть новую тему
Ответов
cirus
сообщение 3.4.2020, 21:24
Сообщение #2


**********

Elder
Сообщений: 3.480
Регистрация: 18.8.2014
Группа: Пользователи
Наличность: 25706
Пользователь №: 16.971
Возраст: 29



Код
--lua
exec ("C:\\test.bat")  -- run the application

local handle = nil
while handle == nil do   -- wait for it to open
    handle = findwindow("window name")
    wait (100)
end
log(111)
Пользователь в офлайнеDelete PostОтправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения
neves
сообщение 3.4.2020, 21:45
Сообщение #3


***

Novice
Сообщений: 64
Регистрация: 4.10.2019
Группа: Пользователи
Наличность: 0
Пользователь №: 19.419
Возраст: 19



Цитата(Fors1k @ 3.4.2020, 20:11) *

Script:
Код
--lua
function exec_my_bat (path)
    write ([[D:\app.txt]], "1")
    exec(path)
    while not(s=="0") do s = fileexists ([[D:\app.txt]]);wait(5) end
end
---
exec_my_bat([[D:\test.bat]])
log("Launched!")


This isn't actually waits for the application to load.
Цитата(cirus @ 3.4.2020, 20:24) *

Код
--lua
exec ("C:\\test.bat")  -- run the application

local handle = nil
while handle == nil do   -- wait for it to open
    handle = findwindow("window name")
    wait (100)
end
log(111)


Yes, that's a temporary solution, but I'm searching for better way to do it.


I found out that you can run batch script DIRECTLY in cmd.exe.
Is it possible to run the batch script in cmd.exe using exec()?

Something like this:?
Код
exec("cmd.exe", "START C:\Windows\NOTEPAD.EXE")
Пользователь в офлайнеDelete PostОтправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения



Ответить в эту темуОткрыть новую тему
2 чел. читают эту тему (гостей: 2, скрытых пользователей: 0)
Пользователей: 0

 

- Текстовая версия | Версия для КПК Сейчас: 31.12.2025, 20:26
Designed by Nickostyle