Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Access is Denied RT error for ShutDownProcess
#1
Hi Gintaras,
I am getting a Access is denied Error for a ShutDownProcess of a specific process. However, I can manually end the process after I give the ok to the "Warning: Terminating a process can cause undesired results....."
In fact even this code works:
Code:
Copy      Help
run "taskmgr.exe"
;----
int w=win("Windows Task Manager" "#32770")
Acc a.Find(w "LISTITEM" "SampleProcess.exe" "class=SysListView32" 0x1015)
a.Select(3)
but child("&End Process" "Button" win("Windows Task Manager" "#32770") 0x1)
wait 2 WV win("Task Manager Warning" "#32770")
but child("&Yes" "Button" win("Task Manager Warning" "#32770") 0x1)

Is there any work around to the Access is Denied Error. Note that there are other processes that I get "Unable To Terminate Process" dialog (i.e. The opation could not be completed. Access is denied" even when I try to do it manually.

So is there a reason why I am still getting the Access is denied on some even though I can get rid of them manually?

Thanks, S
#2
Possible reason: QM or macro runs not as administrator and tries to terminate process of other user.

This is what ShutDownProcess does when it is called without flags. Does it says "Access denied"? WTSTerminateProcess is Windows API function, you may find the reason with google.
Macro Macro1579
Code:
Copy      Help
str process="regedit"
int pid=ProcessNameToId(process); out pid
if(!WTSTerminateProcess(0 pid 0)) out _s.dllerror
#3
Thanks you. Yes still says Access is denied with WTSTerminateProcess.
I am running on XP so no UAC run as admin option on control panel.
Any other suggestions other than manually calling up taskmanager selecting..etc

S
#4
Try flag 16. Then uses other API function.
#5
Macro Macro1554
Code:
Copy      Help
run "taskkill" "/f /im notepad.exe" "" "" 16

http://www.microsoft.com/resources/docu ... x?mfr=true
#6
thanks so much,
The taskkill command didn't work but I may not have all the parameters correct. I just noticed that User Name in Task Manager is SYSTEM and not my own user name. I am sure that is the main problem.
The manual way script works at startup so I may be good with that.
Thanks so much for your help.
S
#7
Normal processes cannot kill SYSTEM processes. And QM cannot start a process as SYSTEM.
#8
Most processes running in SYSTEM account are services. You can stop a service.

Macro Macro1554
Code:
Copy      Help
VARIANT serviceName="quickmacros2"
Services.clsServices ss._create
Services.clsService s=ss.Item(serviceName)
s.StopService ;;will end qmserv.exe process
10
s.StartService

shows service names and exenames
Macro Macro1570
Code:
Copy      Help
out
Services.clsServices ss._create
Services.clsService s
foreach s ss
,out s.Name
,out s.BinaryPathName
#9
amazing. simply amazing. Thanks!!
S


Forum Jump:


Users browsing this thread: 1 Guest(s)