具有以下文件。
我的最终目标是检查目录中的文件是否存在而不执行任何操作
如果文件不存在,则在该PC上卸载teamviewer
以下是脚本
IF EXIST C:\store\TV-DONOTDELETE.TXT
(echo Found the file won't do anything.)
pause
ELSE
(
REM Kill TeamViewer Process
taskkill /f /im teamviewer*
REM Remove Older Versions
for /d %%F in ("C:\Program Files\TeamViewer\*") do "%%F\uninstall.exe" /S
for /d %%F in ("C:\Program Files (x86)\TeamViewer\*") do "%%F\uninstall.exe" /S
REM Remove Newer Versions
"C:\Program Files\TeamViewer\uninstall.exe" /S
"C:\Program Files (x86)\TeamViewer\uninstall.exe" /S
echo removed teamviewer you can thank me later
)
pause
答案 0 :(得分:0)
感谢所有帮助人员,这是大家都推荐的所有研究的最终结果。
@echo off
CD C:\store\
if exist "TV-DONOTDELETE.TXT" (
echo "Found the file won't do anything."
pause
) ELSE (
REM Kill TeamViewer Process
taskkill /f /im teamviewer*
REM Remove Older Versions
for /d %%F in ("C:\Program Files\TeamViewer\*") do "%%F\uninstall.exe" /S
for /d %%F in ("C:\Program Files (x86)\TeamViewer\*") do "%%F\uninstall.exe" /S
REM Remove Newer Versions
"C:\Program Files\TeamViewer\uninstall.exe" /S
"C:\Program Files (x86)\TeamViewer\uninstall.exe" /S
echo "Removed teamviewer"
md c:\store
CD c:\store\
type nul >TV-DONOTDELETE.txt
echo "Created the file, now you can thank me later"
pause
)