Hi,
I just tried this and should ideally work for you as well.
Step1:
Create a local user with the SAME credentials (login/password) that you use
you login to your server in DMZ.
AND make this user part of local Administrator group.
Step2:
Create the ConsoleApplication1.exe using the code below:
using System;
using System.IO;
using System.Diagnostics;
namespace ConsoleApplication1
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
string path = @"c:\temp\MyTest.txt";
string path2 = @"\\[Put Destination IP here]\c$\TEMP\MyTest.txt";//<-[Put
Destination IP here]
try
{
// Create the file and clean up handles.
using (FileStream fs = File.Create(path)) {}
// Ensure that the target does not exist.
File.Delete(path2);
// Copy the file.
File.Copy(path, path2);
Console.WriteLine("{0} copied to {1}", path, path2);
// Try copy the file, which should succeed.
File.Copy(path, path2, true);
EventLog.WriteEntry("FileCopyOverDMZ-Scheduled Task","Successfully
Copied!!!", EventLogEntryType.Warning);
}
catch (Exception e)
{
EventLog.WriteEntry("FileCopyOverDMZ-Scheduled Task",e.Message,
EventLogEntryType.Error);
}
}
}
}
Step3:
Now create a scheduled task and provide the credentials for the local user
that was created in Step1.
This enables the application to copy the files as it would impersonate the
administrator role of the server in DMZ.
Could you please give a try and let me know the outcome(from the Event
Logs)?
Hope this helps!
Thanks-