Copy files and folders using robocopy - robocopy

I need to copy directory from a server to the Program Files folder on desktop using local admin. This is what I have so far.
robocopy "server source" "C:\Program Files\Test" /MIR
I get the follwoing error
2014/05/23 17:53:04 ERROR 5 (0x00000005) Creating Destination Directory C:\Program Files\Test\
Access is denied.
I'm running the bat on logon via GPO.
Can someone please help me?
Thanks.

I changed the location to %appdata% from program files.

Related

Powershell script to delete temp files in a specified folder and then create logging in a seperate folder

Can someone please help me with Powershell script.
The task is to delete temp files in a specified folder and then create logging in a seperate folder.
Also, the windows batch file (.bat) I add my code always prompts, "Are you sure (Y/N)?". How can I disable this? And there is no log file being created in the end.
Thanks in advance!
Bobby
I tried this script.
Del C:\Users\redla\Downloads\C_drive*. -recurse -force; Start-Transcript -Append C:\Users\redla\Downloads\test\Log.txt*
It works fine in Powershell but when I add it to a .bat file, it works with the deletion part but doesn't create the log file in my specified folder.

Powershell - Unable to create directory in Program Files and specify install path

I am trying to write a simple script but I am running into trouble when I try to create a directory in "C:\Program Files".
New-Item -Path "C:\Program Files\JHA" -ItemType Directory
When I do this, no directory is created. No error is thrown. I have admin privileges on my computer. Any advice?
Also, in this script I would like to run an installer and specify this path I created above as the directory it installs to. Is that possible? I read one post where the person was using IMAGEDIR= but someone said Powershell doesn't allow you to specify the installation folder.
Thanks for any help.

Robocopy - ERROR 124 (0x0000007C) Creating Destination Directory

Hoping someone familiar with Windows 10 and Robocopy can help.
I am using the following robocopy command in backup script that is being run as Administrator (yes the real Administrator user ID)
runas /user:Administrator backup.bat
robocopy N:\FNL E:\FNL /MIR /E /Z /R:1 /W:1 /V /NP /LOG+:backup.log
As long as there have been no new files for directories created in the source folder, in this case N:\FNL it seems to run fine. As soon as I create a directory, for example "Fred", I get the following error:
ERROR 124 (0x0000007C) Creating Destination Directory N:\FNL\Fred
The system call level is not correct.
I have changed file permission for "Authenticated Users" to Full Control and as well have taken ownership of all folders and sub-folders/child objects on the target drive but still get the same error.
Anyone have an idea what I might be doing wrong?

Powershell Copy-Item - Access Denied

I'm writing a script that will open files in a directory and perform a find/replace. But before I do that I would like to make copies of the files in the same directory as the original file. All files exist in the C:\Program Files (x86) directory. The script errors out stating that access to the directory is denied. I see that Copy-Item has a -Credential parameter, but on my test machine I don't have any local Administrator permissions. Doesn't seem like there is going to be any way to copy the file to the same directory. Can I specify the system's temp folder (Windows 7 Professional) and just write it there? I'd like to find a way to copy the file to the same directory as the source file, however.
Windows Vista and above default to not allowing non-administrative users to write to the `%PROGRAMFILES% folder. This means that you're not going to be allowed to copy the files there; you're also not going to be able to save them after doing your find/replace operation.
You can write them to your user documents folder (%USERPROFILE%\Documents) folder instead, if that will work for you.

please give the command in Robocopy i should use to copy the files from primary server to the secondary server

I got the command in robocopy as mentioned below
ROBOCOPY Source Destination [file…[file]…..] [Options]
Source: Source Directory
Destination: Destination Directory
Files: files to copy .
Please let us know what does the "\server\share\path" means? Kindly provide me an example on this command syntax and explain
An example of a ROBOCOPY call would be
ROBOCOPY C:\Users \\SERVER\backup\Users /MIR /R:0 /W:0
This copys everything under C:\Users to a network share at the UNC path \\SERVER\backup. If you don't know, what that means, google for 'UNC path' or find a nice tutorial that explains how to setup network shares under Windows.
Instead of \\SERVER\backup, that copies to a remote machine, you are totally free to use something like H:\ to copy to a local drive like a USB mass storage device.
The part /MIR /R:0 /W:0 are options of ROBOCOPY. Call ROBOCOPY /? to get an explanation for these.
Cheers,