Batch file to send files through ip - batch-file

im new with .bat files.
Im trying to create a .bat file that backups files from a PC to a server PC that is not in the same network.
In this case, i can connect to the server pc with my home pc with remote desktop (got the IP, domani username and password), and i want to make a batch file that sends files from my house pc, to the server pc in my job.
Is there any type of way to send them?
This is what i tried so far:
PROGRAM 1:
copy C:\FROM_HERE \\xxx.xxx.xxx.xx\C:\TO_HERE
net use \\xxx.xxx.xxx.xx\C:\TO_HERE /user:username password
robocopy \xxx.xxx.xxx.xx\C:\TO_HERE C:\FROM_HERE
net use /delete
pause
This program says that the route cannot be found.
I dont know, any suggestion please?

Related

How to map drive as system account via batch file

I need to map a network drive as a the local system account on a server, I can achieve this fine by running psexec -I -s cmd.exe then the net use command
My issue is the drive disconnects on reboot, even with persistent set to /p:yes
I’ve been trying to create a batch file that will run at startup that will run cmd via psexec, and then execute the net use command.
I can get to this point where cmd runs but I can’t get the next part of the command for net use to appear in the new cmd window.
Has anyone got any ideas/a better way of doing this altogether?
As a side note, the network share requires separate credentials to connect to it so it has to be mapped in such a way that credentials can be specified.
Have you tried saving the file as a .cmd file type and placing it in the shell:startup folder? It will run automatically every time you log in to the pc.

Copying a file using a batch file from a RemoteDesktop using the static ip username and password

I would like to create a bat. file on my computer who is connected to another computer using nothing but a switch, there is no server.
the remote desktop has a static ip a username and a password which are known to me.
I saw and used this code in the bat. file on my computer:
net use "\172.17.0.27" typePassword /user:domain\typeUsername
XCOPY "\172.17.0.27\C$\Reports\" "C:\Trades_Backup" /y /d
it did not work did not copy any files

Using FTP.exe to get unknown contents from a directory [duplicate]

I want to create a batch file in Windows Server, including the following functions:
Connection to a FTP server
Copying the files from there (directory called "out") to a local directory
if success, then deleting the files from the FTP server
repeating those steps every 15 minutes
I haven't done that much with batch files so far, so it would be great if you could help me. I know there is the ftp command, and I know how to connect (ftp open), but unfortunately I don't know how to copy those files from there every 15 minutes.
Thanks a lot for your help!
To program ftp from a batch file, see http://support.microsoft.com/kb/96269. You need to call ftp like this
ftp -i -s:ftpcommands.txt
where ftpcommands.txt looks something like this:
open ftp.myftpsite.com
username
password
bin
cd out
mget *
del *
bye
For running this every 15 minutes, see other replies (at or Command Scheduler).
(The -i parameter is to turn off interactive prompting - the other way to do this is to add a prompt off command to the commands text file before the mget. Without this, mget will stop and ask you to confirm before getting each file. [Thanks to Adriano for pointing this out!])
The accepted answer by #AAT suggests using Windows built-in ftp.exe command-line client. While that can work, more often it won't, because this client does support FTP active mode only, which does not play nicely with today's ubiquitous firewalls and NATs. It also does not support encrypted FTPS (FTP over TLS/SSL).
If you have a problem with the above, you need to use a 3rd party FTP client. Most of them do support both the passive mode and encryption.
For example with WinSCP FTP client, you can use the following batch file (.bat):
WinSCP.com /command ^
"open ftp://username:password#ftp.example.com/" ^
"get /out/* c:\local\path\" ^
"exit"
In case you already have an ftp.exe script, there's a guide for converting it to WinSCP script.
For the scheduling part, see the guide to scheduling transfers to FTP server.
(I'm the author of WinSCP)
Windows has the at utility as well as the Windows task scheduler. Either one can run your program at a specified interval.
Using only one (1) .bat file script. Create the FTP script in a temporary file, run it, then delete the temporary file.
SET "FTPFILE=%TEMP%\myftpscript_%RANDOM%.txt"
ECHO>>"%FTPFILE%" open ftp.myftpsite.com
ECHO>>"%FTPFILE%" username
ECHO>>"%FTPFILE%" password
ECHO>>"%FTPFILE%" bin
ECHO>>"%FTPFILE%" cd out
ECHO>>"%FTPFILE%" mget *
ECHO>>"%FTPFILE%" del *
ECHO>>"%FTPFILE%" bye
ftp -i -s:"%FTPFILE%"
IF EXIST "%FTPFILE%" (DEL "%FTPFILE%")
EXIT /B 0

batch file to automatically connect to vpn connection

I need some help with batch file. I am using windows 7.
I need a batch file to:
Open VPN Client on my PC, path is
("C:\Program Files (x86)\Cisco Systems\VPN Client\vpngui.exe)
There are 5 VPNs in the list. Connect to vpn name (AA_VPN) using my username and password
A window pop ups when I connect - that is 'continue or discontinue'
3. The process should press 'continue' button or spacebar key (all works)
And then the batch file should close itself.
Thanks.
From documentation:
"C:\Program Files (x86)\Cisco Systems\VPN Client\vpnclient" connect AA_VPN user <yourUser> pwd <yourPassword>

Getting back a file sent from remote PC using BATCH with PsExec C#

I am coding a program in C# to communicate with a remote PC in an Wifi AdHoc network. I execute a BATCH file in the remote that will send to the local a CHECK.txt file. I use PsExec.
Everything works fine in my C# program when I execute this batch file remotely with PsExec from the local PC to copy the CHECK.txt file in any of the remote's directories. The problem comes when I modify this BATCH to copy the text file to the LOCAL:
copy C:\Windows\CHECK.txt \\192.168.1.10\C$\Windows
It seems that the process PsExec, used to execute the BATCH in remote, blocks the communication of the network when the BATCH tries to send back to the local the text file. Ports 445 and 139 problem? Any idea of what is blocking the file to be sent back?
Everything is set for a transparent dialog between remote and local (no firewall, etc).
Thanks in advance...
I just noticed the -s parameter on your PSEXEC command. The -s means Run the remote process in the System account.. Removing it should allow your batch script to write back to local computer.

Resources