Rename files from system32 in Windows 10

Just starting out? Need help? Post your questions and find answers here.
boyoss
User
User
Posts: 74
Joined: Fri Feb 05, 2016 10:11 am

Rename files from system32 in Windows 10

Post by boyoss »

I'm trying to rename a file in system32, i give it permissions with iacls and takeown, on windows 7 it works fine, but on windows 10 it's not renaming.
What can be the problem ?

Code: Select all

file.s = "C:\Windows\System32\calc.exe"

RunProgram("takeown", "/f " + file, "", #PB_Program_Wait | #PB_Program_Hide)
RunProgram("icacls", file + " /grant administrators:F", "", #PB_Program_Wait | #PB_Program_Hide)
RenameFile(file, "C:\Windows\System32\a.exe")
Thanks
User avatar
Keya
Addict
Addict
Posts: 1865
Joined: Thu Jun 04, 2015 7:10 am

Re: Rename files from system32 in Windows 10

Post by Keya »

just guessing here but maybe the rename is working, but that Windows File Protection system copies 'critical' ones (like system32) back automatically if it detects they go AWOL? But its very quick so it might appear like it never happens. Try it with a file you create yourself rather than a Windows protected one. Or maybe you just need to run as Admin rights?
boyoss
User
User
Posts: 74
Joined: Fri Feb 05, 2016 10:11 am

Rename files from system32 in Windows 10

Post by boyoss »

I have admin rights, and i tried with a file i created, it's also not working.
In the Windows explorer when i press delete it's deleting.

Now i see that the iacls also is not giving permissions to the file, but when i write the command in a console it's yes giving.

Don't understand anything.


Envoyé de mon iPhone en utilisant Tapatalk
fryquez
Enthusiast
Enthusiast
Posts: 207
Joined: Mon Dec 21, 2015 8:12 pm

Re: Rename files from system32 in Windows 10

Post by fryquez »

If you compile with x86 and run your code in x64 windows, it may triggers File system redirection.
boyoss wrote: Don't understand anything.
Than better keep away from system32 folder, for now ... :P
eJan
Enthusiast
Enthusiast
Posts: 365
Joined: Sun May 21, 2006 11:22 pm
Location: Sankt Veit am Flaum

Re: Rename files from system32 in Windows 10

Post by eJan »

Hi!, for Win 10 permissions the only working tool for me is SetACL.
Image
boyoss
User
User
Posts: 74
Joined: Fri Feb 05, 2016 10:11 am

Re: Rename files from system32 in Windows 10

Post by boyoss »

Thanks
It's very interesting, I test it on two computers with Windows 8,on the first one it works and on the second one not!
Both of them have uac!

I have to find out what's the problem.

@ejan, is it possible to integrate setacl in purebasic?
eJan
Enthusiast
Enthusiast
Posts: 365
Joined: Sun May 21, 2006 11:22 pm
Location: Sankt Veit am Flaum

Re: Rename files from system32 in Windows 10

Post by eJan »

I'm using it via batch scripts only. You can use it in PB inside DataSection, extract it to Temp and run a command:

Code: Select all

Procedure ExtractIncludeFile(Name.s, *StartFile, *EndFile)
  If CreateFile(0, Name)
    WriteData(0, *StartFile, *EndFile - *StartFile)
    CloseFile(0)
    ProcedureReturn #True
  EndIf
  ProcedureReturn #False
EndProcedure

ExtractIncludeFile("New Text Document Extract.txt", ?StartFile_data, ?EndFile_data)

DataSection
  StartFile_data:
  IncludeBinary "New Text Document.txt"
  EndFile_data:
EndDataSection
Image
boyoss
User
User
Posts: 74
Joined: Fri Feb 05, 2016 10:11 am

Re: Rename files from system32 in Windows 10

Post by boyoss »

fryquez wrote:If you compile with x86 and run your code in x64 windows, it may triggers File system redirection.
That was the problem, thank you very much.


Envoyé de mon iPhone en utilisant Tapatalk
Post Reply