Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
Docfxit
- Posts: 132
- Joined: 12 Nov 2015 12:42
#16
Post
by Docfxit » 13 Oct 2023 09:48
If I understand correctly, Is this correct?
Code: Select all
if %_OS%==64 (
Set FileName=SecureVNCPlugin64.dsm
if not exist "%FileName%" (
set "file=!file!!lf! ? %FileName%"
robocopy "%IPADDRESS%\Dnload\VNC" "!wkdir!" "%FileName%"
set errlev=!errorlevel!&REM
IF !errlev! LSS 8 GOTO FileCopied)
)
Set FileName=VNCultravnc.ini
if not exist "%FileName%" (
set "file=!file!!lf! ? %FileName%"
robocopy "%IPADDRESS%\Dnload\VNC" "%wkdir%" "%FileName%"
set errlev=%errorlevel%&REM
IF %errlev% LSS 8 GOTO FileCopied)
-
OJBakker
- Expert
- Posts: 90
- Joined: 12 Aug 2011 13:57
#17
Post
by OJBakker » 13 Oct 2023 09:56
You are halfway correct.
You have corrected the first "if not exist" but not the second one. There the errorlevel and errlev variables have to be corrected as well.
-
Aacini
- Expert
- Posts: 1914
- Joined: 06 Dec 2011 22:15
- Location: México City, México
-
Contact:
#18
Post
by Aacini » 13 Oct 2023 17:56
miskox wrote: ↑13 Oct 2023 07:16
One thing to add:
Code: Select all
robocopy "%IPADDRESS%\Dnload\VNC" "%wkdir%" "%FileName%"
Echo %ERRORLEVEL%
IF NOT ERRORLEVEL 1 GOTO FileCopied
ERRORLEVEL that is compared in this case is the one from the ECHO command and it would probably always return success. You would have to use something like this:
Code: Select all
set errlev=%errorlevel%&REM or !errorlevel! - depends where/how you use it
and then check the %errlev% variable.
Saso
miskox,
The
ECHO command does NOT
"probably always return success". This command appears below the
Table 1 - Commands that not change the prior ERRORLEVEL value at the
What are the ERRORLEVEL values set by internal cmd.exe commands? S.O. topic...
Antonio
PS -
VERIFY is the "standard" command suggested by MS to set the errorlevel to zero (success). There is not any other command that always return success by default...
-
miskox
- Posts: 630
- Joined: 28 Jun 2010 03:46
#19
Post
by miskox » 15 Oct 2023 09:28
@aacini: thanks! This is what I get for not following SO. In any case: my contribution was intended to draw attention to the possibility of such an error.
SO link is very useful! Thanks!
Saso