It is currently Mon Jan 27, 2020 10:07 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Rename files from system32 in Windows 10
PostPosted: Sun Jan 15, 2017 9:47 pm 
Offline
User
User

Joined: Fri Feb 05, 2016 10:11 am
Posts: 73
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:
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Rename files from system32 in Windows 10
PostPosted: Mon Jan 16, 2017 1:34 am 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 04, 2015 7:10 am
Posts: 1673
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?

_________________
Thankyou to all the coders who generously helped & encouraged me in the nearly 2yrs when i was welcome here,
it was a tremendous privilege. I learned a lot. I wish you and your families all the best and success for the future.


Top
 Profile  
Reply with quote  
 Post subject: Rename files from system32 in Windows 10
PostPosted: Mon Jan 16, 2017 7:06 am 
Offline
User
User

Joined: Fri Feb 05, 2016 10:11 am
Posts: 73
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Rename files from system32 in Windows 10
PostPosted: Mon Jan 16, 2017 3:22 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Dec 21, 2015 8:12 pm
Posts: 153
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Rename files from system32 in Windows 10
PostPosted: Mon Jan 16, 2017 7:57 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun May 21, 2006 11:22 pm
Posts: 364
Location: Sankt Veit am Flaum
Hi!, for Win 10 permissions the only working tool for me is SetACL.

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Rename files from system32 in Windows 10
PostPosted: Mon Jan 16, 2017 11:26 pm 
Offline
User
User

Joined: Fri Feb 05, 2016 10:11 am
Posts: 73
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?


Top
 Profile  
Reply with quote  
 Post subject: Re: Rename files from system32 in Windows 10
PostPosted: Tue Jan 17, 2017 9:01 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun May 21, 2006 11:22 pm
Posts: 364
Location: Sankt Veit am Flaum
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:
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Rename files from system32 in Windows 10
PostPosted: Thu Jan 19, 2017 1:07 am 
Offline
User
User

Joined: Fri Feb 05, 2016 10:11 am
Posts: 73
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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 21 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye