Jump to content

32-bit ProcessClose in 64-bit world


Recommended Posts

I have a 32 bit application running on a Windows 2008 Server 64-bit OS. The application is launched by an automated process and thus not windowed. While I am able to list the process and get the PID, the processclose function does not kill the process. Any ideas?

Thank you.

Link to comment
Share on other sites

I've tried this actually, and I could never find anything to work either, here's a batch example of one of the ones I tried it with.

@ECHO OFF
TASKKILL /IM Vindictus.exe /F /T 
del C:\Nexon\Vindictus\en-us\HShield\hshield.log
del C:\Nexon\Vindictus\en-us\HShield\supdate.log
del C:\Nexon\Vindictus\en-us\HShield\HSUpChk.log
del C:\Nexon\Vindictus\en-us\HShield\Update\supdate.log
cd %UserProfile%
rmdir /s /q "Documents\Vindictus\Report Error"
ECHO Done.

no matter what happens, vindictus would never close. I've made other applications do it, but all those were x64

Link to comment
Share on other sites

Thanks to all who replied. It's given me a few other ideas to try, most notably the taskkill.exe tool I did not know about before. Just in case that approach does not work, here are some more details.

1. I am logged in as a member of the local administrators group on the server and have sufficient rights to stop processes as I am able to manually kill the process using task manager.

2. The application, when launched in a non-automated fashion, is a windows app and has window titles that can be determined with the wingettitle command. The application and it's related processes can also be killed using the winkill or the processclose command in this setting. The processclose command fails to kill the process if the application was launched based on a task scheduler event and is a visible window.

3. I have compiled the autoit script for x64 and am using the very latest non-beta versions of autoit.

Link to comment
Share on other sites

The processclose command fails to kill the process if the application was launched based on a task scheduler event and is a visible window.

When you launch an application with a task scheduler event, it is run with the "System"-Account. No other user has the right to kill it. You will have to create another task to kill it or run an AutoIt-script as the task which launches the app and later kills it.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

It took a few tries with the command line syntax, but the taskkill.exe route did the trick where processclose was failing. The final piece of the puzzle was the use of the /f and /t flags on the command lines and ensuring the password was enclosed in quotes as it contained some special characters that the command interpreted as invalid parameters. Below is the code I used with the sensitive items renamed (user anmes password, etc). As noted in previous replies, this process did require the use of administrator level credentials.

Hope this helps anyone else who encounters a similar issue.

#include <Process.au3>

dim $USR, $DOM, $ SVR, $ PW, $PROC_NAM, $PID, $PROC_LIST, $TK_CMD

$USR="Sysman"

$DOM="Domain"

$PW="Password"

$SVR="ServerName"

$PROC_NAM="Application.exe"

$PROC_LIST=processlist($PROC_NAM)

for $i = 1 to $proc_list[0][0]

$PID=$PROC_LIST[$i][1]

PROCESSCLOSE($PID)

sleep(750)

next

if processexists($PID) Then

msgbox (0,"ProcessClose Failure", "ProcessClose did not kill " & $PROC_NAM & " process. Trying external taskkill.exe command.", 5)

$TK_CMD="TaskKill.exe /PID " & $PID & " /S " & $SVR & " /U " & $DOM & "\" & $USR & " /P " & chr(34) & $PW & chr(34) & " /F /T"

for $T=1 to 5

runaswait($USR, $DOM, $PW, 1, $TK_CMD,"c:\",@sw_show)

sleep(750)

if not processexists($PID) then

msgbox (0,"TASKKILL Success","Eureka!!! TaskKill.exe killed the " & $PROC_NAM & " process.",5)

exitloop

elseif $T=5 Then

msgbox(0,"TaskKill Failure","TaskKill also failed to kill the " & $PROC_NAM & " process.", 5)

exitloop

EndIf

next

Else

msgbox(0,"ProcessClose Success","ProcessClose command from AutoIT successfully killed the " & $PROC_NAM & " process.",5)

endif

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...