Link to home
Start Free TrialLog in
Avatar of MaxwellTurner
MaxwellTurnerFlag for Canada

asked on

Transfering files via Remote Desktop Connection as a scheduled task

My company has a Coldfusion website, hosted by a local ISP, and each night I have a Windows Scheduled Task that uploads (ftp) the website's Access data source.  

Recently, we purchased our own IBM webserver (using Server 2003, Coldfusion MX 6.1), but It is still located at our ISP's offices (for security reasons).  I am told that now rather than FTPing my data source, I must use Windows Remote Desktop Connection (terminal services) to connect to the web server.  I have the connection established - I log on with a u-name & p-word - then the server's desktop is displayed & I can transfer files from my local conmputer to the server.

I need to make my new situation an automatic process that also occurs at night - that is, my data source gets transfered to my remote web server each night.  I am told by a contact at my ISP that this could be very difficult to set a Scheduled Task to log onto my remote web server, transfer the files, then log off.

I have absolutely no idea where to start!  First, is this even possible?  Can someone point me in the correct direction as to what I need to know/learn to be able to accomplish this process?  Can I accomplish this using VB?

Any help/input would be greatly appreciated.


Avatar of AmazingTech

So when you remote desktop to your server you make a connection back to your workstation using \\workstation\c$ to transfer the contents from your workstation to the server?

Why not create the scheduled task on the server to get the files from your workstation every night?

So using a batch file with a coldfusionshare created on your workstation.

XCOPY /S /Y \\Workstation\coldfusionshare\*.* E:\Webserver\*.*

Avatar of MaxwellTurner


>>So when you remote desktop to your server you make a connection back to your workstation using \\workstation\c$ to transfer the contents from your workstation to the server?

- Not quite sure what you mean by "connection back to my workstation using \\workstation\c$".  I am fairly new to this whole remote desktop thing, so I can only describe what I do in "laymans" terms!  

Basically, I have a link(icon) to the remote web server on my workstation desktop that my ISP helped me set up.  I double-click it and then I am prompted for the remote web server's U-Name & P-Word - I enter them, then I click connect & then I see the server's desktop.  When I go to the remote web server's Windows Explorer, I can see all of my workstations local drives, as well as the web server's drives.  Yeah, you are right, once I am connected, I could use a batch file to simply move the data source from one drive to the other - I should have thought of that!!!  

I guess my main challenge here is AUTOMATICALLY logging onto the remote web server with the Uname and Pword - can I do this using a batch file somehow?  I have done a few things with batch files - mostly ftp related, but viewing your XCOPY syntax above, it looks fairly simple to copy files using batch.  What do /S & /Y represent?

Simple. You do not need to Automatically logon to the remote web server.

When you setup your scheduled task you can supply the credentials U-Name & P-Word to run the scheduled task under (Username and Password you use to logon to the remote webserver should work). This way there is no need for a user to logged in on the web server when your task runs.

XCOPY parameters /s means to copy subfolders.
/y confirms overwritting existing files.
Other parameter to be helpful is /d copies only changed files between source and destination.


