Killing inactive form session through oracle application server - forms

I am trying use host command in Oracle forms. I get the process id as input from the user and on clicking ok the form should kill the session related to process id.
PS: Users will be entering only frmweb.exe process id which are inactive.
cmd := 'CMD /C taskkill /F /FI /pid 'process which is got as input' /IM frmweb.exe';
host(cmd)
I also tried by writing the above command into a .bat file in application server.When trying to execute the bat file it din work. But when tryin to run the bat file by double clicking in Application server the session was killed.
On executing the above I am unable to kill the process.
I would also like to know whether the host command was successful or not.
Could you please help me and guide me in proceeding. Orakill and alter session are working but I don want to use it.

I tried with writing the command execution to a text for debugging and was able to find the solution.
cmd := 'CMD /C taskkill /F /FI /pid 'process which is got as input' /IM frmweb.exe>>output.txt';
There was some special character written in at the end of the command due to which the command was failing when calling from Oracle Forms.Special character was due to a typo in the code the Oracle Forms.

Related

How do I check for a running process before executing another?

I've found some references to searching for active .exe in the task list but I haven't been able to get any to work.
I'm trying to find a working bat script because I have memory problems and I've been banned twice now for simply forgetting to shut it down.
I have tried the other suggestions on here but they are from 2012 and didn't seem to be working.
I am running Win 10 Home. Any help would be appreciated.
I am not a proficient coder. I can read it and determine what it's supposed to do, but I don't know how to fix it if it doesn't.
For the non-coders looking at this from a google search, this is attempting to create a batch file that simply checks if Cheat engine is running. If it is it pauses and tells me and stops the launcher from loading until Cheat engine isn't in the process tree.
The first bit I found on Reddit by someone who searched through your site to come up with this. It is about 2 years old but doesn't appear to work anymore, as far as I can tell.
tasklist /FI "IMAGENAME eq Cheat engine.exe" 2>NUL | find /N "Cheat engine.exe">NUL
if "%ERRORLEVEL%"=="0" start "" cmd /c "echo [Cheat engine running.]&echo(&pause"
if "%ERRORLEVEL%"=="1" start "" F:\SteamLibrary\steamapps\common\Warframe\Tools\Launcher.exe
That's what I've found. But it never returns an error, even when I run it while intentionally running CE. I never go past the launcher so it shouldn't flag in their system, therefore I should be able to test this as much as necessary.
and
just to see if I could run a kill process for it. This didn't do anything.
echo off
tasklist /fi "imagename eq cheat engine.exe" |find ":" > nul
if errorlevel 1 taskkill /f /im "cheat engine.exe"
exit

taskkill command to delete a program

A scheduled task runs every night to trigger a batch file. This batch file executes the application “AProgram.exe” with a configuration file to import data into a system. Occasionally this program fails to exit properly, leaving a “headless” process behind. When the scheduled task runs again the following night, the error below is produced:
[ERROR] PROCESS ALREADY RUNNING
We believe adding the command “taskkill” into this batch file should prevent this error from occurring again. Add the “taskkill” command with any required parameters into the batch file below to force “AProgram.exe” to end before it runs again, along with any other commands you deem necessary.
from dos prompt type : Taskkill /? this will explain all possible scenarios.
i think that the correct solution for your problem is to add in batch script :
TASKKILL /F /IM AProgram.exe /T
/F : For FORCE the end of task
/T : terminate all child process

Deny windows pop-up error messages with batch or powershell

I am working on a way to start a program via a network drive.(Example follows). Is there a way to suppress these error messages from Windows via Batch or Powershell while the script is running? Or maybe a way to dynamically search for the Network drive without trying all possible ways.
Code Exapmple:
#echo off
start A:"Path to .exe" 2>nul
B...
C...
// For every possible drive letter
you can easily get all successfully connected network drives with the net use command. Put a for /f loop around to get the drive letters only:
for /f "tokens=2" %%a in ('net use^|findstr /b "OK"') do (
start "" "%%a\path to .exe\app.exe"
)

keep command line window open when running scheduled task executing batch file

I would like to have the console window kept open when running a scheduled task which executes a batch file. If I run it manually meaning execute the batch file the window stays open but through task scheduler it doesn't open but I can see the task is still running. I put a pause at the end to do this.
#echo off
TITLE PROCESS_MGR
tasklist /FI "IMAGENAME eq JOESMO.exe" | find /I "JOESMO.exe">nul &&(echo PROCESS
JOESMO.exe IS ALREADY RUNNING!
echo %DATE%
echo %TIME%
pause
) || (
echo JOESMO PROCESS IS NOT RUNNING
cmd /c start "JOESMO.exe" "C:\Users\xxxx\Documents\
Visual Studio 2010\Projects\Projects2013\JOESMO.exe"
pause)
I found this suggestion cmd /k myscript.bat but having creating the task in task scheduler for windows server 2008 I am not sure where to apply this. I added /k to the add arguments box in edit action in task.
In the Scheduled Task dialog, just before the name of the batch file it's going to run (it's labeled Program/script. You now have something like:
myscript.bat
Change it to
cmd
Add the following to the **Add Arguments (optional) entry:
/k "C:\My Batch File Folder\MyScript.bat"
Tested on my system (Win7 64-bit), and it worked perfectly. I'm looking at the open command window it created as I type this text. :-)
Unfortunately Ken's solution didn't work for me on a Windows 2008 R2 Std server, I was able to launch an interactive window by modifying the scheduled tasks setting using schtasks.exe
In a command window I did the following command:
schtasks /Change /TN "My Task" /IT
However that does require you be logged in as the same user context in which the scheduled task is executing. So if your scheduled task is use the localsystem "taskaccount" then you will have to log into the system as the "taskaccount" user.
Oddly enough it worked when I manually run the task but it didn't pop for me when it kicked off at a scheduled time.
Ken's answer didn't worked for me.
Found this way of doing :
in your BAT file (create one if you only have an EXE) :
start C:/Absolute/Path/To/MyScript.exe myScriptArg
works like a charm !
Note: In the scheduled task, you must check "Exec only if user is logged"
Create a shortcut to the Batchfile and put that in the action. Worked for me
I tried all of the above, but they did not work for me. Here is what I did to get this to work:
Platform
Windows Server 2003 R2 SP2
ActivePERL v5.10.1
Steps
Create DOS BATCH script -- this runs the actual program, ie, myscript.bat
Create PERL script to call the DOS batch script, ie, myscript.pl
myscript.pl is a 1-line script: system("e:\scripts\myscript.bat");
Create scheduled task: perl myscript.pl
The DOS command prompt window now always opens up. And more importantly, the task now successfully runs and completes. NOTE: The scheduled task RunAs user is logged in to the server.

taskkill has no effect when issued under scheduled task while user is logged off

I have a batch file containing the command taskkill /f /im program.exe that kills all currently running instances of program.exe.
However, I want to kill program.exe by means of a scheduled task while the user initiating the scheduled task is logged off.
In this case, the batch file runs at the scheduled time but taskkill /f /im program.exe apparently has no effect. Other commands like running a program are not affected, however.
In short: How can I schedule to kill a program when the initiating user is deactivated by 'Switch user' or 'Lock' (i.e. logged off)?
Try to change the file extension of your batch file to '.cmd' instead of '.bat' and make sure your file is ANSI encoded instead of UTF-8 (the UTF-8 Byte Order Mark i.e. BOM could make your batch file invalid and throws an unrecognized character at position or line x error). I use Notepad++ for this kind of encoding checks / conversions.