Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Run batch file rename a folder as administrator!

17 Apr 2019   #11
Snick

Win 10 x64, Linux Lite, Win 7 x64, BlackArch, & Kali
 
 

Quote   Quote: Originally Posted by Paul Black View Post
Thanks again iko22,

This is not critical BTW and is not networked!

The idea behind this is I want to upload a batch file that members can use. It has a menu. I want them to be able to run the menu items. i.e. If they wanted to run SFC, then I thought it would be a good idea to rename the CBS folder to CBS_OLD first for example. I just wondered if there was an easy way to get the code to run with administrator rights.

Thanks.

You're trying to circumvent win security protocol. Batch file run from guest cmd & elevate guest to admin rights?
Don't believe that's possible!
How to open an elevated cmd using command line for Windows ...
#62 green check





My System SpecsSystem Spec
.
18 Apr 2019   #12
Paul Black

Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 

Hi Snick,

Quote   Quote: Originally Posted by Snick View Post
You're trying to circumvent win security protocol. Batch file run from guest cmd & elevate guest to admin rights?
Don't believe that's possible!
How to open an elevated cmd using command line for Windows ...
#62 green check
I didn't think it was but I thought I would ask!

What does #62 green check mean?
My System SpecsSystem Spec
18 Apr 2019   #13
Paul Black

Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 

Would opening PowerShell from within the batch file and performing the processes [then closing PowerShell] overcome the administrator restrictions?

I would assume that it doesn't!
My System SpecsSystem Spec
.

18 Apr 2019   #14
iko22

Windows 7 x64, Vista x64, 8.1 smartphone
 
 

No joy? I'd thought you'd have this up and running by now! I did a bit more homework on the two commands, and I tried this on a folder called Demo, and it seems to work perfectly.

Code:
RUNAS /profile /user:user1 "iCACLS c:\users\user1\desktop\demo /deny user1:(OI)(CI)F"
RUNAS /profile /user:user1 "iCACLS c:\users\user1\desktop\demo /grant user1:(OI)(CI)F"
This returns success on mine, so I'd assume it would also work on c:\windows\logs\cbs on your computer. Assume user1 has admin rights.

I think @Snick is correct, you cannot run an elevated command prompt from a batch file. This example does not attempt to break that restriction.
My System SpecsSystem Spec
18 Apr 2019   #15
Paul Black

Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 

Hi iko22,

Quote   Quote: Originally Posted by iko22 View Post
No joy? I'd thought you'd have this up and running by now!
I have had limited time to spend on this for the last couple of days, but I will get around to it this afternoon, hopefully!

Quote   Quote: Originally Posted by iko22 View Post
I think @Snick is correct, you cannot run an elevated command prompt from a batch file. This example does not attempt to break that restriction.
That was what I thought, but I wondered if there was a clever workaround, obviously not, which makes sense because it is to keep the integrity of the system secure!

Thanks again.
My System SpecsSystem Spec
18 Apr 2019   #16
Paul Black

Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 

Hi iko22,

Quote   Quote: Originally Posted by iko22 View Post
No joy? I'd thought you'd have this up and running by now! I did a bit more homework on the two commands, and I tried this on a folder called Demo, and it seems to work perfectly.

Code:
RUNAS /profile /user:user1 "iCACLS c:\users\user1\desktop\demo /deny user1:(OI)(CI)F"
RUNAS /profile /user:user1 "iCACLS c:\users\user1\desktop\demo /grant user1:(OI)(CI)F"
No go I'm afraid!

Says error with RUNAS and I can't leave the password blank [even though it is not passworded]!

I will try and have a better look later.
My System SpecsSystem Spec
18 Apr 2019   #17
Paul Black

Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 

UPDATE:

I ran this...

Code:
echo.
net stop wuauserv
icacls "c:\windows\logs\cbs" /grant system-admin:(OI)(CI)F /T
ren c:\windows\Logs\CBS\ c:\windows\Logs\CBS_OLD\
net start wuauserv
pause
...and got this...

Run batch file rename a folder as administrator!-7f-img.jpg

Thanks in advance.


My System SpecsSystem Spec
.
18 Apr 2019   #18
iko22

Windows 7 x64, Vista x64, 8.1 smartphone
 
 

Hello Paul

THe syntax for the REN statement says you are trying to RENAME the entire folder. DO you not want to rename the CBS.log within the CBS folder?
My System SpecsSystem Spec
18 Apr 2019   #19
Paul Black

Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 

Hi iko22,

Quote   Quote: Originally Posted by iko22 View Post
The syntax for the REN statement says you are trying to RENAME the entire folder. DO you not want to rename the CBS.log within the CBS folder?
Yes. I would however, also find it useful to be able to rename the parent folder [CBS] if I so wished.

I was trying out both, hence the confusion!
My System SpecsSystem Spec
18 Apr 2019   #20
Snick

Win 10 x64, Linux Lite, Win 7 x64, BlackArch, & Kali
 
 

Well, my reference to #62 green was the response number that was marked with a green check-mark.
It's not there anymore. Many other responses not there either, must be admin vetting.
The gist of the response was that you can't elevate from guest to admin from within the guest process. Don't recall who claimed to be the respondent.
My System SpecsSystem Spec
Reply

 Run batch file rename a folder as administrator!




Thread Tools




Similar help and support threads
Thread Forum
Batch File on USB fails when Ran As Administrator
I am new to this site so please excuse any lack of etiquette I may show. I have recently built a .bat files to perform a large number of configuration changes needed for a Win7 or Win8 workstation to function properly on my network. The .bat file obviously needs to be ran with elevated...
Software
Batch File that grabs file names from folder to insert into batch file
Ok I'm totally at a loss on how to word this so I'm just going to write it out the best that I can... :confused: First I have a batch file that I'm writing that will convert mp4 files to mp3 files (I have a lot) for a buddies band using ffmpeg. Here's the code that I'm using: ffmpeg -i...
General Discussion
Batch file or Exe to copy & rename directory and update files
I require a batch file or free utility that i can redistribute from my web site to other users, (gamers) that will copy the contents of a directory inside their game to a new location and re-name the directory at the same time. Something like this; Copy "Genesis\Vehicles\truck\diesel\4tonbaker"...
General Discussion
How to always run batch file as administrator?
I've made a batch file, but i don't know how to make it to always run as administartor. In .bat's file properties the option "always run as administartor" is grayed out. I have to right click it and then choose "run as administartor" from context menu. But i don't want to do it every time because...
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 01:07.
Twitter Facebook