Unexpected things happening with batch scripts

Mar 21, 2011
30
0
#1
Unexpected things happening with batch scripts (from a CMD perspective)

I have finally moved to TCC/LE as my default shell. When I run batch scripts I get some different behaviour from CMD. I would like to stop them from happening.

First of all, del stdout is echoed, when it would not be in CMD. Can I stop this from happening? I know that about the /q switch and 2>nul, but I would rather use a global options that makes it act as CMD in this regard, so that I do not need to edit all my scripts just because of this.

On every scripts which I have used SetLocal, I get an error at the EndLocal line saying that there was no SetLocal, when there was. I have tried different capitalisation combinations, but it does not seem to realise that I have SetLocal. What is going on?

When running scripts I get erratic behaviour where the console clears, as though there has been a cls command. There does not seem to be a pattern to this happening. Why does this happen and can it be stopped?

Thanks.
 
#2
When I have had screen clearing problems it has been from running a 16 bit app.

Sent from Cookie's iPhone
Jim Cook

On Apr 28, 2011, at 19:59, jason404 <> wrote:


> When I run batch scripts I get some different behaviour from CMD. I would like to stop them from happening.
>
> First of all, del operations are echoed, when they would not be in CMD. As I have @echo off before the del operations, I would not expect this to happen. Why does this happen and how can I stop it?
>
> On every scripts which I have used SetLocal, I get an error at the EndLocal line saying that there was no SetLocal, when there was. I have tried different capitalisation combinations, but it does not seem to realise that I have SetLocal.
>
> When running scripts I get erratic behaviour where the console clears, as though there has been a cls command. There does not seem to be a pattern to this happening. Can it be stopped?
>
> Thanks.
>
>
>
>
 

rconn

Administrator
Staff member
May 14, 2008
10,588
97
#4
Re: Unexpected things happening with batch scripts (from a CMD perspective)

I have finally moved to TCC/LE as my default shell. When I run batch scripts I get some different behaviour from CMD. I would like to stop them from happening.

First of all, del stdout is echoed, when it would not be in CMD. Can I stop this from happening? I know that about the /q switch and 2>nul, but I would rather use a global options that makes it act as CMD in this regard, so that I do not need to edit all my scripts just because of this.
This is a feature. If you don't want it, alias it out:

alias del=*del /q

On every scripts which I have used SetLocal, I get an error at the EndLocal line saying that there was no SetLocal, when there was. I have tried different capitalisation combinations, but it does not seem to realise that I have SetLocal. What is going on?
Impossible to say without seeing one of your scripts. (Capitalization is irrelevant.)

When running scripts I get erratic behaviour where the console clears, as though there has been a cls command. There does not seem to be a pattern to this happening. Why does this happen and can it be stopped?
The only time I've ever heard of something like this is if you have a CLS in your TCSTART and you're piping to a child process (which will run TCSTART again). TCC/LE will never clear the screen on its own.
 
Mar 21, 2011
30
0
#5
Re: Unexpected things happening with batch scripts (from a CMD perspective)

Thanks for the answers. I'll get back with an example of the SetLocal problem once I come across it again.

But at the moment, I am wondering why this script works in the CMD, but not in TCC/LE:

-------------------------------------------------
@echo off
SetLocal

:WMIC_TEST
WMIC /? >nul 2>&1
if %ERRORLEVEL% EQU 9009 (
goto :HOME
) ELSE (
goto :WMIC_START
)

:WMIC_START
for /f "usebackq tokens=1,* delims==" %%A in (`wmic os get Caption /format:list ^| findstr "^Caption="`) do (
set %%A=%%B
)
echo. & echo.%Caption%
goto :EOF

:HOME
echo This is a Home version of Windows & echo.
goto :EOF

:EOF
EndLocal
-------------------------------------------------


For some reason %Caption% is not being echoed or set.