标题: [注册表类] 批处理检测文件是否存在 并运行命令(望高手解答)[已解决] [打印本页]
作者: 5209520 时间: 2019-11-28 18:35 标题: 批处理检测文件是否存在 并运行命令(望高手解答)[已解决]
本帖最后由 5209520 于 2022-12-14 10:49 编辑
- @echo off
- if exist C:\1.txt (
- taskkill /f /im iexplo*
- ECHO ---正在解除权限.........
- set route=HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation\ClearableListData
- :fix
- del %tmp%\ko.txt/q
- echo "%route%"[7]>>%tmp%\ko.txt
- regini %tmp%\ko.txt
- ping 127.1 -n 3
- set route=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2
- :fix
- del %tmp%\ko.txt/q
- echo "%route%"[7]>>%tmp%\ko.txt
- regini %tmp%\ko.txt
- ping 127.1 -n 3
- ECHO ---删除信任
- Reg.exe delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges" /f
- ping 127.1 -n 2
- ECHO 开始配置智联T9运行环境……
- REM ECHO 该设置不会对您的电脑使用带来影响
- REM ---增加信任站点
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range302" /f > nul
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range302" /v ":Range" /t REG_SZ /d "*.9csoft.com" /f > nul
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range302" /v "http" /t REG_DWORD /d 2 /f > nul
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range303" /f > nul
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range303" /v ":Range" /t REG_SZ /d "*.zlt9.com" /f > nul
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range303" /v "http" /t REG_DWORD /d 2 /f > nul
-
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range304" /f > nul
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range304" /v ":Range" /t REG_SZ /d "*.zlt9.cn" /f > nul
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range304" /v "http" /t REG_DWORD /d 2 /f > nul
-
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range301" /f > nul
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range301" /v ":Range" /t REG_SZ /d "61.128.196.*" /f > nul
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range301" /v "http" /t REG_DWORD /d 2 /f > nul
-
- REM ---设置IE信任区域
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "DisplayName" /t REG_SZ /d "可信站点" /f > nul
- ECHO ---正在设置权限.........
- set route=HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation\ClearableListData
- :fix
- del %tmp%\ko.txt/q
- echo "%route%"[8]>>%tmp%\ko.txt
- regini %tmp%\ko.txt
- ping 127.1 -n 3
- set route=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2
- :fix
- del %tmp%\ko.txt/q
- echo "%route%"[8]>>%tmp%\ko.txt
- regini %tmp%\ko.txt
- ) else (echo >nul 2>nul)
- ping 127.1 -n 2
- set dir=C:\WINDOWS\Temp
- rd /s /q "%dir%"
- exit
- ) else (
- goto :i
- )
- goto :eof
-
- :i
- echo 不存在文件
复制代码
上面是在论坛搜索 自己的做的 主要目的是实现 平 判断文件是否存在并运行命令 实现注册表设置访问权限 在设置注册表相干设置 如果不存在文件 就自动退出 现在能做出判断 并且运行命令 可是开头 if exist C:\1.txt 这个命令运行后 批处理设置注册表不能实现 如果去掉if exist C:\1.txt 这个命令后 就能设置注册表权限 麻烦论坛里高手帮忙看看 谢谢
作者: terse 时间: 2019-11-28 21:46
目测 少个IF 重复那么多标签干嘛呢
作者: Batcher 时间: 2019-11-28 22:12
回复 1# 5209520
这个代码里有3个左括号、4个右括号。你检查一下看看是哪里多了一个右括号
作者: 5209520 时间: 2019-11-29 11:11
本帖最后由 5209520 于 2019-11-29 12:01 编辑
@echo off
if exist C:\1.txt (
taskkill /f /im iexplo*
ECHO ---正在解除权限.........
set route=HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation\ClearableListData
:fix
del %tmp%\ko.txt/q
echo "%route%"[7]>>%tmp%\ko.txt
regini %tmp%\ko.txt
ping 127.1 -n 3
set route=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2
:fix
del %tmp%\ko.txt/q
echo "%route%"[7]>>%tmp%\ko.txt
regini %tmp%\ko.txt
ping 127.1 -n 3
ECHO ---删除信任
Reg.exe delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges" /f
ping 127.1 -n 2
ECHO 开始配置智联T9运行环境……
REM ECHO 该设置不会对您的电脑使用带来影响
REM ---增加信任站点
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range302" /f > nul
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range302" /v ":Range" /t REG_SZ /d "*.9csoft.com" /f > nul
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range302" /v "http" /t REG_DWORD /d 2 /f > nul
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range303" /f > nul
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range303" /v ":Range" /t REG_SZ /d "*.zlt9.com" /f > nul
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range303" /v "http" /t REG_DWORD /d 2 /f > nul
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range304" /f > nul
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range304" /v ":Range" /t REG_SZ /d "*.zlt9.cn" /f > nul
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range304" /v "http" /t REG_DWORD /d 2 /f > nul
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range301" /f > nul
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range301" /v ":Range" /t REG_SZ /d "61.128.196.*" /f > nul
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range301" /v "http" /t REG_DWORD /d 2 /f > nul
REM ---设置IE信任区域
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "DisplayName" /t REG_SZ /d "可信站点" /f > nul
ECHO ---正在设置权限.........
set route=HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation\ClearableListData
:fix
del %tmp%\ko.txt/q
echo "%route%"[8]>>%tmp%\ko.txt
regini %tmp%\ko.txt
ping 127.1 -n 3
set route=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2
:fix
del %tmp%\ko.txt/q
echo "%route%"[8]>>%tmp%\ko.txt
regini %tmp%\ko.txt
) else (echo >nul 2>nul)
ping 127.1 -n 2
set dir=C:\WINDOWS\Temp
rd /s /q "%dir%"
exit
我重新编辑了 没有要最好那部分 但是 批处理设置权限 这个段代码 使用不能生效 (set route=HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation\ClearableListData
:fix
del %tmp%\ko.txt/q
echo "%route%"[7]>>%tmp%\ko.txt
regini %tmp%\ko.txt ) 但是去掉 if exist C:\1.txt ( 这个段代码 就能生效 是什么原因?、
作者: terse 时间: 2019-11-29 12:48
本帖最后由 terse 于 2019-11-29 14:31 编辑
去掉一楼的52行试一下呢
另外 括号里变量 %route% 加个延迟用!route!
作者: 5209520 时间: 2019-11-29 14:45
本帖最后由 5209520 于 2019-11-29 14:59 编辑
%route% 改老也不 提示设置失败 能否帮忙编辑一下 谢谢
作者: flashercs 时间: 2019-11-29 15:54
- @echo off
- if exist C:\1.txt (
- goto label1
- ) else goto end
-
- :label1
- taskkill /f /im iexplo*
- ECHO ---正在解除权限.........
- set route=HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation\ClearableListData
- :fix
- del %tmp%\ko.txt/q
- echo "%route%"[7]>>%tmp%\ko.txt
- regini %tmp%\ko.txt
- ping 127.1 -n 3
- set route=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2
- :fix
- del %tmp%\ko.txt/q
- echo "%route%"[7]>>%tmp%\ko.txt
- regini %tmp%\ko.txt
- ping 127.1 -n 3
- ECHO ---删除信任
- Reg.exe delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges" /f
- ping 127.1 -n 2
- ECHO 开始配置智联T9运行环境……
- REM ECHO 该设置不会对您的电脑使用带来影响
- REM ---增加信任站点
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range302" /f > nul
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range302" /v ":Range" /t REG_SZ /d "*.9csoft.com" /f > nul
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range302" /v "http" /t REG_DWORD /d 2 /f > nul
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range303" /f > nul
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range303" /v ":Range" /t REG_SZ /d "*.zlt9.com" /f > nul
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range303" /v "http" /t REG_DWORD /d 2 /f > nul
-
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range304" /f > nul
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range304" /v ":Range" /t REG_SZ /d "*.zlt9.cn" /f > nul
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range304" /v "http" /t REG_DWORD /d 2 /f > nul
-
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range301" /f > nul
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range301" /v ":Range" /t REG_SZ /d "61.128.196.*" /f > nul
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range301" /v "http" /t REG_DWORD /d 2 /f > nul
-
- REM ---设置IE信任区域
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "DisplayName" /t REG_SZ /d "可信站点" /f > nul
- ECHO ---正在设置权限.........
- set route=HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation\ClearableListData
- :fix
- del %tmp%\ko.txt/q
- echo "%route%"[8]>>%tmp%\ko.txt
- regini %tmp%\ko.txt
- ping 127.1 -n 3
- set route=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2
- :fix
- del %tmp%\ko.txt/q
- echo "%route%"[8]>>%tmp%\ko.txt
- regini %tmp%\ko.txt
- exit /b
-
- :end
- echo 不存在文件
复制代码
作者: 5209520 时间: 2019-11-30 07:48
回复 7# flashercs
谢谢解答 666 谢谢
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |