Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to copy file to system folder in batch

i want to copy a file to system32 folder using a batch file. but when i try to do this it says "Access denied" i also can not copy anything to my C:\ drive also. i tried using xcopy and copy to do this. i don't know what is the parameter to get the administrator permission. so, can anyone help me?

program:

@echo off  
xcopy abc.dll "C:\Windows\System32\" -y  
pause  

output:

D:abc.dll  
Access denied  
Press any key to continue . . .  
like image 608
p2013 Avatar asked Dec 14 '25 05:12

p2013


2 Answers

Should be doable one of two ways.

The first is to make a shortcut to your batch file, right click -> properties and on the Shortcut tab of the properties, click the Advanced button to find a checkable "run as admin" option.

The second (NOT TESTED) is to add a bunch of stuff to the top of your batch file (Reference) - I don't want to include it in the answer because I have not tested it.

like image 62
panhandel Avatar answered Dec 15 '25 18:12

panhandel


@echo off  
copy /Y abc.dll "C:\Windows\System32\"  
pause

right click the batch file and run as administrator and make sure the abc.dll is in the same folder as your batch file.

hope this helps.

like image 24
webspyder Avatar answered Dec 15 '25 17:12

webspyder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!