中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-11 11:21
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS批处理 & 脚本技术(批处理室) » [Help] Please use reg together with ERRORLEVEL
Printable Version  956 / 10
Floor1 XZ Posted 2009-02-05 17:24
初级用户 Posts 65 Credits 144 From Taiwan
Can reg be used together with ERRORLEVEL?
Or is there some other way to achieve what I need

Goal: if the REGISTER value exists then execute, if the value does not exist then exit


Floor2 yishanju Posted 2009-02-05 17:43
银牌会员 Posts 1,357 Credits 1,488
if %%i is empty then exit
wouldn't this work?
Floor3 XZ Posted 2009-02-05 18:07
初级用户 Posts 65 Credits 144 From Taiwan
Originally posted by yishanju at 2009-2-5 05:43 PM:
if %%i is empty then exit
wouldn't this work?

Sir.. I'm not sure whether it works or not ^^"
Because I don't know how to use this command
SORRY~~ = =

Could you give an example, thanks ^^
Floor4 yishanju Posted 2009-02-05 18:14
银牌会员 Posts 1,357 Credits 1,488
It's right there in if /?
Floor5 XZ Posted 2009-02-09 12:02
初级用户 Posts 65 Credits 144 From Taiwan
Originally posted by yishanju at 2009-2-5 06:14 PM:
if /? 就有啊


Sir, I'm still not very familiar with using if together with it.
I did read the help, but I'm not very clear on what ERRORLEVEL values REG returns!! ^^

Floor6 wxcute Posted 2009-02-09 13:33
中级用户 Posts 211 Credits 458
reg query "key item" [/v "value"]
echo %errorlevel%
Floor7 XZ Posted 2009-02-13 14:47
初级用户 Posts 65 Credits 144 From Taiwan
Originally posted by wxcute at 2009-2-9 01:33 PM:
reg query "键项"
echo %errorlevel%


Hello
I tested the method you mentioned.
Whether the value exists or not,
the ERRORLEVEL value I get is always 0.
So it seems this won't work.
Is there any other way?
Thanks





Floor8 XZ Posted 2009-02-16 15:43
初级用户 Posts 65 Credits 144 From Taiwan
It can't be checked inside FOR, maybe I wrote the FOR method wrong ˇˇ
Because it works when it's not under FOR

Content



Result


Can someone help modify this?
Thanks!!
Goal: if the REGISTER value exists then execute, if the value does not exist then exit; if the value exists, that value must be set to a variable for later syntax use
Floor9 zhengqian529 Posted 2009-02-16 15:48
初级用户 Posts 93 Credits 100 From 湖南
The errorlevel value is returned by the system. Why not set an error variable yourself:
1. If it exists, set error=1
2. If it doesn't exist, set error=0
Then immediately follow it with the operation you want to perform. You don't have to get hung up on the system-provided variable %errorlevel%
Floor10 XZ Posted 2009-02-16 17:31
初级用户 Posts 65 Credits 144 From Taiwan
Originally posted by zhengqian529 at 2009-2-16 03:48 PM:
The value of errorlevel is returned by the system. Why not set an error variable yourself:
1. If it exists, set error=1
2. If it doesn't exist, set error=0
Then put the operation you want to execute right after that; you don't necessarily have to get hung up on the system-defined variable %errorlevel%


Mm, thank you!!
Right now I've run into another problem


As long as I add
reg query "HKCU\Software\Microsoft\Office\11.0\Outlook\Security" /v "OutlookSecureTempFolder" >nul
if %errorlevel% EQU 0 (

these two lines, it can no longer detect the path value
The result is as follows

With
reg query "HKCU\Software\Microsoft\Office\11.0\Outlook\Security" /v "OutlookSecureTempFolder" >nul
if %errorlevel% EQU 0 (
result


If I add REM to
reg query "HKCU\Software\Microsoft\Office\11.0\Outlook\Security" /v "OutlookSecureTempFolder" >nul
if %errorlevel% EQU 0 (
result
Floor11 XZ Posted 2009-02-18 16:44
初级用户 Posts 65 Credits 144 From Taiwan
I couldn't find the cause..
So I had no choice but to rewrite it like this below
Temporarily solved

[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023