Website Backup Script Button Event

Scooby_Doo

Executive Member
Joined
Sep 4, 2005
Messages
9,081
Ok, i'm pretty new at all this website building stuff but hear me out.

I need to create a button that a user on the clientside can click that will copy a directory on the server to another file path.

So

User clicks button on website ----> Script runs server side ----> data in directory C:\test ----> copied to C:\test2 on the server.

I am using VS2008 with microsoft source safe so just need to copy the database from my working folder somewhere else with a log.

I have a vbscript that will do all the copying and works when i manually run it on the desktop but i need a button on a web page to run this on the server (in this case which ever PC is running the website in VS2008).

I am trying to use this code


protected void BackupButton_Click(object sender, EventArgs e)
{
//Process.Start("~/Vandelay_WFMS/Scripts/Backup.vbs");
System.Diagnostics.Process.Start("cscript ..\\Scripts\\Backup.vbs");
Response.Redirect("AdminHomePage");
}

But i get cannot find file error.

Now either

1 i have not called the file up correctly
2 there is a problem with this trying to run on the client side when it should run server side.
3 #1 is true but i will get an error such as #2 after i fix the file path error.


Any suggestions

:)


PS Am coding in c#
 

FarligOpptreden

Executive Member
Joined
Mar 5, 2007
Messages
5,396
Server.MapPath is your best friend in the world of relative URLs in the web-server environment... ;)
 

Scooby_Doo

Executive Member
Joined
Sep 4, 2005
Messages
9,081
protected void BackupButton_Click(object sender, EventArgs e)
{
String FilePath;
FilePath = Server.MapPath("../Scripts/backup.vbs");
System.Diagnostics.Process.Start(FilePath);

}

Yay and it works :)

Thanks Farlig
 
Top