Taskill via Batch Issue

Page 1 of 2 12 LastLast

  1. Posts : 532
    Windows 10 (22H2)
       #1

    Taskill via Batch Issue


    Until recently a batch file containing taskkill commands worked w/o issue. Now one of the commands fails (ERROR ... access denied) and the only thing different now from then is the recent windows update. I do know it does work if I open a command window and type the taskklill command there. Thoughts?
      My Computer


  2. Posts : 4,163
    Windows 11 Pro, 22H2
       #2

    Just to double-check: When you run the batch file, are you right-clicking on that batch file and then choosing the option to run it as Administrator?
      My Computers


  3. Posts : 4,163
    Windows 11 Pro, 22H2
       #3

    Follow-up: If you find that it does work when run as Administrator, you could consider adding this one line of code to the start of your batch file:

    Code:
    (Fsutil Dirty Query %SystemDrive%>Nul)||(PowerShell start """%~f0""" -verb RunAs & Exit /B)
    That will check to see if the batch file was run as Administrator. If not, it will automatically re-run the batch file as Administrator and terminate the original instance of the batch file. This way, you do not need to remember to run the batch file as Administrator. In effect, this turns your batch file into a "self-elevating batch file".
      My Computers


  4. Posts : 532
    Windows 10 (22H2)
    Thread Starter
       #4

    thank you hsehestedt -

    I run the batch file via a shortcut. As mentioned it used to work (w/o UAC).

    I followed your advise (run as admin) and it runs as coded (THANK YOU!), however it throws the UAC. I added your code to the batch and it too runs correct, but with the UAC as well, i.e. both batch direct and via shortcut.

    Am I stuck with the UAC now? If so, I can live with it, more important to me that it works now.
      My Computer


  5. Posts : 4,163
    Windows 11 Pro, 22H2
       #5

    Unfortunately, yes, there are simply some commands that will need to be run elevated. You could disable UAC, but my personal preference is to just live with it.
      My Computers


  6. Posts : 532
    Windows 10 (22H2)
    Thread Starter
       #6

    ^
    Thx - Is it possible via some kind of code in the batch file to disable UAC, run the script and then enable UAC when complete? Please forgive me if this question reveals techno-illiteracy on my part.
      My Computer


  7. Posts : 4,163
    Windows 11 Pro, 22H2
       #7

    No worries . It's a good logical question. Unfortunately, not that I am aware of. That would defeat the purpose of UAC if a program could simply bypass UAC on its own. The act of turning off UAC would likely first trigger a UAC warning itself .
      My Computers


  8. Posts : 532
    Windows 10 (22H2)
    Thread Starter
       #8

    hsehestedt - thanks for the 'gentle' reply and more thanks for getting me off to the races, as it were. cheers!
      My Computer


  9. Posts : 4,163
    Windows 11 Pro, 22H2
       #9

    MourningStar said:
    hsehestedt - thanks for the 'gentle' reply and more thanks for getting me off to the races, as it were. cheers!
    Just glad to be able to be of assistance! Have a good evening.
      My Computers


  10. Posts : 532
    Windows 10 (22H2)
    Thread Starter
       #10

    I have asked this question in another somewhat related thread and will do so here, so please don't beat me up folks.

    The task in question first came on my system when I decided to use a vpn (meaning the vpn installed the components). Is it possible to prevent this service from starting at boot? In addition to the taskkill 'no longer working' w/o admin credentials, this task is now starting at boot. I know the vpn uses this service but the app will start it when the app is invoked, thus my assumption and surprise that closing the app did not end the task. I still suspect the latest windows update did something based on the timing of this behavior. However, it is something that I can live with nonetheless. Just curious.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 07:53.
Find Us




Windows 10 Forums