Reputation: 23
So the issue I'm facing is that after grabbing admin privledges with a UAC prompt, or even just having the batch file 'run as admin', the following commands will work fine in a 'run as admin' command prompt, but not in the batch file. Said commands are as follows.
WMIC PROCESS WHERE name="Agent.exe" CALL Terminate
WMIC PROCESS WHERE "name like '%Battle.net%'" CALL Terminate
After those two commands, which work in a command prompt, but not in a batch file, I also delete two directories, which fails as the application in question is still running. I just am at a loss for why WMIC works in a command prompt with the exact same context, and not in a batch file. I can share the entire batch file if it's really necessary, but those are the only commands not working as intended, and I'm entirely at a loss now.
Upvotes: 2
Views: 2237
Reputation: 38589
The %
characters act as wildcards for WMIC
's Like
comparator, however in Windows batch files it is necessary to double those characters:
WMIC Process Where "Name Like '%%Battle.net%%'" Call Terminate
Your wildcards as written above though are actually searching for any Process
whose Name
begins with any number of characters followed by the string Battle.net
then has any number of characters following it. I'm going to assume, more especially because of the strings leading capital that you don't really need the leading wildcard.
WMIC Process Where "Name Like 'Battle.net%%'" Call Terminate
Upvotes: 3