Copying Files

  • Thread starter Thread starter Jim in Arizona
  • Start date Start date
J

Jim in Arizona

Is it possible to copy a file from one location to the desktop of the
user on the local lan? The webserver is IIS6, and all users are active
directory accounts. I realize that its a security risk to do such
things, but it would be ok in our given environment. I can't think of a
simple way to do it.

I was thinking of something similar to this:

Protected Sub btnPlaceIcon_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnPlaceIcon.Click

IO.File.Copy("\\server1\share\Finance.mdb",
"%USERPROFILE%\Desktop\DataTest.mdb", True)

End Sub

This doesn't work because of the %userprofile%, but if I make it the C
drive, like this

IO.File.Copy("\\server1\share\Finance.mdb", "c:\DataTest.mdb", True)

then it just copies the file to the web server's C drive, of course.


The other option would be for them to click a link, which is anchored to
a batch file or vb script file, which they can then run. I have several
links that do that already so I was hoping to do this a little
differently, with less 'clicks'.

Any ideas, anyone?

TIA,
Jim
 
Jim said:
Is it possible to copy a file from one location to the desktop of the
user on the local lan? The webserver is IIS6, and all users are active
directory accounts. I realize that its a security risk to do such
things, but it would be ok in our given environment. I can't think of a
simple way to do it.

I was thinking of something similar to this:

Protected Sub btnPlaceIcon_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnPlaceIcon.Click

IO.File.Copy("\\server1\share\Finance.mdb",
"%USERPROFILE%\Desktop\DataTest.mdb", True)

End Sub

This doesn't work because of the %userprofile%, but if I make it the C
drive, like this

IO.File.Copy("\\server1\share\Finance.mdb", "c:\DataTest.mdb", True)

then it just copies the file to the web server's C drive, of course.


The other option would be for them to click a link, which is anchored to
a batch file or vb script file, which they can then run. I have several
links that do that already so I was hoping to do this a little
differently, with less 'clicks'.

Any ideas, anyone?

TIA,
Jim


I tried this:

Protected Sub btnPlaceIcon_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnPlaceIcon.Click

Dim pcname As String
pcname = Request.ServerVariables("REMOTE_HOST")

IO.File.Copy("\\server1\share\P8200811.jpg",
"\\pcname\%USERPROFILE%\Desktop\testimage.jpg", True)

End Sub

And it would have probably worked if it weren't for a permissions issue.
I'm assuming this is because the ASP.NET account doesn't have read/write
permissions on the server/client.

Would there be a way to specify credentials when doing this file copy
method, or could the credentials of the person accessing the webpage be
used since everyone is logged on via Active Directory?
 
Maybe impersonation would work in this instance (along with Integrated
Windows Authentication on the web server)?

I don't think %USERPROFILE% is going to work in this instance either.

What is the reasoning behind this? Maybe there's a better way to solve your
problem?
 
Brendan said:
Maybe impersonation would work in this instance (along with Integrated
Windows Authentication on the web server)?

I don't think %USERPROFILE% is going to work in this instance either.

What is the reasoning behind this? Maybe there's a better way to solve your
problem?


The main reason is app (in this case, access database front end)
deployment. On our internal website, we have a page that employees can
go to with links that, when clicked, run a batch file that copies down a
front end of an access database from a server to their desktop. All they
do is click 'run' when prompted after they click the link.

In this case I was trying to create a little security on who could get
the front end of this database (easily) with a simple passcode .. ie:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

If Page.IsPostBack Then
If txtAccessCode.Text = "456" Then
lblInvalidCode.Visible = False
pnlAccess.Visible = False
pnlAuthorized.Visible = True

Else
lblInvalidCode.Visible = True
End If
Else
pnlAccess.Visible = True
lblInvalidCode.Visible = False
pnlAuthorized.Visible = False

End If
End Sub

Just something simple but effective enough for our purposes. Within the
pnlAuthorized panel is a button, that when clicked, would run the code
to copy the access database file from server to their desktop.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top