Copy a non-shared file on a local network with a windows command - windows

I'm using Windows 8.
How can I copy a non-shared file from another pc on my home network (another IP)?
This command can copy files, but only shared files:
copy \\{ip address}\Downloads\example C:\example_folder
copy (where and what) to (here)
I'd like something like this. But I don't know how can I copy a non-shared File? Is there a simple windows command I can run to do this?

You could try mapping a drive first and then doing the copy, then deleting the mapping. e.g.
net use x: \\computer name\share name
copy x:\Downloads\example C:\example_folder
....
net use x: /delete
where x: is the drive letter to map to locally.
If you don't have a share name, you could use the drive letter in the format of c$ for the c: drive on the remote machine or d$ for d: e.g.
net use x: \\computer name\c$
You will probably need to have a login for the remote machine. If you do, do the following.
net use x: \\computer-name\share-name password /user:username
I can't test this at the moment as I'm on my Linux machine, but give it a go as a guide.
See http://support.microsoft.com/kb/308582 for more details on mapping the drive

Related

Copy File to Another Server Using Batch File [duplicate]

I have a bat file copying files from current machine to mapped network drive (one line, xcopy command).
It works when I RDP to server. However, when I run as a scheduled task, and configure it to run under the same user I'm logged in, it doesn't work and give error 0x4.
Is there a way I can achieve this?
I also try dsynchronize and it works when I click synchronized. When I run it as service same issue.
I was able to figure it out. Following batch files works under scheduler, even as local system account:
net use m: \\server\share /U:server\user password
xcopy C:\source m: /E /Y
It maps a network drive every time and then copy to that drive
It's possible to copy files to a UNC path without mapping as a network drive.
Just try to set the UNC path in quotes.
copy * "\\server\share"
Without the quotes, i got a "syntax error" running on Windows7 command line.
I had similar issue where I wanted to copy file(s) from a server to hundreds of other servers without mapping a remote drive to my local PC. I didn't have enough drive letters to map hundreds of remote machines to my local PC! I couldn't just map the remote drive and copy.
I thought I could use copy, xcopy, or robocopy, and specify my creds to the copy command. But none of the copy commands had any options to provide credentials to remote system.
Thanks to the post above, I was able to create a small batch file where I just loop through my hosts, and keep re-using just one drive mapping for all my hosts.
Here is my batch file...
echo #off
for /F %%j in (pchostslist1.txt) do (
net use z:\\%%j\c$ /user:domain\myusername mypassword
mkdir \\%%j\c$\tmp\mynewdir
xcopy c:\anyfile.txt \\%%j\c$\tmp\mynewdir
net use z: /delete
)
I had a similar issue and instead of using net use I simply needed to store the password as part of the scheduled task. You'll notice that it says it only has access to local resources if it's ticked.
Who maps the network drive? And are you using the mapped name, instead of the underlying UNC native path? Because it sounds like the mapped drive is setup in your login script, which doesn't run if you're not logged in. So, in a scheduled task, you do have the correct credentials for the UNC path, but no mapped drive letter.

Is there a way in Windows 10 to create a virtual link from an UNEXISTING file to an existing one?

I'm using Windows 10 on a device that has only one SSD formatted with NFTS, the drive letter is C:\
I have an application that looks for a file located in D:\afolder\needed.file (I can't change this)
Is there a way to put the file needed.file in C:\ and create a virtual link so that this application thinks is working on D:\afolder\needed.file but transparently the OS is redirecting it to the file located in C: ?
I tried with the command
mklink /H D:\afolder\needed.file C:\needed.file
but I receive the error
Local NTFS volumes are required to complete the operation.
Maybe it is because the drive D: doesn't exist at all on the device?
Is there a way to make it work?
NOTE: The SSD of the device is formatted with NTFS and I run the command mklink with admin privileges

Lua io.popen() - Accessing Shared Drive on Windows

I am running a Lua program on a Windows 10 machine. This Windows 10 computer is networked to another Windows 10 computer and this other computer is sharing its D: drive with my computer. The shared drive is called the O: drive by my computer.
When I open a cmd window on my computer and type:
type "O:\Data\config\file.xml"
I get the contents of file.xml in my cmd window. However, if I run this same command through Lua:
f = io.popen([["type O:\Data\config\file.xml"]])
output = f:read("*l")
Then output returns as nil.
This behavior is true of any command involving the shared O: drive, not just type. Similarly, I have some bat scripts that reference the O: drive, and I call these using os.execute, but they are not able to accomplish their task (I can see they are actually executing, just not correctly). However, if I run similar commands or scripts with the local D: or C: drives, I do not have this issue.
Any ideas as to what could be different between these two calls? Is there a different way I can call the O: drive?
My Lua application was running as a service, and I determined that when it was running as a service it was running as a 'guest' user, rather than my system user. Therefore, it did not have the appropriate permissions to run.
I modified my Windows service to run as my specific user, and this resolved the issue.

How to sync 2 directory content on 2 different computer during file change only

Lets say I have PC A(with folder C:\PCA) and PC B (with folder C:\PCB)
first i do a WNetAddConnection2 to map PCB folder on PC A with S drive letter
followed by a copy command cmd.exe /C copy S:*.* C:\PCA\ /Y
but this will be just copy all files in PCB to PCA everytime i call it
I'm looking for a way to Sync PCA and PCB (One way is ok) and the process should copy only files with changes(to save bandwidth).
This type of action could be performed on Linux with a tool called rsync
Maybe try take a look at this answer:
https://superuser.com/questions/69514/windows-alternative-to-rsync
for some Windows alternatives.

Can't copy files to UNC Destinations if BAT file is called via scheduled task

I have a bat file copying files from current machine to mapped network drive (one line, xcopy command).
It works when I RDP to server. However, when I run as a scheduled task, and configure it to run under the same user I'm logged in, it doesn't work and give error 0x4.
Is there a way I can achieve this?
I also try dsynchronize and it works when I click synchronized. When I run it as service same issue.
I was able to figure it out. Following batch files works under scheduler, even as local system account:
net use m: \\server\share /U:server\user password
xcopy C:\source m: /E /Y
It maps a network drive every time and then copy to that drive
It's possible to copy files to a UNC path without mapping as a network drive.
Just try to set the UNC path in quotes.
copy * "\\server\share"
Without the quotes, i got a "syntax error" running on Windows7 command line.
I had similar issue where I wanted to copy file(s) from a server to hundreds of other servers without mapping a remote drive to my local PC. I didn't have enough drive letters to map hundreds of remote machines to my local PC! I couldn't just map the remote drive and copy.
I thought I could use copy, xcopy, or robocopy, and specify my creds to the copy command. But none of the copy commands had any options to provide credentials to remote system.
Thanks to the post above, I was able to create a small batch file where I just loop through my hosts, and keep re-using just one drive mapping for all my hosts.
Here is my batch file...
echo #off
for /F %%j in (pchostslist1.txt) do (
net use z:\\%%j\c$ /user:domain\myusername mypassword
mkdir \\%%j\c$\tmp\mynewdir
xcopy c:\anyfile.txt \\%%j\c$\tmp\mynewdir
net use z: /delete
)
I had a similar issue and instead of using net use I simply needed to store the password as part of the scheduled task. You'll notice that it says it only has access to local resources if it's ticked.
Who maps the network drive? And are you using the mapped name, instead of the underlying UNC native path? Because it sounds like the mapped drive is setup in your login script, which doesn't run if you're not logged in. So, in a scheduled task, you do have the correct credentials for the UNC path, but no mapped drive letter.

Resources