1

I need to automate a process where i want to close a program.

When running,

taskkill /IM notepad.exe

from CMD it works fine.

But when i create a batch file in order to do the same thing, it fails. The bat file runs but the program is not closed.

How to fix this issue?

1
  • 1
    Were you running the command in an Administrative command prompt but you're just double clicking on the batch file so it's not running as admin? If you run the batch file from an administrative command prompt or right click on the batch file and choose "Run as administrator" does it work then. If the notepad was elevated a non elevated batch file would be getting access denied I suspect. You may also want to add the /f switch to force close. E.g. taskkill /F /IM notepad.exe Commented Oct 17, 2017 at 6:48

1 Answer 1

0

Try the following:

taskkill /f /im notepad.exe

Source: StackOverflow.

Flags used include -
/im imagename
/f forcefully terminate

For more flags, open dialogue Win + R, paste & run "cmd.exe", then in cmd - paste "Taskkill /?" (without the quotation marks) and press enter to see all flags, filters and additional examples.

0

You must log in to answer this question.