?
Solved

VB.Net - System.IO.File.Move with Elevated Privileges

Posted on 2014-09-05
12
Medium Priority
?
839 Views
Last Modified: 2014-09-10
Good Day Experts!

I have developed a small SA VB.net exe to move files on one of our network paths.  My searches on the net have been inconclusive.  

It works fine when I execute it from my machine as I have Administrator privileges.  However, when I put it on the User machine it does not work due to lack of permissions.

How can I elevate the privileges of the User in the code to be able to execute System.IO.File.Move?

Thanks,
jimbo99999
0
Comment
Question by:Jimbo99999
  • 6
  • 4
  • 2
12 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40307472
0
 
LVL 84

Expert Comment

by:David Johnson, CD, MVP
ID: 40307625
the user doesn't have permission from the source or the destination directory?
0
 

Author Comment

by:Jimbo99999
ID: 40308514
Good Day Everyone

Yes, you are correct...unfortunately due to new rule standards the User does not have permission on the source or destination directory.  So, I have been given the task to figure out how to give the User the permissions in my little VB.Net application.  

Eric, thank you for the link reference...I will take a look here today.

Thanks,
jimbo99999
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 84

Expert Comment

by:David Johnson, CD, MVP
ID: 40308538
Isn't this breaking company policy if the user doesn't have access then they should not have programmatic access as well?   Only a user with the proper access should be able to move the file.
0
 

Author Comment

by:Jimbo99999
ID: 40310302
Eric:

I tried the impersonation link information here this morning.  Unfortunately I am having a bit of trouble.  
My little app is a a windows Form that I load a listview with file to move in a directory. After the User selects the files to move they have to hit a button to execute the move.   The trouble I am having is embedding the Impersonation code into the code behind the button.  

Is there by chance any references the use Impersonation in a Windows form type application?

Thanks,
jimbo99999
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40310579
I found yet another example using a Windows Forms application: http://support.microsoft.com/kb/841699/en-us
0
 

Author Comment

by:Jimbo99999
ID: 40310653
Thank you kindly Eric...I appreciate the reference.  I will try this out today.

Thanks,
jimbo99999
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40310739
I just tried the example from http://social.msdn.microsoft.com/Forums/en-US/fe8af53c-4912-49c3-9992-5bbeea32b29d/impersonation-to-copy-file?forum=vblanguage and it is working.

It will be the subject of my next article to be published in the next few days!
0
 

Author Comment

by:Jimbo99999
ID: 40311155
I am looking at that one too...thanks for the good info I really appreciate it.

jimbo99999
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 2000 total points
ID: 40313500
0
 

Author Comment

by:Jimbo99999
ID: 40313550
Excellent! Just sitting down to give it a try.

Thanks,
jimbo99999
0
 

Author Comment

by:Jimbo99999
ID: 40314322
I am officially impersonating.  Thanks for the help...excellent article!

Thanks,
jimbo99999
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Integration Management Part 2
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question