Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

batch & VBS script to take file ownership

Featured Replies

Working perfect...

please add the script to rename the file for backup purpose well.. as for previous one..

B)

Here it is, just drag and drop the original file on the script, it'll modify permissions for the original file and make another copy of the same file in source directory..

Thank You gunsmokingman! :)

Dim Act : Set Act = CreateObject("Wscript.Shell")
Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")
Dim File1, File2
For Each File1 in Wscript.Arguments
Act.Run("takeown /A /f " & Chr(34) & File1 & chr(34)),1,True
Act.Run("icacls " & Chr(34) & File1 & chr(34) & " /grant administrators:F"),1,True
File2 = Split(File1,".")
Set File = Fso.GetFile(File1)
File.Copy(File2(0) & "_Original." & File2(1))
Next

BTW, how can I add now this new script to my right click selection?

Working perfect...

please add the script to rename the file for backup purpose well.. as for previous one..

B)

Here it is, just drag and drop the original file on the script, it'll modify permissions for the original file and make another copy of the same file in source directory..

Thank You gunsmokingman! :)

Dim Act : Set Act = CreateObject("Wscript.Shell")
Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")
Dim File1, File2
For Each File1 in Wscript.Arguments
Act.Run("takeown /A /f " & Chr(34) & File1 & chr(34)),1,True
Act.Run("icacls " & Chr(34) & File1 & chr(34) & " /grant administrators:F"),1,True
File2 = Split(File1,".")
Set File = Fso.GetFile(File1)
File.Copy(File2(0) & "_Original." & File2(1))
Next

BTW, how can I add now this new script to my right click selection?

I have made this new script into a sfx fle that extracts to the Sendto folder,

this one does not create a extra copy of the file

Save As OwnTheFile_V2

Dim Act : Set Act = CreateObject("Wscript.Shell")
Dim File1
For Each File1 in Wscript.Arguments
Act.Run("takeown /A /f " & Chr(34) & File1 & chr(34)),1,True
Act.Run("icacls " & Chr(34) & File1 & chr(34) & " /grant administrators:F"),1,True
Next

I have made this new script into a sfx fle that extracts to the Sendto folder

Save as OwnTheFile_V3

Dim Act : Set Act = CreateObject("Wscript.Shell")
Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")
Dim File, File1, File2
For Each File1 in Wscript.Arguments
Act.Run("takeown /A /f " & Chr(34) & File1 & chr(34)),0,True
Act.Run("icacls " & Chr(34) & File1 & chr(34) & " /grant administrators:F"),0,True
File2 = Split(File1,".")
Set File = Fso.GetFile(File1)
File.Copy(File2(0) & "_Original." & File2(1))
Next

OwnTheFile_V3.exe

OwnTheFile_V2.exe

wooo something i was looking for, hmm isit there anyway you can take over everyfile because that would save time an effort in a sense

wooo something i was looking for, hmm isit there anyway you can take over everyfile because that would save time an effort in a sense

This can do multiple files, but there is a limit to how many the Wscript.Arguments can handle.

I believe it can handle under 24 files at a time, but do not quote me on that.

  • Author

Yesss, it is working great with every files i have checked till now..

if problem persist.. rectification will obviously be done

Thanks Gunsmokingman for his effort for making the VBS script for sendto menu.

hmmm 24 aint to bad.....providing you need to do a directory cheers :)

  • Author

now you can take ownership with the registry file

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\runas]

@="Gain Ownership"

"Extended"=""

"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\*\shell\runas\command]

@="cmd.exe /c takeown /A /f \"%1\" && icacls \"%1\" /grant administrators:F"

"IsolatedCommand"="cmd.exe /c takeown /A /f \"%1\" && icacls \"%1\" /grant administrators:F"

[HKEY_CLASSES_ROOT\Directory\shell\runas]

@="Gain Ownership"

"Extended"=""

"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\Directory\shell\runas\command]

@="cmd.exe /c takeown /A /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"

"IsolatedCommand"="cmd.exe /c takeown /A /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"

