Search found 117 matches

by tinfanide
03 Apr 2012 08:41
Forum: DOS Batch Forum
Topic: DEL / RD: The system cannot find the file specified
Replies: 7
Views: 9854

Re: DEL / RD: The system cannot find the file specified

foxidrive wrote:Or this: (untested)

Code: Select all

@ECHO OFF

pushd "C:\test\New folder\" && (
RD /S /Q "C:\test\New folder\" 2>nul
)
popd

PAUSE


I've got most of it.
But one thing not sure...
2>nul (no redirection?) the nul device?
Why is it needed after RD?
by tinfanide
03 Apr 2012 07:17
Forum: DOS Batch Forum
Topic: DEL / RD: The system cannot find the file specified
Replies: 7
Views: 9854

DEL / RD: The system cannot find the file specified

C:\>DIR /B /S "C:\test\New folder" C:\test\New folder\folder1 C:\test\New folder\folder1\good C:\test\New folder\folder1\txt.txt C:\test\New folder\folder1\good\txt.txt C:\>test\test.bat Deleted file - C:\test\New folder\folder1\txt.txt Deleted file - C:\test\New folder\folder1\good\txt.t...
by tinfanide
29 Mar 2012 00:22
Forum: DOS Batch Forum
Topic: Exit /B %ERRORLEVEL% ???
Replies: 17
Views: 39450

Re: Exit /B %ERRORLEVEL% ???

Yes, :D , that's why I was saying in previous posts that I might be figuring it out once I'd use it when I code on my own. Anyway, thanks.
by tinfanide
28 Mar 2012 21:44
Forum: DOS Batch Forum
Topic: Exit /B %ERRORLEVEL% ???
Replies: 17
Views: 39450

Re: Exit /B %ERRORLEVEL% ???

Oh... yes, I see. It makes sense to me now. Thanks for all that a lot.
by tinfanide
28 Mar 2012 19:35
Forum: DOS Batch Forum
Topic: Exit /B %ERRORLEVEL% ???
Replies: 17
Views: 39450

Re: Exit /B %ERRORLEVEL% ???

Here is a run-time test on my machine: Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Windows\system32>CD C:\folder one C:\folder one>DIR /B ERRORLEVEL.bat my program.exe myfile.ini C:\folder one>ERRORLEVEL.bat Invalid parameter to SETLOCAL com...
by tinfanide
28 Mar 2012 09:57
Forum: DOS Batch Forum
Topic: Exit /B %ERRORLEVEL% ???
Replies: 17
Views: 39450

Re: Exit /B %ERRORLEVEL% ???

Half clear. Maybe next time when I come across a practical use of it, I may understand it better than just read people's explanation. Anyway, thanks for the explanation given.
by tinfanide
28 Mar 2012 07:22
Forum: DOS Batch Forum
Topic: Exit /B %ERRORLEVEL% ???
Replies: 17
Views: 39450

Re: Exit /B %ERRORLEVEL% ???

Well, how about this?

Code: Select all

:: A batch file

ECHO it's a batch file

EXIT /B 1


Is it what you said I set an errorlevel for this batch program?
by tinfanide
28 Mar 2012 06:31
Forum: DOS Batch Forum
Topic: Exit /B %ERRORLEVEL% ???
Replies: 17
Views: 39450

Re: Exit /B %ERRORLEVEL% ???

Yes, I started another cmd.exe and it worked.
But what's the use of specifying a number for the command EXIT?

exitcode Sets the %ERRORLEVEL% to a numeric number.
If quitting CMD.EXE, set the process exit code no.


Could ya explain a bit for the use of this?
by tinfanide
28 Mar 2012 06:08
Forum: DOS Batch Forum
Topic: Exit /B %ERRORLEVEL% ???
Replies: 17
Views: 39450

Re: Exit /B %ERRORLEVEL% ???

Well, what I don't understand is
In your example,
Are we using the default setting of ERRORLEVEL of the command EXIT?
Or
setting the ERRORLEVEL for EXIT?

And I tried your example in CMD
When I typed

Code: Select all

EXIT /B 1

It exits.

And in your example,
Are you setting the ERRORLEVEL (1,2) for EXIT?
by tinfanide
28 Mar 2012 04:54
Forum: DOS Batch Forum
Topic: Exit /B %ERRORLEVEL% ???
Replies: 17
Views: 39450

Re: Exit /B %ERRORLEVEL% ???

But does the command

Code: Select all

EXIT /B 1

set the errorlevel or it uses the errorlevel?
by tinfanide
26 Mar 2012 21:09
Forum: DOS Batch Forum
Topic: Exit /B %ERRORLEVEL% ???
Replies: 17
Views: 39450

Exit /B %ERRORLEVEL% ???

Could I ask a bit about the use of ERRORLEVEL in DOS?
In the EXIT case,

Code: Select all

EXIT /B 1

Safely setting the ERRORLEVEL to 1. What does it mean?
by tinfanide
02 Mar 2012 10:35
Forum: DOS Batch Forum
Topic: How to return a string position?
Replies: 4
Views: 4289

Re: How to return a string position?

foxidrive wrote:Try this:

Code: Select all

@echo off
for /f "tokens=2 delims==" %%a in ('type "test.txt" ^|find "ProductKey="') do set PK=%%a
echo %PK%


Yes, this works. Thanks.
by tinfanide
02 Mar 2012 10:34
Forum: DOS Batch Forum
Topic: How can DOS substitute equal signs?
Replies: 1
Views: 2671

How can DOS substitute equal signs?

For /F "tokens=*" %%B IN (test.txt) DO ( SETLOCAL ENABLEDELAYEDEXPANSION SET t=is SET old=%%B SET new=!old:t=! ECHO !new! ENDLOCAL ) Two questions. First, can I store the target text ("is") in the variable t and put t within the !!variable? It seems not working. Second, how can ...
by tinfanide
29 Feb 2012 04:11
Forum: DOS Batch Forum
Topic: How to return a string position?
Replies: 4
Views: 4289

Re: How to return a string position?

@ECHO OFF FOR /F "tokens=*" %%C IN (test.txt) DO ( SETLOCAL ENABLEDELAYEDEXPANSION SET "old=%%C" :: ProductKey= (the equal sign "=" is not escaped) SET new=!old:ProductKey==! IF DEFINED new ( :: ECHO) = ECHO. ECHO.!new! ) ENDLOCAL ) PAUSE Originally I wanted to extract...
by tinfanide
28 Feb 2012 23:09
Forum: DOS Batch Forum
Topic: How to return a string position?
Replies: 4
Views: 4289

How to return a string position?

test.txt [UserData] FullName = "Your User Name" OrgName = "Your Organization Name" ComputerName = * ProductKey= "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" How could I return a specific string position in a text file? I know there's string manipulation commands (e.g. Left, Mid...) ...