Windows 10: Robocopy syntax doesn't work in my batch file anymore

Discus and support Robocopy syntax doesn't work in my batch file anymore in Windows 10 Support to solve the problem; I created the following text file & then changed the extension to .bat. The syntax is: Robocopy... Discussion in 'Windows 10 Support' started by phrab, Mar 22, 2018.

  1. phrab Win User

    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 my desktop.

    If I paste this into Powershell or Powershell (run as administrator), it works fine. When I first created it, I could double click it & it would run fine. In order to get the batch file to work now, I have to right click it & choose "Run as administrator". Can anyone explain what's happening?

    I should add that I left off an additional option: /RH: 0130-0140 that allows it to run only between 0130 & 0140 AM. However, it hasn't run for 2 days. It used to be that I would simply edit the batch file by pressing enter after /R:10 so that the whole thing read:

    Robocopy "C:\Users\Phil\AppData\Roaming\Thunderbird\Profiles\MyProfile" "E:\Backups\Thunderbird\Profiles\MyProfile" /MIR /Z /W:5 /TS /MOT:180 /R:10
    /RH: 0130-0140

    This would allow me to run it manually. Then I could delete the "return" & have it run only 130-140. In any event, I don't know why it doesn't work any more. Any help would be appreciated!

    I may have found the answer, but I'd appreciate some knowledgeable advice. I changed the name of the batch file from Copy.bat to Robocopy.bat. Apparently, Windows doesn't like that. When I changed it to any other name, it worked. Can someone please explain that?

    Thank you in advance!

    :)
     
    phrab, Mar 22, 2018
    #1

  2. Deleting Hidden Folders

    I already have ownership of the computer as administrator. I was able to use Robocopy to complete my backup successfully.

    My batch file is now working fully and backing up all my sub-folders. Thanks Andre.
     
    stevebeasley, Mar 22, 2018
    #2
  3. DennisCPA Win User
    Batch File Syntax: Insert %USERPROFILE% into batch file command lines

    Thanks for your time and knowledge!

    Following is what worked:

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

    Set DosUtilPathEnd=\Documents\Visual Studio DOS Utilities

    Set DLLFullPath=%UserProfile%%DLLPathEnd%

    Set DosUtilFullPath=%UserProfile%%DosUtilPathEnd%

    CD %DLLFullPath%

    "%DosUtilFullPath%\RegAsm64" "%DLLFullPath%\ToolsNET.dll" /UNREGISTER
     
    DennisCPA, Mar 22, 2018
    #3
  4. Robocopy syntax doesn't work in my batch file anymore

    Caledon Ken, Mar 22, 2018
    #4
  5. Samuria Win User
    A bat file is old MS-DOS command file you should have a .cmd extension for Windows file
     
    Samuria, Mar 23, 2018
    #5
  6. Bree New Member
    You can use .bat or .cmd interchangeably in Windows NT or above and CMD.EXE will treat them identically, with one important distinction.
    https://groups.google.com/forum/#!ms...k/LIEViGNmkK0J
     
  7. phrab Win User
    Thank you so much for your reply, Ken. I have some additional questions please. I got my batch file to work manually by changing the name of it...it's now "ThunderbirdCopy.bat".

    I am not well versed in batch files, so I thought (apparently incorrectly) that the /MOT:180 /R:10 would make it monitor & start automatically.

    After going to the thread you posted above, I guess I have 2 choices:
    1) I can manually start it & then leave it running, so that at 1:30AM it will monitor the source to see if there's changes & then copy. This seems to be a stupid choice, as it would be running constantly & never stop.
    2) I could use Task Scheduler to run it starting at 1:30AM, which is what I've done.
    Question 1: Is this the correct way to do this?
    Question 2: The thread above mentioned using cmd /c for elevated Powershell.
    A. What is an elevated Powershell?
    B. Is there an advantage to using Powershell over just the command line.
    Question 3: Would the syntax for the elevated Powershell then be:
    cmd /c ""Robocopy "C:\Users\Phil\AppData\Roaming\Thunderbird\Profiles\MyProfile" "E:\Backups\Thunderbird\Profiles\MyProfile" /MIR /Z /W:5 /TS /MOT:180 /R:10""
    i.e. I'm not sure how to invoke Powershell automatically.
    C. In any event, if I use Task Scheduler to start the batch file at 1:30AM, is there an option to stop it after it's run?

    Sorry for all these questions, but I really appreciate your help!
     
    phrab, Mar 23, 2018
    #7
  8. Robocopy syntax doesn't work in my batch file anymore

    Yes I would use Task manager to start this file.

    Elevated in simple terms you are giving it additional permissions.

    What is an Elevated Command Prompt?

    As I understand it you would just use the file as you use it today. When you run it through Task Manager it will invoke Powershell.

    Yes I believe the syntax is right. You added the extra quotes surrounding the entire line as you had quotes within your command. I did not look at your robocopy parameters.
     
    Caledon Ken, Mar 23, 2018
    #8
  9. lx07 Win User
    I think you are making your robocopy parameters far too complicated.

    I don't see the point in scheduling the job to run at 01:30 for 3 hours to look for changes. What will happen? Surely you scheduled it at a time when nothing was happening. Why not just run it to do the backup of changed files and then stop (that is what I do).

    With regards to the robocopy switches:
    You specify /Z to copy files in restartable mode. Why? You would only use this for massive files over dodgy connections. Drop it.
    You have the /TS to log timestamps but you don't specify a log file. The switch is therefore pointless.
    You have reduced the wait time on error from the default 30 seconds to 5. And retries to 10. This means if it can't find your backup it will try again for 50 seconds. I'd set both to zero - it is a local drive and you either connected it or forgot to.

    Then you are monitoring to see if any changes have happened in the 180 minutes after you submit the job. This means if you submit the job for 01:30 it will see if any changes occur before 03:30. This may be what you want but I doubt it.

    You also are not copying all security flags - the default is /COPYRobocopy syntax doesn't work in my batch file anymore :DAT - I'd change that to /COPYALL (to include (S=Security=NTFS ACLs, O=Owner info, U=aUditing info)

    Therefore I'd change this:
    Robocopy "C:\Users\Phil\AppData\Roaming\Thunderbird\Profiles\MyProfile" "E:\Backups\Thunderbird\Profiles\MyProfile" /MIR /Z /W:5 /TS /MOT:180 /R:10 to:
    Robocopy "C:\Users\Phil\AppData\Roaming\Thunderbird\Profiles\MyProfile" "E:\Backups\Thunderbird\Profiles\MyProfile" /MIR /COPYALL /R:0 /W:0

    There is no advantage running robocopy by powershell than cmd incidentally - the result is exactly the same. However splitting out the parameters into arrays and forcing quote marks around paths is a bore in powershell.

    I do use powershell for this though: this is my robocopy script (triggered via task scheduler when I put my laptop in the dock) to give you an idea. PHP Code: $backupDrive='E'
    $backupLocation=$backupDrive+':\X201 Backup'

    $backupDirectories = @(
    ,('D:\Music','*.*')
    ,('C:\Users\Hali\Documents\Calibre Library','*.*')
    ,('C:\Users\Hali\OneDrive','*.*')
    )

    # Check if dock connected
    if (Test-Path $backupLocation) {
    For($i=0;$i -lt $backupDirectories.Count; $i++) {
    $source=$backupDirectories[$i][0]
    $files=$backupDirectories[$i][1]

    if(Test-Path $source) {
    $sourceDrive=(get-item $source).PSDrive.Name
    $unqualifiedPath=split-path -noqualifier $source
    $destination="$backupLocation\$sourceDrive$unqualifiedPath"

    $logfile="""$backupLocation\Backup Logs\Backup $(get-date -f yyyy-MM-dd' 'HH-mm-ss-fffff) $(split-path -leaf $source).log"""

    # Robocopy options
    $copyOptions = @('/B','/COPYALL','/MIR')
    $selectionOptions = @()
    $retryOptions = @('/R:0','/W:0')
    $loggingOptions = @('/NFL','/NDL',"/LOG:$logfile",'/TEE')
    $jobOptions = @()

    $CmdLine = @('"{0}"' -f $source) +@('"{0}"' -f $destination) +@($files) +$copyOptions +$selectionOptions +$retryOptions +$loggingOptions +$jobOptions
    & 'robocopy.exe' $CmdLine
    }
    }
    }
    You should also note that if you use the /MT switch with /LOG you will get hundreds or thousands of pages saying "100%100%100%100%" etc in your logfile.

    According to TechNet (in 2009): Robocopys /MT option disables /NP option it will be fixed soon but that was nearly a decade ago. *Wink
     
  10. phrab Win User
    Thank you so much Ken for answering my questions. You've been a great help!
     
    phrab, Mar 23, 2018
    #10
  11. phrab Win User
    Thank you very very much!! This is fantastic! I've learned a lot in such a short time.
     
    phrab, Mar 23, 2018
    #11
  12. phrab Win User
    Thought I had this, but my batch file isn't working properly. When I use the /COPYALL switch, it doesn't work. If I use:
    /MIR /COPYALL /R:0 /W:0
    -OR-
    /MIR /COPYALL /R:0 /W:0 /MT:25
    it just flashes, but doesn't copy anything.

    If I use:
    /MIR /R:0 /W:0
    -OR-
    /MIR /R:0 /W:0 /MT:25
    it works.

    Can you figure out what I'm doing wrong? Thank you again for your time & patience!

    Additional: I ran the command from a command prompt & got this message:
    ERROR : You do not have the Manage Auditing user right.
    ***** You need this to copy auditing information (/COPY:U or /COPYALL).

    Since this is my own computer & my user profile has administrator rights, how can I add the "Manage Auditing user right"? Thank you again!

    Additional: Sorry for panicking. The syntax works on my WinXP machine & I found the tutorial on adding user rights, so it appears to work now in Windows 10. It will run at 1:15AM tomorrow morning. I'll post back if it doesn't work. Sorry for all the additional questions that I should have researched before posting. Many thanks!
     
    phrab, Mar 25, 2018
    #12
  13. lx07 Win User

    Robocopy syntax doesn't work in my batch file anymore

    What are you trying to do with the /MT switch? This is to define the number of threads your copy command uses and you have picked 25. The default is 4. Unless you have multiple CPU it is probably best to leave it out - there is also a issue since 4000BC where using the /MT switch messes up your log file.

    The second error you got is because you forgot to run as administrator.

    Open a command prompt as you or administrator any type in "WhoAmI /all" and you will see exactly the difference.
     
  14. phrab Win User
    Thank you again. I actually changed my user privileges from the tutorial at Change User Rights Assignment Security Policy Settings in Windows 10 & included Manage Auditing rights. However, now I see it could have been simpler.

    If I go to the Task Scheduler > Task Scheduler > Library & rt click on my batch file>Properties, I see an option to "Run with highest privileges". I didn't realize that was the same as "Run with Administrative Privileges", but I guess it is. That would have done the trick, wouldn't it? (I've also deleted the /MT switch).

    I don't have a log file. Should I be using one? Thank you again!!
     
    phrab, Mar 26, 2018
    #14
  15. lx07 Win User
    There are lots of different privileges in Windows. Administrative privileges aren't the same as highest - just the default is different.

    Have a look here - I'd put all this in spoiler tags but we don't have them here - don't be put off by the length or detail of this post just see some boxes are different sizes *Smile

    This WhoAmI /all information default for standard user: Code: PRIVILEGES INFORMATION ---------------------- Privilege Name Description State ============================= ==================================== ======== SeLockMemoryPrivilege Lock pages in memory Disabled SeShutdownPrivilege Shut down the system Disabled SeChangeNotifyPrivilege Bypass traverse checking Enabled SeUndockPrivilege Remove computer from docking station Disabled SeIncreaseWorkingSetPrivilege Increase a process working set Disabled SeTimeZonePrivilege Change the time zone Disabled[/quote] Right click and "Run as Administrator" Code: PRIVILEGES INFORMATION ---------------------- Privilege Name Description State ========================================= ================================================================== ======== SeLockMemoryPrivilege Lock pages in memory Disabled SeIncreaseQuotaPrivilege Adjust memory quotas for a process Disabled SeSecurityPrivilege Manage auditing and security log Disabled SeTakeOwnershipPrivilege Take ownership of files or other objects Disabled SeLoadDriverPrivilege Load and unload device drivers Disabled SeSystemProfilePrivilege Profile system performance Disabled SeSystemtimePrivilege Change the system time Disabled SeProfileSingleProcessPrivilege Profile single process Disabled SeIncreaseBasePriorityPrivilege Increase scheduling priority Disabled SeCreatePagefilePrivilege Create a pagefile Disabled SeBackupPrivilege Back up files and directories Disabled SeRestorePrivilege Restore files and directories Disabled SeShutdownPrivilege Shut down the system Disabled SeDebugPrivilege Debug programs Disabled SeSystemEnvironmentPrivilege Modify firmware environment values Disabled SeChangeNotifyPrivilege Bypass traverse checking Enabled SeRemoteShutdownPrivilege Force shutdown from a remote system Disabled SeUndockPrivilege Remove computer from docking station Disabled SeManageVolumePrivilege Perform volume maintenance tasks Disabled SeImpersonatePrivilege Impersonate a client after authentication Enabled SeCreateGlobalPrivilege Create global objects Enabled SeIncreaseWorkingSetPrivilege Increase a process working set Disabled SeTimeZonePrivilege Change the time zone Disabled SeCreateSymbolicLinkPrivilege Create symbolic links Disabled SeDelegateSessionUserImpersonatePrivilege Obtain an impersonation token for another user in the same session Disabled[/quote] System: Code: PRIVILEGES INFORMATION ---------------------- Privilege Name Description State =============================== ============================================= ======== SeAssignPrimaryTokenPrivilege Replace a process level token Disabled SeIncreaseQuotaPrivilege Adjust memory quotas for a process Disabled SeTcbPrivilege Act as part of the operating system Enabled SeSecurityPrivilege Manage auditing and security log Disabled SeTakeOwnershipPrivilege Take ownership of files or other objects Disabled SeLoadDriverPrivilege Load and unload device drivers Disabled SeProfileSingleProcessPrivilege Profile single process Enabled SeIncreaseBasePriorityPrivilege Increase scheduling priority Enabled SeCreatePermanentPrivilege Create permanent shared objects Enabled SeBackupPrivilege Back up files and directories Disabled SeRestorePrivilege Restore files and directories Disabled SeShutdownPrivilege Shut down the system Disabled SeDebugPrivilege Debug programs Enabled SeAuditPrivilege Generate security audits Enabled SeSystemEnvironmentPrivilege Modify firmware environment values Disabled SeChangeNotifyPrivilege Bypass traverse checking Enabled SeUndockPrivilege Remove computer from docking station Disabled SeManageVolumePrivilege Perform volume maintenance tasks Disabled SeImpersonatePrivilege Impersonate a client after authentication Enabled SeCreateGlobalPrivilege Create global objects Enabled SeTrustedCredManAccessPrivilege Access Credential Manager as a trusted caller Disabled[/quote] TrustedInstaller Code: PRIVILEGES INFORMATION ---------------------- Privilege Name Description State ========================================= ================================================================== ======== SeAssignPrimaryTokenPrivilege Replace a process level token Disabled SeLockMemoryPrivilege Lock pages in memory Enabled SeIncreaseQuotaPrivilege Adjust memory quotas for a process Disabled SeTcbPrivilege Act as part of the operating system Enabled SeSecurityPrivilege Manage auditing and security log Disabled SeTakeOwnershipPrivilege Take ownership of files or other objects Disabled SeLoadDriverPrivilege Load and unload device drivers Disabled SeSystemProfilePrivilege Profile system performance Enabled SeSystemtimePrivilege Change the system time Disabled SeProfileSingleProcessPrivilege Profile single process Enabled SeIncreaseBasePriorityPrivilege Increase scheduling priority Enabled SeCreatePagefilePrivilege Create a pagefile Enabled SeCreatePermanentPrivilege Create permanent shared objects Enabled SeBackupPrivilege Back up files and directories Disabled SeRestorePrivilege Restore files and directories Disabled SeShutdownPrivilege Shut down the system Disabled SeDebugPrivilege Debug programs Enabled SeAuditPrivilege Generate security audits Enabled SeSystemEnvironmentPrivilege Modify firmware environment values Disabled SeChangeNotifyPrivilege Bypass traverse checking Enabled SeUndockPrivilege Remove computer from docking station Disabled SeManageVolumePrivilege Perform volume maintenance tasks Disabled SeImpersonatePrivilege Impersonate a client after authentication Enabled SeCreateGlobalPrivilege Create global objects Enabled SeIncreaseWorkingSetPrivilege Increase a process working set Enabled SeTimeZonePrivilege Change the time zone Enabled SeCreateSymbolicLinkPrivilege Create symbolic links Enabled SeDelegateSessionUserImpersonatePrivilege Obtain an impersonation token for another user in the same session Enabled[/quote] What the tutorial you quoted explains is how to enable privileges that are normally disabled under the context in which you are running. You can if you want enable them all (as long as your account is part of the administrators group). For robocopy backup you don't need everything - just the /COPYALL switch requires permissions standard user doesn't have by default - running as Administrator is sufficient to copy the security data.

    As for whether you want a logfile that is up to you. I use one (with most details suppressed - see below) so I can see if and when it worked. I delete old log files every few months when I remember.

    It is definitely good for testing - just put this on the end of your statement - you can remove it later if you don't want to check the logs or have them taking up space:

    /NFL /NDL /LOG:C:\Temp\whatever.log
     
Thema:

Robocopy syntax doesn't work in my batch file anymore

Loading...
  1. Robocopy syntax doesn't work in my batch file anymore - Similar Threads - Robocopy syntax doesn't

  2. Can Robocopy copy in batches of files?

    in Windows 10 Gaming
    Can Robocopy copy in batches of files?: Evening, I'm just after a bit of help, I have a folder on my PC which has a load of files from my Nikon Camera - for my current example 1700 at around 42GB, I usually copy these to an external SDD but I'm guessing due to the SSD the speed tends to drop off so I start around...
  3. Can Robocopy copy in batches of files?

    in Windows 10 Software and Apps
    Can Robocopy copy in batches of files?: Evening, I'm just after a bit of help, I have a folder on my PC which has a load of files from my Nikon Camera - for my current example 1700 at around 42GB, I usually copy these to an external SDD but I'm guessing due to the SSD the speed tends to drop off so I start around...
  4. Can Robocopy copy in batches of files?

    in Windows 10 Network and Sharing
    Can Robocopy copy in batches of files?: Evening, I'm just after a bit of help, I have a folder on my PC which has a load of files from my Nikon Camera - for my current example 1700 at around 42GB, I usually copy these to an external SDD but I'm guessing due to the SSD the speed tends to drop off so I start around...
  5. HOW: Robocopy command to a batch-file

    in Windows 10 Network and Sharing
    HOW: Robocopy command to a batch-file: This working fine in a Command Prompt: robocopy "C:\¤Head Folder\Folder 01\Old folder" "C:\¤Head Folder\Folder 01\New folder" /mov /minage:930 How do I make a Batch file .BAT with that RoboCopy command...
  6. Robocopy Syntax required

    in Windows 10 Installation and Upgrade
    Robocopy Syntax required: Hi I have a shortcut with the following script C:\Windows\SysWOW64\Robocopy.exe /MIR "C:\Users\Jandd\AppData\Local\Google\Chrome\User Data\Default" J:\CHROME_BOOKMARKS_BACKUP /SEC Bookmark* Under Windows 7 this script copied the two Bookmarks files and put them in my...
  7. Robocopy Syntax Required

    in Windows 10 Software and Apps
    Robocopy Syntax Required: Hi I have a Robocopy script for backing up my files. It always worked ok under Windows 7 but since I upgraded to Windows 10 it is now treating every file as "modified" so it takes a lot longer to backup my files. My script is: C:\Windows\SysWOW64\Robocopy.exe I:\DATA...
  8. 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...
  9. Batch File doesn't open

    in Windows 10 BSOD Crashes and Debugging
    Batch File doesn't open: The title is pretty self explanatory. When I double click the batch file, a program tries to open in the taskbar and it quickly disappears as well. When I run it as an administrator, it asks me, "Allow command processor to change blah blah blah". I click yes, and then the...
  10. Wildcards in Robocopy | Batch file very very basics

    in Windows 10 Support
    Wildcards in Robocopy | Batch file very very basics: I have folders that contain files and subfolders. The files have a limited set of extensions. What I seek to do is to robocopy /mir the files separately from the subfolders. I have been trying to review wildcard basics. I am not finding any ways to combine them that suits...

Users found this page by searching for:

  1. schedule tasks dont work robocopy bat