Robocopy using /copyall generates error 3- related to security? - batch-file

I have a simple .bat file that copies a mapped network folder to a local external drive (NTSF). This was working perfectly, but there was a SNAFU with my domain profile and upon rebuilding my profile it seems I have lost the right to copy files from the server using this code:
Robocopy \\###.###.##.###\ShareFile "G:\Folder\File_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%%time:~6,2%" /e /z /np /copyall /R:5 /R:2
Error 3 90x00000003) Accessing Source Directory Y:\
The system cannot find the path specified.
I know the COPYALL requires full privileges, and I need this info copied. I am a local admin, admin on the server, and a Domain admin... how can I not have the security rights?

Is your network drive remapped?
I would reccomend using the full UNC path instead of a drive letter.

Related

Copying the files from one server to another server getting NTFS error

I am using one batch file to copy files from one server to another server. That batch file run fine when I run it manually, but I run the same batch file using task scheduler am getting below error.
ERROR 5 (0x00000005) Getting File System Type of Source
\\Server ame\c$\ProgramData\DStt\
Access is denied.
But same script run fines when I run it manually. Script has been scheduled with admin user & admin user have access to both server.
robocopy /XC /E /R:2 /W:2 /copy:DATS /NDL /NP \\Server\c$\ProgramData\DStt C:\ProgramData\DStt > "D:\Apps\DStt\syncDStt_AppData_Server.log"

Move a Folder and Subfolders to another Folder using Batch or VBS

