Commands don't execute from batch file but from CMD

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
falcios
Posts: 43
Joined: 02 Mar 2017 05:38

Commands don't execute from batch file but from CMD

#1 Post by falcios » 01 Jun 2021 04:10

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 "^"

falcios
Posts: 43
Joined: 02 Mar 2017 05:38

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

#2 Post by falcios » 01 Jun 2021 04:55

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.

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

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

#3 Post by ShadowThief » 02 Jun 2021 07:42

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.

Post Reply