This method closes a running process and returns its exit code.
Returns the process exit code.
To avoid forcefully terminating a running process call the Process:Wait method instead of this method, or wait for Process:GetStatus to return PROCESS_FINISHED before calling this method.
local appname = "Notepad"
local apppath = "C:/Windows/notepad.exe"
--Get the displays
local displays = GetDisplays()
--Create a window
local window = CreateWindow("Ultra Engine", 0, 0, 460, 480, displays[1])
--Create User Interface
local ui = CreateInterface(window)
--Create widget
local sz = ui.background:GetSize()
local button = CreateButton("Launch " .. appname, (sz.x - 120) / 2, (sz.y - 30) / 2, 120, 30, ui.background)
local proc = nil
while true do
local ev = WaitEvent()
if ev.id == EVENT_WIDGETACTION then
if ev.source == button then
if proc then
proc:Close()
proc = nil
button:SetText("Launch " .. appname)
else
button:SetText("Close " .. appname)
proc = CreateProcess(apppath)
end
end
elseif ev.id == EVENT_WINDOWCLOSE then
return
end
end