I'm trying to automatically move the subfolders and files from my Dropbox folder on my F: Drive to a separate folder on the same drive, therefore emptying my Dropbox and freeing up space in it while backing up the files.
I tried this in Batch:
MOVE /-Y "F:\Dropbox\files\camera" "F:\backup\Camera\"
pause
but I keep getting Access Denied even when running as Administrator.
I also tried this in VBS:
With CreateObject("Scripting.FileSystemObject")
.MoveFile "F:\Dropbox\files\camera*", "F:\backup\Camera\"
End With
but I only got Path Not Found from that.
So pretty much I'm a bit stumped, or overlooking something obvious, But basically I just want to make a small script in vbs or batch that allows me to move all the sub-folders and files from F:\Dropbox\files\camera\ to F:\backup\camera\ so I can set it as a scheduled task and let it run each day so that it empties my Dropbox folder(and therefore my Dropbox account) of all files and folders and backs them up.
Any help would be appreciated, I have already searched a number of different options and none seems to work specifically for my purpose.
I suggest using ROBOCOPY instead of MOVE.
I have a similar backup script that uses it.
See:
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy
#ECHO OFF
ROBOCOPY /E /MOVE "F:\Dropbox\files\camera" "F:\backup\Camera\"
MKDIR "F:\Dropbox\files\camera"
Options:
/E : Copy Subfolders, including Empty Subfolders.
/MOVE : Move files and dirs (delete from source after copying).
Because of the /MOVE switch, I need to re-create the source directory because ROBOCOPY moves it to the destination directory. ROBOCOPY, by default, will retry the operation if it fails. See the /R:n and /W:n options to customize it. Also, the command will print a lot of info messages to the terminal, but you can customize it using the ROBOCOPY's logging options (ex. /NJH, /NJS, etc).
For the "Access Denied" error, make sure that:
You have write access to the destination folder
(Test by creating a batch file with just MKDIR "F:\backup\Camera\some_file.txt")
(Test by creating a batch file with just MKDIR "F:\backup\Camera\some_folder")
The files being moved are not being used or opened anywhere prior to running the script
(Ex. It's not opened in the Dropbox app.)

Relative path doesn't work on shared directory

xcopy "D:\CCStudio\rtos" panasonic /s /e
The folder panasonic and the bat file are on the same level in the directory structure, although on another machine I have access to.
When I use the bat script on my PC everything works fine. But when I put the bat script into the remote shared folder, it doesn't work as expected. The problem seems not to be the source, instead the destination address is the key in the problem. When I replace `pansonic' whit its absolute address, the script works.
So why should I specify absolute path for destination? Recall that the destination is external path. It is shared folder on another windows machine.
I currently run a bat from a shared drive to copy to another shared drive. This is what I use to get it working fine. Adjust as needed.
cd /d %~dp0
xcopy /s "D:\CCStudio\rtos" "panasonic\" /E
cd /d %~dp0 will change the directory to what ever the batch file is in allowing you to use relative paths. This script will copy the files in rtos to panasonic. Folder path will look something like this X:\Shared\Network\panasonic\RtosFiles.ini assuming RtosFiles.ini was in D:\CCStudio\rtos and the batch was run in X:\Shared\Network\

XCOPY batch file

I’m looking to create a batch file that transfers all my music from my external drive to my Samsung note 3. The idea is just to click the batch file and for it to update any song on my external on my phone.
Heres what I’ve got
XCOPY "E:\Music\*.*" "Computer\SAMSUNG-SM-N900A\Phone\Music\" /e /c /r /k /y /v
The problem I see is that it’s creating a folder on my desktop with that path, the directory on my desktop being computer with the following subfolders.
I’m not sure why it won’t recognize the path, any ideas?
You can't directly copy files from windows to an android device, its a different file system. You can probably do it manually with this program:
https://android-file-manager.en.softonic.com/

ClickOnce Deployment with a Database as a Prerequisite

I have a Winforms application that I want to publish using ClickOnce. This application comes with an initial database, which must be installed once on a per-machine basis. After much ado, I have landed on the idea of using a custom pre-requisite to install the .sdf file. I have used Bootstrapper Manifest Generator (BMG) to create a package for the .cmd file I want to run, and I have included the .sdf file as an "additional file."
My expectation was that the two files would end up in the same directory, and I would be able to copy the .sdf file to the place where I want it (They do end up in the same directory.) The pre-requisite shows up in Visual Studio just fine. It get's deployed to the client system just fine, and the setup program kicks off the prerequisite just fine.
The only problem is that the current working directory that the .cmd file is executing is C:\Documents and Settings\\Desktop!
Neither of the two files (.cmd or .sdf) are located there - they were downloaded elsewhere, e.g., "C:\Documents and Settings\drogers\Local Settings\Temp\VSD5A.tmp". So, although I know where to xcopy to, I have no idea where to xcopy from.
How can I resolve this?
Here is the .cmd file:
REM Modify this file to reflect your manufacturer name [FHCRC] and product name [ClickOnceSharedDataDemo].
SET TargetBase=%ALLUSERSPROFILE%
IF NOT "%TargetBase%"=="C:\ProgramData" SET TargetBase=%ALLUSERSPROFILE%\Application Data
REM We only want to do this copy for the first user!
if exist "%TargetBase%\FHCRC\ClickOnceSharedDataDemo\shareddata.sdf" GOTO EXIT
if not exist "%TargetBase%\FHCRC" mkdir "%TargetBase%\FHCRC"
if not exist "%TargetBase%\FHCRC\ClickOnceSharedDataDemo" mkdir "%TargetBase%\FHCRC\ClickOnceSharedDataDemo"
CACLS "%TargetBase%\FHCRC\ClickOnceSharedDataDemo" /E /T /C /G "Users":C
xcopy shareddata.sdf "%TargetBase%\FHCRC\ClickOnceSharedDataDemo\"
if not exist "%TargetBase%\FHCRC\ClickOnceSharedDataDemo\shareddata.sdf" PAUSE
if not exist "%TargetBase%\FHCRC\ClickOnceSharedDataDemo\shareddata.sdf" exit /B -1
:EXIT
PAUSE
exit /B 0
Thanks,
David
Well, I am not altogether happy with this solution, but it works. I now have two prerequisites. the first is just the command file which runs the CACLS commands to set permissions. It is basically a shortened version of the above:
REM Modify this file to reflect your manufacturer name [Manufacturer] and product name [ProductName].
SET TargetBase=%ALLUSERSPROFILE%
IF NOT "%TargetBase%"=="C:\ProgramData" SET TargetBase=%ALLUSERSPROFILE%\Application Data
REM We only want to do this copy for the first user!
if exist "%TargetBase%\Manufacturer\ProductName\shareddata.sdf" GOTO EXIT
if not exist "%TargetBase%\Manufacturer" mkdir "%TargetBase%\Manufacturer"
if not exist "%TargetBase%\Manufacturer\ProductName" mkdir "%TargetBase%\Manufacturer\ProductName"
CACLS "%TargetBase%\Manufacturer\ProductName" /E /T /C /G "Users":C
:EXIT
ECHO exit /B 0
The second prerequisite is an "all users = true" setup project which has a custom folder located at default location:
"[CommonAppDataFolder][Manufacturer][ProductName]".
Into this folder I put the sdf file.
Finally, I used Bootstrapper Manifest Generator to make packages for both, making the second dependent on the first. I copied the packages to the appropriate VS2010 directory, included them as prerequisites, and published.
I now have per-machine .sdf files published to both WinXP and Win7. Why does this have to be so difficult!?!?
I'm still looking for less complicated solutions, that will install to both Windows 7 and Windows XP.
Did you try MSDeploy? It is able to fulfil all your needs.
Cheers!
You could just include the .sdf file with the ClickOnce application, then have your program copy it to somewhere else the first time it runs. I never recommend keeping the data in the CLickOnce cache anyway, it's safer to handle it yourself. See if this article helps at all:
http://robindotnet.wordpress.com/2009/08/19/where-do-i-put-my-data-to-keep-it-safe-from-clickonce-updates/

Resources