Page 1 of 1

Take Ownership of a file/folder

Posted: Fri Mar 26, 2010 4:13 pm
by 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

Re: Take Ownership of a file/folder

Posted: Mon Mar 29, 2010 10:56 pm
by Harlem9191
You would probably have to run the program as administrator

Re: Take Ownership of a file/folder

Posted: Tue Mar 30, 2010 10:39 pm
by MiztaInsane
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)