Copies files and directory trees.

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
                           [/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
                           [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]

  source       Specifies the file(s) to copy.
  destination  Specifies the location and/or name of new files.
  /A           Copies only files with the archive attribute set,
               doesn't change the attribute.
  /M           Copies only files with the archive attribute set,
               turns off the archive attribute.
  /D:m-d-y     Copies files changed on or after the specified date.
               If no date is given, copies only those files whose
               source time is newer than the destination time.
               Specifies a list of files containing strings.  Each string
               should be in a separate line in the files.  When any of the
               strings match any part of the absolute path of the file to be
               copied, that file will be excluded from being copied.  For
               example, specifying a string like \obj\ or .obj will exclude
               all files underneath the directory obj or all files with the
               .obj extension respectively.
  /P           Prompts you before creating each destination file.
  /S           Copies directories and subdirectories except empty ones.
  /E           Copies directories and subdirectories, including empty ones.
               Same as /S /E. May be used to modify /T.
  /V           Verifies each new file.
  /W           Prompts you to press a key before copying.
  /C           Continues copying even if errors occur.
  /I           If destination does not exist and copying more than one file,
               assumes that destination must be a directory.
  /Q           Does not display file names while copying.
  /F           Displays full source and destination file names while copying.
  /L           Displays files that would be copied.
  /G           Allows the copying of encrypted files to destination that does
               not support encryption.
  /H           Copies hidden and system files also.
  /R           Overwrites read-only files.
  /T           Creates directory structure, but does not copy files. Does not
               include empty directories or subdirectories. /T /E includes
               empty directories and subdirectories.
  /U           Copies only files that already exist in destination.
  /K           Copies attributes. Normal Xcopy will reset read-only attributes.
  /N           Copies using the generated short names.
  /O           Copies file ownership and ACL information.
  /X           Copies file audit settings (implies /O).
  /Y           Suppresses prompting to confirm you want to overwrite an
               existing destination file.
  /-Y          Causes prompting to confirm you want to overwrite an
               existing destination file.
  /Z           Copies networked files in restartable mode.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.
Cool, thanks for all the switches & descriptions - that will help me out big time.

Okay, as for logging onto the Web Server:  If I understand you correctly, it is as simple as setting up a Scheduled Task that opens the Remote Desktop icon that I have on my desktop, and in the scheduler, I should use the same U&P that I use to log onto the Web Server.

This is what I tried:
My current workstation account's U&P are different than the web server's, so when I tried to create the Scheduled Task, changing the U&P to match the Web Server's U&P, I got an error and couldn't apply the changes - I guess it would not allow me to use a U&P that didn't match one of the accounts already on the workstation.  So, I then created a new account on my workstation with the same U&P as the Web Server's.  I then tried running the scheduled task, but the Web Server's login screen still pops up - now it has the Username already filled in, but prompts for a Password.

I need it to NOT STOP at the Web Server's login screen, but rather go right to it's desktop.

Oh, wait a second.  I think I just realized what you are saying.  

I don't actually have to log into the server & see it's desktop - by using the Web Server's U&P in the scheduler, I should have access to the Web Server's drives, even though I don't see it's desktop.  So all I really need to do in the Scheduled Task is run my batch file that will transfer the files. (& I guess I would have to know what to call the drives)

Can U explain this a little further:

\\Workstation\coldfusionshare\*.* - does this mean the ALL FILES in the COLDFUSIONSHARE folder on the local workstaion?
E:\Webserver\*.* - Is this the local drive on the Web Server?

Sorry, if I seem a little slow . . . it's alot to grasp whn you only know a little bit about this stuff.

Your last email is correct.

Your remote desktop is only used for administering not for the automated copying.

You mentioned that on the remote web server's windows explorer you can see all your workstations drives.

Uh oh, hold on when you made your remote desktop connection did you go into Options - Local Resources
Under Local devices do you have the Disk drives checked?

If you do then these drives are only available when you are remotely connected.

The schedule tasks will not work because you won't be remotely connected at the time of transfer.

So does the windows explorer drive letters look like this?

C on WorkstationName
>>The schedule tasks will not work because you won't be remotely connected at the time of transfer.

That is my problem - I assumed that I actually had to be logged onto the server, then copy the files over, then log off - apparently I was wrong!!

Yes, I was told to check DISK DRIVES & PRINTERS, and yes my workstation drives look like 'C on WorkstationName'.

I don't quite understand this though - I thought that the DRIVES setting was attached to the RDC icon (after I set it up, I saved it to the desktop) & it applied these settings as I connected to the server.  If I don't double-click the icon and just use the Task Scheduler, how does the Server that I want to see my local workstation drives?  Couldn't I just create a second RDC connection icon that has DRIVES unchecked?

Hope that made sense.

There are certain problems here.

1. Your connection to your ISP probably does not allow MS File Sharing so you cannot use this in a Scheduled Task to connect back to your machine without logging on. Simply won't work ISP firewall and potentially your company firewall.

2. What is allowed is RDP through your firewalls since you can make the connection.  With/through the use of RDP you get access to your local workstation drives at the server.

Will need to test some things but this may still be doable.

Here are the new proposed steps and challenges to making this work.

1. Created your RDP connection including saving the username and password. So in Remote Desktop Connection go into options and check save my password.

Under connection settings click save as and save it somewhere you know the full local path.  So something like C:\WEBSERVER.RDP

Let's test the connection and make sure you automatically get to the desktop on the server.

This is the command to start Remote Desktop with the connection settings you just saved.

%windir%\system32\mstsc c:\WEBSERVER.RDP

Did you get the desktop? Hope so. Next step.

2. Open RDP again and back to options - Programs tab.  We need to run a program or batch file now on the web server once you're connected. Check the Start the following program on connection. Fill in the program path and file name (probably the XCOPY commands in previous messages may work.) I haven't had the time to figure out if the webserver will reference your local workstation C: as \\workstation\c$ or \\workstation\c or is not available using UNC.  As a test you might want to put a CMD file on the webserver as a test.  Something like TEST.CMD with a PAUSE in it.

If the CMD works then the only thing left to do is to log off or disconnect when the transfer is done.

3. Disconnect RDP. How? Need some log off program.  Maybe included with Server 2003. Let me hunt around.

I will also give these things a try when I find a spare moment.

Excellent!  You are indeed an AmazingTech!!

Last night I created another RDC and actually saw that I could enter the U&P and have it remember the Password.  I saved it & double-clicked and it opened the Server desktop this time without prompting for a Password - I feel a little foolish that I never noticed that before.  The only problem I can think of is perhaps a security issue, but if I save the RDC connection somewhere deep into one of my workstation's drives, I don't think anyone will find it.  I will check with my ISP/Network guy to see if he sees a problem with that - he specifically told me not to enter that info when he helped my set up my original connection.

I searched Google quickly and found a forum that suggested that SHUTDOWN.EXE be used - I don't think that this will end that session - I believe that I actually have to LOG OFF to end the current session.  That got me thinking though, so I searched my workstation (XP PRO) and found LOGOFF.EXE (found it on the server too - system32/logoff.exe).  When I d-clicked it (on my workstation), it indeed logged me off . . . much to my dismay because I had already typed a couple paragraphs here & lost it all!@$&*.  Anyways what do think about using LOGOFF.EXE as the final line of the batch file?  I didn't try opening the logoff.exe on the server until I was sure it was OK to do that.

If that will work, my last challenge is the syntax of the batch file and the referencing of the drives - I am not sure how to call up the Test.CMD file on the server from my workstation.  To be honest, I am actually not sure how to put a pause in a CMD file. Do I simply create a file in NotePad with the word PAUSE & save it as a .CMD file?

Thanks so very much - you have been incredibly helpful!

Avatar of AmazingTech

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great news!

I tried RDP to a Windows 2003 server it ran the CMD file from C:\TEST.CMD it has access to \\tsclient\c

When the CMD is finished it logs off.
Excellent!  I successfully connected, transferred a test .txt file and logged out - all from opening the RD connection with the U&P saved.

I'll mention what I did, incase someone else searches this thread and wants to know the solution.

I set the paths in the RD connection to the CMD file on the server.  I also created a test TXT file(copytest.txt) which I saved on my workstation's E:\ drive.


XCOPY /s /y /d \\tsclient\e\copytest\copytest.txt D:\CopyTest\

Upon connecting to the server, it goes so fast all I could see was the desktop briefly, the dos screen breifly then I was logged out!  

Thats it!  Now my only concern is the RD connection with the saved U&P - youre right though, my ftp program also had the ftp U&P saved, so it's really not much different now.

Thanks a million once again - I would have NEVER EVER figured this out without your help.  I'd give you an A+ if I could!!

Great to see it worked for you.

One note if you didn't see my previous email you do not need the logoff.exe in the batch file. When the batch file is finished it will logoff automatically.

There is one more part to your question and that is to have it automated. I hope the Scheduled Task works as planned.

PS.  What does your ISP know about Scheduled Task and Remote Desktop Connection anyways? ;)
Don't need the logoff.exe in the batch file?  Really?  Hmmmm - dosen't make sense to me but then that dosen't mean anything!!  I will try it.  

