Page 1 of 1
Rename files from system32 in Windows 10
Posted: Sun Jan 15, 2017 9:47 pm
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
Re: Rename files from system32 in Windows 10
Posted: Mon Jan 16, 2017 1:34 am
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?
Rename files from system32 in Windows 10
Posted: Mon Jan 16, 2017 7:06 am
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
Re: Rename files from system32 in Windows 10
Posted: Mon Jan 16, 2017 3:22 pm
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 ...

Re: Rename files from system32 in Windows 10
Posted: Mon Jan 16, 2017 7:57 pm
by eJan
Hi!, for Win 10 permissions the only working tool for me is
SetACL.
Re: Rename files from system32 in Windows 10
Posted: Mon Jan 16, 2017 11:26 pm
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?
Re: Rename files from system32 in Windows 10
Posted: Tue Jan 17, 2017 9:01 pm
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
Re: Rename files from system32 in Windows 10
Posted: Thu Jan 19, 2017 1:07 am
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