I'm doing scripting using appcmd
. What I'd like to do is check to see if a given site exists and if does perform an action. In this case, delete it.
appcmd list app | find "mySite"
So, if the find "mySite" returns any text, I'd like to execute a delete statement. Now, I understand I could attempt to delete the site and ignore the error but that gives a (potentially) confusing output.
I've tried something like the following, where I assume I'd just use the variable appExists
in an if statement, but it just ends up blank. Alayways.
set appExists=appcmd list app | find "mySite"
echo %~n0: %appExists%
How can I achieve this?
You could do:
But then you could skip setting an environment variable and adding an if test, and build the removal into the for loop:
(And check the for options (
for /?
) to use thedelims=
andtokens=
to get whichever part of the line you need directly).