As for the scheduled task, I actually didn't try that yet.  I was simply going to direct it to the Remote Desktop Connection file that I saved - I figured that would be the easy part, but now that I've said that, it probably won't work!  I better give it a try to be sure that there are no probs.  

My contact at my ISP is unfortunately also my company's network consultant - he set up (and maintains) our Novell (piece of crap) network and also set our new web server up.  I say 'unfortunately' because he is very very Anti-Microsft and has bitched about Server 2003 since he started, despite the fact that he was the one to suggest we use it!!??  Go figure.  Me, I love MS even though its quite costly (you get what you pay for) & he can keep his stinkin' Linux & Novell . . . but thats just my opinion :>)

I will set up a scheduled task quick like & let you know what happened.

Well, I currently have my RDC file with the saved U&P, saved to my desktop.  I plan to move it deeper into one of my workstation's drives once I have everything working.  Anyways, I simply used the Scheduled Task wizard, and browsed for the RDC file on my desktop, set up the times to run . . etc.  When I ran the Task, it worked perfectly - without logoff.exe in the batch file I might add - I find that wierd - how does it know I want to log off?

In an earlier comment you mentioned that the path to open the RDC in the Scheduled Tasks (if I saved it to C:\) is:

%windir%\system32\mstsc c:\WEBSERVER.RDP

. . . when I set my task up, the target ended up being:

C:\Documents and Settings\{my username}\Desktop\LVVF_WS02.RDP"

. . . seemed to work, but I see what you have done there & I am wondering if mine is the wrong way to do it, or it dosen't matter either way.  It seems to work fine, but I want to do this properly.

If it works it works. That's the good thing.

I use and MS uses environment variables because each person's installation can be a little bit different.  For example there is no hard rule that the Windows directory must be C:\WINDOWS. For dual boot machines you must select two different windows directory. But what happens when you load up windows it references %systemroot% and %windir% variables to figure out where the windows files are.

I could have said C:\WINDOWS\SYSTEM32\MSTSC but if your windows installation was installed in say C:\WINNT then it would not have worked.

