I know this question might have been asked in other ways, but all the things I have read and tried had not yet fixed my problem, so I am hoping to get some help here with context to my issue.
The problem:
I need to move files from a local drive to a network drive (the network drive is a SharePoint mapped library) on my server in Windows Azure (don't think the azure part matters, but it provides context).
My thought was to schedule a task that will run a bat file to move the files I need moved and do so frequently (every 5 to 10 minutes). The batch file I have created does what I need it to when I manually run the batch file but not when the task runs it.
Here is the batch file:
echo Write log file > LogStart.txt
C:\Windows\System32\robocopy.exe "\\PCICSWKS001\D$\ToBeMoved" "V:" /s /e /MOV /r:0 /W:0
echo Write log file > LogEnd.txt
You can see that it writes a log file before and after running robocopy.exe.
When the task runs it does write both of these log files so I know that the batch file is at least running.
You can also see that I have tried using the UNC path for the drive in the source, that is because I was reading that the task scheduler might not be able to pick up properly on the drive letters. When I put the machine name in for the destination and run the batch file myself or with the scheduler it errors.
Here is the action taken by the task:
Here is the task general tab
Any assistance would be much appreciated.
I had that same error with Robocopy after a few times of running it:
ERROR 3 (0x00000003) Getting File System Type of Destination
I think it has to do with how robocopy scans the destination when it has a fair amount of files on it. It worked fine when I started the copy job and the Azure destination was empty.
Anyway, I think you should try to use the AzCopy command as that should be less error prone and faster since it was designed for this kind of thing. It's command line switches are similar to robocopy so it should feel pretty familiar.
Related
I have a batch file stored on my work network. When i go manually on the target folder and open my batch file it works just fine.
Thus I wanted to put this command in my task scheduler, went on it and for its action, browsed my file, got a path Y:\ and such
However when i launch my scheduled task, i have a pop up saying windows doesn't find my bat file and my cmd writes "the path can not be found"
I believe that is because with cmd it starts naturally on the C disk, thus as it is not on the right disk, the path is not found.
A pushd to change disk from C to Y works afterwards, however i have to do that manually on cmd
My question is, how can i handle my task scheduler to launch my file without having to create a copy of my file on the local disk? I would really like it to launch the bat file stored on work network.
Thought at first to write on my bat file the pushd line but well, the file is still stored on the network haha..
Thanks for your help
Run a local batch file to map the network drive as Y
net use y: \\server\blah
Then have it call your network batch file at Y:
call y:\mybatch.bat
As task scheduler runs normally as a different user it doesn't have your drive mappings.
Alternatively call the batch file via it's unc path \\server\blah\mybatch.bat and then on the first line of the batch file pushd the unc path again
pushd \\server\blah\
I am trying to make a scheduled batch file to run with the volume shadow copy service to copy the outlook.pst file from microsoft outlook.
The commands work properly when i enter them in the command panel but when i setup the same code in a batch file it gives me an invalid number of parameters error in during the second line.
You have to use administrator access on cmd and the batch file for it to even work and i am doing that but i have no clue as to why i get an error only in the batch version but not in cmd?
I found this link helpful.
Its where i found the batch file which simplifies the process incase anyone is wondering.
Heres the code :
CALL MountLatestShadowCopy "C:\MyShadow\"
xcopy /y "C:\MyShadow\Users\%USERNAME%\Documents\Outlookove datoteke\*.pst" "\\hyp\backup"
RMDIR "C:\MyShadow"
pause
Anyone have any ideas as to the cause of my problems? Its supposed to simply copy the .pst file to a server for backup which i will run on a regular schedule.
Outlook is usually the first thing people open when they turn on their computers so i have to use volume shadow copy otherwise getting a copy might be hard on certain computers.
Thanks for the help in advance!
In my windows server, am taking SQL DB backup in C drive. I wants to copy this .bak file to some other client windows machine in a particular drive with the current date using batch script. So that i can schedule this batch script using scheduled task. please help me out.
Can anyone, give a script to run this. thanks
Batch files are always tricky to get just right. First I'd open a command line and see if you can copy between two machines using the following syntax:
copy C:\localfile.bak \\remotemachine\c$\Path\remotefile.bak
(where "remotemachine" is the name of the remote machine and "c$" is the drive you wish to copy to). You can then copy this into a batch file and set up a scheduled task.
As for renaming the file to have the current date and time, I suggest you start with this question as it may involve some effort to get it into a format you want.
How would I create a self executing batch file to delete files in a specific folder.
Scenario: I have a folder on a server where all the scannered documents go to once they have been scanned. They want a the scanned documents to be deleted after 1 day. Can a batch file be created to do that everyday?
You can use the built in task scheduler - this can call a batch file, or just about anything.
(I am assuming Windows, since you mention batch files).
This is quite a well known method, and was documented in MSDN some time ago. This technique works on both Windows 95 and Windows NT. It works because MS-DOS batch files are able to delete themselves. To test this technique, create a small batch file containing the single command:
del %0.bat
The batch file, when run, deletes itself and issues an error "The batch file cannot be found". This error is just a simple message, so it can be safely ignored. By itself this isn't too useful, but when modified to delete our executable it solves our problem, albeit in a rather forceful manner. Our executable will create a batch file (called C:\DelUs.bat) with the following content:
:Repeat
del "C:\MYDIR\MYPROG.EXE"
if exist "MYPROG.EXE" goto Repeat
rmdir "C:\MYDIR"
del "\DelUS.bat"
This batch file repeatedly attempts to delete the specified file, and will run continuously consuming CPU until it succeeds. When the execuable has been deleted, the batch file then deletes itself.
The executable needs to spawn off the batch file using CreateProcess, and then should exit immediately. It would be a good idea to give the batch file's thread of execution a low priority so that it doesn't get much execution time until the original executable has terminated.
Read the entire article at http://www.catch22.net/tuts/self-deleting-executables that contains the full code to this technique.
I have a shared disk that I would like to clean up once per week using a scheduled task of some sort. I would like to use a batch script so that the system admins can easily modify it or reuse it on other directories when needed.
The directory has files with multiple file extensions but the ones that need to be deleted end in .bkf and must be over 2 weeks old.
Does anyone have a batch script solution for this windows server (not sure which version)?
If you have PowerShell (or can install it), check out this link: http://thepowershellguy.com/blogs/posh/archive/2007/12/13/hey-powershell-guy-how-can-i-delete-files-that-are-a-specified-number-of-hours-old.aspx
Take a look at this page - scheduling tasks from command line
It shows you hot to create scheduled tasks from the command line. You might be able to use this in combination with other dos commands to get your result.
The only thing that needs to be in the batch file is
#echo off
cls
del C:\some\directory\*.bkf
And the delete path can also be sent to this batch script as an argument so that the directory is changeable.
I ended up just writing an EXE that accepts parameters and scheduling that. Unfortunately the other solutions didn't have the flexibility needed.
have you looked into forfiles.exe?
http://blog.stevienova.com/2007/02/27/forfiles-delete-files-older-than-x-amount-of-days/