Windows 10: Simple batch file gets syntax error

Discus and support Simple batch file gets syntax error in Windows 10 Gaming to solve the problem; My one-line batch file gets the error message :The syntax of the command is incorrect. I'm pretty sure this is not so.As in so many many other cases,... Discussion in 'Windows 10 Gaming' started by Larry Dunn1, Oct 5, 2024.

  1. Simple batch file gets syntax error


    My one-line batch file gets the error message :The syntax of the command is incorrect. I'm pretty sure this is not so.As in so many many other cases, Microsoft gives a generic error message that has no apparent connection to what the user is trying to do. As a result, we don't know what is going on, and we don't know what to do. So we have to waste the time of a Microsoft representative, and maybe get an answer in a couple of years.And it's even longer for a CORRECT answer.Here's my batch fileSimple batch file gets syntax error :mad:echo offcopy C:\Users\larry\OneDrive\Pictures\user.png C:\ProgramData\Microsoft\User Account Picture

    :)
     
    Larry Dunn1, Oct 5, 2024
    #1
  2. Rohn007 Win User

    Batch rename files using ForFiles command getting syntax error

    Win 10

    I want to rename a bunch of files to add a prefix. ie "aaa.url" to "win 10- aaa.url"

    I found these pages:

    Rename file extensions in bulk from command line [CMD]

    Forfiles

    the example and my version of the command

    forfiles /M *.jpg /C "cmd /c rename @file \"@fname - pic.jpg\""

    forfiles /M *.* /C "CMD /c RENAME @FILE \"WIN 10- @FILE\""

    I get this output:

    D:\Public\Favorites\@test>forfiles /M *.* /C "CMD /c RENAME @FILE \"WIN 10- @FILE\""

    The syntax of the command is incorrect.

    The syntax of the command is incorrect.

    The syntax of the command is incorrect.

    The syntax of the command is incorrect.

    The syntax of the command is incorrect.

    The syntax of the command is incorrect.

    The syntax of the command is incorrect.

    'Tutorials' is not recognized as an internal or external command,

    operable program or batch file.

    The syntax of the command is incorrect.

    The syntax of the command is incorrect.

    The syntax of the command is incorrect.

    The syntax of the command is incorrect.

    The syntax of the command is incorrect.

    As far as I can see I have the syntax OK, but obviously windows does not agree with me.

    What am I missing?
     
    Rohn007, Oct 6, 2024
    #2
  3. DennisCPA Win User
    Batch File Syntax: Insert %USERPROFILE% into batch file command lines

    Following batch file code lines work fine.

    Batch File that works:

    CD "C:\Users\xlmas\Documents\Visual Studio 2013\Projects\ToolsNET\bin\Release\"

    "C:\Users\xlmas\Documents\Visual Studio DOS Utilities\RegAsm64" "C:\Users\xlmas\Documents\Visual Studio 2013\Projects\ToolsNET\bin\Release\ToolsNET.dll" /UNREGISTER

    Goal:

    Want to substitute the environmental variable %USERPROFILE% for "C:\Users\xlmas" but I keep running into syntax issues. The issue seems to be related to the spaces in the Path. I have attempted the code with and without quotation marks. Either way there
    are syntax errors when invoking RegAsm64. If I include quotation marks (to preserve the folder name with spaces) in the Set commands they screw up attempting to run RegAsm64.

    Failed attempts:

    Set DLLPathEnd="\Documents\Visual Studio 2013\Projects\ToolsNET\bin\Release"

    Set DosUtilEndPath="\Documents\Visual Studio DOS Utilities"

    Set DLLFullPath=%UserProfile%%DLLPathEnd%

    CD %DLLFullPath%

    Set DosUtilFullPath=%UserProfile%%DosUtilEndPath%

    %DosUtilFullPath%\ResAsm64 %DLLFullPath%\ToolsNET.dll /UNREGISTER

    Any thoughts greatly appreciated!
     
    DennisCPA, Oct 6, 2024
    #3
  4. Kreij Win User

    Simple batch file gets syntax error

    Batch Files Knowledge Base

    Batch files are exactly that. They are a file that contain a "batch" of commands so that you do not have to type them consecutively at a DOS prompt.

    Anything that you can do at a DOS prompt you can do in a BF, and more.

    What batch files allow you to do is take arguments when you call the file using the % identifier within the batch file, and also to use conditional statements (if's) to cause code redirection based on user input.

    Batch file syntax is really easy to learn, and in a day or two you can write very powerful batch files to do a lot of stuff.

    They are not so much useful to the home user as they are to someone who is an administrator of a network.

    A simple use of a batch file ...

    Let's say that you have a system that has 3 hard drives. C:, D:, E:
    You want to copy the contents of C & D to E.

    You create a file called MyCopy.cmd (just make a text file in notepad and rename it)
    Then type in two lines.
    "xcopy C:\ E:\MyCopyOfC /c /e /r /k (etc. xcopy siwtches
    "xcopy D:\ E:\MyCopyOfD (switches)

    Save the file and run from a DOS prompt.

    This will create two directories (if the switches are correct) called MyCopyOfC and MyCopyOfD on the E: partition.

    This is a simple backup solution for multiple hard drives.

    You can , of course, get as elaborate as you want.
     
    Kreij, Oct 6, 2024
    #4
Thema:

Simple batch file gets syntax error

Loading...
  1. Simple batch file gets syntax error - Similar Threads - Simple batch file

  2. Simple batch file gets syntax error

    in Windows 10 Software and Apps
    Simple batch file gets syntax error: My one-line batch file gets the error message :The syntax of the command is incorrect. I'm pretty sure this is not so.As in so many many other cases, Microsoft gives a generic error message that has no apparent connection to what the user is trying to do. As a result, we...
  3. How to run a simple batch file in windows 10

    in Windows 10 Gaming
    How to run a simple batch file in windows 10: For years, from Windows3.1 to Windows7 I have been able to run simple batch files like something.bat It always executed without any problems.Fast forward to Windows10 pro 22H2 , it does not work anymore : On clicking the 'something.bat' , it shows the same as 'something.txt'...
  4. How to run a simple batch file in windows 10

    in Windows 10 Software and Apps
    How to run a simple batch file in windows 10: For years, from Windows3.1 to Windows7 I have been able to run simple batch files like something.bat It always executed without any problems.Fast forward to Windows10 pro 22H2 , it does not work anymore : On clicking the 'something.bat' , it shows the same as 'something.txt'...
  5. How to run a simple batch file in windows 10

    in Windows 10 Network and Sharing
    How to run a simple batch file in windows 10: For years, from Windows3.1 to Windows7 I have been able to run simple batch files like something.bat It always executed without any problems.Fast forward to Windows10 pro 22H2 , it does not work anymore : On clicking the 'something.bat' , it shows the same as 'something.txt'...
  6. Syntax Error

    in Windows 10 Network and Sharing
    Syntax Error: i try and open HR Block 2018 and get this error Syntax error on line 1:{"queryUrl"is not a valid type,see ConfigurationFileReader::readData{}} What the heck do I do now. I tried Uinstall and reinstalling the software from a disk. It just wont work. I never had this...
  7. Syntax for Batch file &/or powershell script to run multiple commands

    in Windows 10 Support
    Syntax for Batch file &/or powershell script to run multiple commands: I wanted a batch file to run the following commands: Start Powershell as administrator cd "C:\Program Files\Macrium\Reflect" regsvr32 RContextMenu.dll regsvr32 RShellEx.dll I can get as far as: Code: echo Start "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" cd...
  8. A simple batch file...?

    in Windows 10 Network and Sharing
    A simple batch file...?: Hi, It's been a while since I delved into the depths of Windows - and long before Windows 10 - but I would like to write a batch file to copy files from a folder on my Windows 10 PC to 2 separate folders - one on an SD card and the other on an external hard drive (I have...
  9. Simple batch file driving me nuts

    in Windows 10 Software and Apps
    Simple batch file driving me nuts: All I want to do is check if a folder exists on a network share and if it does, copy a file to it. Should be a piece of cake. Here is my code: Code: @echo on set "newFile=Just a test file.txt" set "hostTarget=\\Kfwserver\HP_D\ShowkeyPlus Data\" if exists "%hostTarget%" copy...
  10. Robocopy syntax doesn't work in my batch file anymore

    in Windows 10 Support
    Robocopy syntax doesn't work in my batch file anymore: I created the following text file & then changed the extension to .bat. The syntax is: Robocopy "C:\Users\Phil\AppData\Roaming\Thunderbird\Profiles\MyProfile" "E:\Backups\Thunderbird\Profiles\MyProfile" /MIR /Z /W:5 /TS /MOT:180 /R:10 I also created a shortcut for it on...