Page 1 of 1

Commands don't execute from batch file but from CMD

Posted: 01 Jun 2021 04:10
by falcios
I have this batch file that doesn't execute the commands but they work from the command prompt.

It does echo the command on the screen but doesn't run any commands.

Could you tell me what I'm doing wrong and how I can get it to run the commands?

Thanks in advance.

Code: Select all

echo copy "c:\users\sfd\appdata\roaming\microsoft\excel\xlstart" "d:\sfd\dtsc\admt\office\excel\dt xlstart" 
:EXCELTOOLBARS
echo copy "c:\users\sfd\appdata\local\microsoft\office\excel.officeui" "d:\sfd\dtsc\admt\office\excel\toolbars\excel ui\excel ui 2021" |findstr /N /A:4E "^"
:OUTLOOK
echo copy "c:\users\sfd\appdata\local\microsoft\office\olk*.officeui" "d:\sfd\dtsc\admt\office\outlook" |  findstr /N /A:4E "^"
:WORDACL
echo copy "c:\users\sfd\appdata\roaming\microsoft\office\*.acl" "d:\sfd\dtsc\admt\office\word\autocorrect acl\acl bu\acl 2021" | findstr /N /A:4E "^"
:WORDDICTIONARY
echo copy "c:\users\sfd\appdata\roaming\microsoft\uproof\custom*.*" "d:\sfd\dtsc\admt\office\word\dictionaries" | findstr /N /A:4E "^"
:WORDTEMPLATES
:normal normal.dotm, normalemail.dotm
echo copy "c:\users\sfd\appdata\roaming\microsoft\templates\normal.dotm" "d:\sfd\dtsc\admt\office\word\normal bu\normal bu 2021" | findstr /N /A:4E "^"
echo copy "c:\users\sfd\appdata\roaming\microsoft\templates\normalemail.dotm" "d:\sfd\dtsc\admt\office\word\normal bu\normal bu 2021" | findstr /N /A:4E "^"
:WORDTOOLBARS
echo copy "c:\users\sfd\appdata\local\microsoft\office\word*.*ui" "d:\sfd\dtsc\admt\office\word\toolbars\word ui\word ui 2021" /d /y /v | findstr /N /A:4E "^"

Re: Commands don't execute from batch file but from CMD

Posted: 01 Jun 2021 04:55
by falcios
Forgot to mention that when I use the call command to the bat file, it works.

Is there a limit to how many lines can be in a file. That was just part of the script.

Re: Commands don't execute from batch file but from CMD

Posted: 02 Jun 2021 07:42
by ShadowThief
Everything after echo gets printed to the screen, and that's all that command does. You never run the actual commands at any point - you would do that by having the same command but without the echo at the beginning.