If you go into DOS: START - RUN - CMD

Type in SET

You will see the environment variables that have been setup.

So if you went DIR %WINDIR% no matter what machine you're on you will always get the directory listing of the current windows directory. It won't error if your batch says DIR C:\WINDOWS when your windows installation you chose C:\WINNT instead. It is only meant to be more portable.  Your case there is really nothing different if you hard coded your schedule task to C:\WINDOWS\SYSTEM32\MSTSC

When helping people I like to try and minimize any potential errors. It is not a wrong or a right way.

I see what you have done. Your scheduled task is opening the .RDP file. It is using Windows File Association to run MSTSC.

If you go to Windows Explorer - Tools - Folder Options - File Types

Look for the RDP under extensions. The details says it Opens with Remote Desktop Connection.  Advance - Edit
Under Application used to perform action: mstsc.exe "%l"
So this runs your RDP file with mstsc.exe "C:\Documents and Settings\{my username}\Desktop\LVVF_WS02.RDP"

This will work too and is just fine. Maybe better my command above since you have spaces in the path you would need to put quotes in yourself.

It is not too weird that the you're logged off after the command is finished. When I tested with the PAUSE in the CMD file I noticed that the familiar START button and desktop never appeared. So the shell Explorer which is not to be confused with Windows Explorer but it is the same file is not started.  So without the shell Explorer running your CMD file is the shell. When you double click on your CMD file the black DOS screen comes up and when finished it closes. Because it closes it logs you out.

If you want to go really deep with this. You don't have too for what your doing but when you're sitting at the Logon screen. Explorer.exe is not running. When you logon explorer.exe runs until you logoff.  Now you can run task manager and stop the process explorer.exe but it does not log you off. I think it doesn't log you off this way because the program did not end it was killed. With task manager you can create a new task for explorer.exe and the desktop reappears and reinitializes the desktop.

BTW: I am a Novell administrator for a large hospital. Of course we also have Microsoft and are transistioning to pure Microsoft for collaboration with other hospitals. Both NOS has it's strengths and weeknesses. I don't have strong biases with one over the other and I really don't care as long as my hospital continues to employ me and pay me, I'm happy.

That all makes sense - I now understand the difference between Referencing the directory that holds the windows files vs. Hard-Coding the path(like I did) and I sort of understand what you said about the shell explorer - when the shell explorer normally closes it will log you off.  If my CMD file IS the shell explorer, it make sense then that it logs me off after it closes.  I have learned ALOT going through this process that will help me in other areas.  

I hope I didn't offend you about my Novell comment - it was not necessary to say what I did.  I realize that it (Novell) is a pretty solid network system - I am just tired of my network guy's constant complaining about MS operating systems/networks and it gets to me sometimes - yesterday he was really getting on my nerves & it made me a little angry because it was him who suggested we use Server 2003!!!  I think I am biased more because he has a bad attitude than whether one OS/Network is better than the other, but to be fair, I guess that makes my attitude a little bad as well! :(

You are 100% correct though - As long as my employer(s) continue to pay me and buy the latest servers and software to play with, I will remain happy regardless.  I feel very fortunate that I have the opportunity to learn on-the-job and have very patient employer(s) that give me the chance to try figure stuff like this out. :)

I undoubtably will have more issues while I complete setting up my server - I was told to figure out how to "ghost" the server just incase it becomes compromised by a hacker so we could restore it back & also was asked to find out how to securely "lock" the server down to hopefully help avoid being hacked in the first place.  I don't even know where to start, but when I really get into it and questions arise, I will send a link to this question to my new question to give you the first try at it.  I have to briefly move onto another project for a couple days - my server is set to be public on Feb 1, so I have a little time to get it all worked out.

Thanks again for all your help!

No offence taken by the Novell comment. I do not take sides and don't really care which OS I use.

Ghosting shouldn't be a problem. Especially, when your not replicating it for mass deployment like workstations. For backup purposes it is quick and easy.

Hardening your server. You should take a good hard look at how your ISP consultant setup your webserver in the first place.

Did he use the wizards provided by Server 2003 or did he make manual changes? Did he document the steps he took in installing Server 2003?

There has been a big functional change between Server 2003 and previous Microsoft Server products. Previous servers were configured with no security and relied on the person installing the server to close/deny access to things that were not required. The method was very troublesome for Microsoft since people did not have the knowledge or skill to secure or harden their servers properly. Server 2003 is the opposite. Everything is closed and it's up to you to open what you need. There is the danger of opening too much as well but now Microsoft has put the onus on you.  There are however wizards to help you in opening just what you need.

Good luck in your other projects.

I look forward to seeing your other questions. I'm sure there will be tons of other people responding to your questions with references to tons of links to web pages. I like to work on problems which there are no posted solutions for.