SHIFT + Right Click = Gain Ownership context menu

ownership.reg

Edited by Nepali

now you can take ownership with the registry file

What this reg entry gives us, right click option to take ownership or?

Thx

  • Author

merging this, you will get option to gain ownership for files and folder

SHIFT + Rt click

Edited by Nepali

  • 3 weeks later...
Working perfect...

please add the script to rename the file for backup purpose well.. as for previous one..

B)

Here it is, just drag and drop the original file on the script, it'll modify permissions for the original file and make another copy of the same file in source directory..

Thank You gunsmokingman! :)

Dim Act : Set Act = CreateObject("Wscript.Shell")
Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")
Dim File1, File2
For Each File1 in Wscript.Arguments
Act.Run("takeown /A /f " & Chr(34) & File1 & chr(34)),1,True
Act.Run("icacls " & Chr(34) & File1 & chr(34) & " /grant administrators:F"),1,True
File2 = Split(File1,".")
Set File = Fso.GetFile(File1)
File.Copy(File2(0) & "_Original." & File2(1))
Next

BTW, how can I add now this new script to my right click selection?

I have made this new script into a sfx fle that extracts to the Sendto folder,

this one does not create a extra copy of the file

Save As OwnTheFile_V2

Dim Act : Set Act = CreateObject("Wscript.Shell")
Dim File1
For Each File1 in Wscript.Arguments
Act.Run("takeown /A /f " & Chr(34) & File1 & chr(34)),1,True
Act.Run("icacls " & Chr(34) & File1 & chr(34) & " /grant administrators:F"),1,True
Next

I have made this new script into a sfx fle that extracts to the Sendto folder

Save as OwnTheFile_V3

Dim Act : Set Act = CreateObject("Wscript.Shell")
Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")
Dim File, File1, File2
For Each File1 in Wscript.Arguments
Act.Run("takeown /A /f " & Chr(34) & File1 & chr(34)),0,True
Act.Run("icacls " & Chr(34) & File1 & chr(34) & " /grant administrators:F"),0,True
File2 = Split(File1,".")
Set File = Fso.GetFile(File1)
File.Copy(File2(0) & "_Original." & File2(1))
Next

i get a permissions error when i try to run and i'm not sure how to force it to run as admin (or whatever permissions are needed)

now you can take ownership with the registry file
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\runas]

@="Gain Ownership"

"Extended"=""

"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\*\shell\runas\command]

@="cmd.exe /c takeown /A /f \"%1\" && icacls \"%1\" /grant administrators:F"

"IsolatedCommand"="cmd.exe /c takeown /A /f \"%1\" && icacls \"%1\" /grant administrators:F"

[HKEY_CLASSES_ROOT\Directory\shell\runas]

@="Gain Ownership"

"Extended"=""

"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\Directory\shell\runas\command]

@="cmd.exe /c takeown /A /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"

"IsolatedCommand"="cmd.exe /c takeown /A /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"

SHIFT + Right Click = Gain Ownership context menu

This doesnt allow for gaining of ownership of executeables

I used this script to change the permission on mspaint.exe

Dim Act : Set Act = CreateObject("Wscript.Shell")
Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")
Dim File, File1, File2
For Each File1 in Wscript.Arguments
Act.Run("takeown /f " & File1),0,True
Act.Run("icacls " & File1 & " /grant administrators:F"),1,True
File2 = Split(File1,".")
Set File = Fso.GetFile(File1)
File.Copy(File2(0) & "_Original." & File2(1))
Next

The other scripts I posted where to change permission in the Program Files because of the space in the name.

Before OwnTheFile

BeforeOwnTheFile.jpg

After OwnTheFile

AfterOwnTheFile.jpg

  • 1 month later...

I was wondering if anyone can help me with this unkown user?

I would like to remove it if I could, I am the only user on this computer and the guest account is disabled.

vistartm034ub8.gif

Should I run a script to take ownership of "everything" ?

Edited by kartel

  • 1 year later...

Hello,

Can this script be used to open an encrypted file,if yes how to do that.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.