Link to home
Start Free TrialLog in
Avatar of Jimbo99999
Jimbo99999Flag for United States of America

asked on

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

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
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

the user doesn't have permission from the source or the destination directory?
Avatar of Jimbo99999

ASKER

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
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.
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
I found yet another example using a Windows Forms application: http://support.microsoft.com/kb/841699/en-us
Thank you kindly Eric...I appreciate the reference.  I will try this out today.

Thanks,
jimbo99999
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!
I am looking at that one too...thanks for the good info I really appreciate it.

jimbo99999
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Excellent! Just sitting down to give it a try.

Thanks,
jimbo99999
I am officially impersonating.  Thanks for the help...excellent article!

Thanks,
jimbo99999