UoKit.com Форумы > Кликер > UO Pilot
Страницы: 1, 2
neves
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?
Вверх
Fors1k
test.bat
Код
START /wait C:\Windows\System32\notepad.exe

Вверх
neves
It's not working as it should.
Вверх
cirus
Isn't it easier to launch the app from the uopilot?
Вверх
Fors1k
Цитата(cirus @ 3.4.2020, 18:36)

Isn't it easier to launch the app from the uopilot?

neves, the same question
Вверх
neves
I have very long .bat file with many settings. I gave notepad.exe as an example.
Lets say that my bat looks like:
Код
start game.exe;name=user;ip=36.29.147.162;port=4747

I cannot start the .exe file without these settings, so I can't just use execandwait("game.exe") if you understand.
I need somehow to run that .bat file and wait for the program to load.
Вверх
Fors1k
UOpilot is able to start the apps with params - Exec


If u want to launch ur app by .bat in any ways, here is a solution:
test.bat:
Код
start game.exe;name=user;ip=36.29.147.162;port=4747
del D:\app.txt

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!")

Вверх
cirus
Код
--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)

Вверх
Fors1k
Цитата(cirus @ 3.4.2020, 21:24)

Код
handle = findwindow("window name")


If an app with the same window text is already running, this will not be a solution.
Вверх
neves
Цитата(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")

Вверх
Invision Power Board © 2001-2024 Invision Power Services, Inc.
Version for Pocket PC © 2006-2024, IPBest Studio.