|
Post by angelo2449 on Oct 16, 2022 13:34:57 GMT -5
Hi guys,
I would like to terminate Liberty.exe with a .bat file:
taskkill /f /im liberty.exe
How can I launch it from Liberty as > Administrator <?
Thank you guys
|
|
|
Post by xxgeek on Oct 16, 2022 17:56:40 GMT -5
Short answer - create a new file in notepad, copy that line - taskkill /f /im liberty.exe - to the file, save it as a .bat file, (not a .txt file) eg: saved as test.bat in the root of c: drive The line in Liberty would be run "c:\test.bat" You could also run taskill straight from a Liberty program. run "taskkill /f /im liberty.exe" See learn.microsoft.com/en-us/windows-server/administration/windows-commands/taskkill for more info on the taskill command. It is possible to choose which Liberty.exe you have running when there is more than one, and you can also find the non responding Liberty.exe and kill ONLY that one. Note, that if this command is used as written above it will kill ALL Liberty.exe running processes. No mercy! So if you have multiple Liberty windows open, save your work prior to running taskill. Since my Windows rig is about a hundred miles from here I can't test anything, except in a WINE environment on Linux. If I remember correctly Windows security won't interfere with running a bat file, or taskill.exe, from Liberty code. Not positive on that, but you'll find out soon enough when testing.
|
|
|
Post by Chris Iverson on Oct 16, 2022 23:48:59 GMT -5
Depends on if the LB code that you want to run the batch file from is already running as Administrator. If you're already running as Administrator, you should be able to just run the batch file using the RUN command, and it'll run with Admin perms. If you're not already running as Admin, then there's no way to run the batch file as Admin without requiring input from the user(via a UAC admin prompt, if UAC is turned on, which it should be.)
However, you can ask the system to prompt the user to allow your script to run as admin, by using the "runas" verb on the ShellExecute API call.
prog$ = "C:\temp\testadmin.bat" showWindow = 1
CallDLL #shell32, "ShellExecuteA",_ 0 as ulong, "runas" as ptr,_ prog$ as ptr, 0 as ulong,_ 0 as ulong, showWindow as long, ret as ulong
print ret
(The showWindow flag sets whether or not the program that runs will be visible on the screen. 1 = Visible, 2 = Invisible.)
If you want to be sure to succeed in all cases, the simplest way is to always execute via the ShellExecute command. If you're not running elevated, Windows will prompt the user to allow the elevated command to run. If you ARE already running elevated, the ShellExecute() call will succeed invisibly. (After all, you're already running elevated, there's no need to ask for elevation.)
|
|