Take Ownership of a file/folder

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
3 posts Page 1 of 1
Contributors
User avatar
MiztaInsane
VIP - Donator
VIP - Donator
Posts: 13
Joined: Thu Jan 14, 2010 3:39 pm

Take Ownership of a file/folder
MiztaInsane
I want to take ownership of Context.exe but it don't let me anyway of takeing ownership of a file in vb that easy?
Code: Select all
Dim fileName As String = ("C:\Users\Devin\Desktop\Context.exe")
Dim arguments As String = ("takeown /f C:\Users\Devin\Desktop\Context.exe")
System.Diagnostics.Process.Start(fileName, arguments)
it give me and Access is denied error
User avatar
Harlem9191
Top Poster
Top Poster
Posts: 87
Joined: Mon Jan 18, 2010 8:45 pm

You would probably have to run the program as administrator
User avatar
MiztaInsane
VIP - Donator
VIP - Donator
Posts: 13
Joined: Thu Jan 14, 2010 3:39 pm

Hey Harlem9191 i had to use this code
Code: Select all
Dim fileName As String = ("C:\Users\Devin\Desktop\Context.exe")
Interaction.Shell(String.Concat(New String() {"cmd.exe /c takeown /f ", fileName, " && icacls ", fileName, " /grant administrators:F"}), AppWinStyle.Hide, False, -1)
3 posts Page 1 of 1
Return to “Coding Help & Support”