SOLVED Elmers Batch file writing issue #2

Elmer BeFuddled

Resident eejit
Joined
Jun 12, 2010
Messages
1,050
Reaction score
251
I'm trying to write a batch file that will:-
a) Take full ownership
b) Rename original file
c) Copy replacement file from point A (different) to the original locations (system 32 and SysWOW64 involved here)

The story so far:-
Code:
@echo off
takeown /f C:\Windows\System32\Elmers.rtf
cacls C:\Windows\System32\Elmers.rtf
REN C:\Windows\System32\Elmers.rtf Elmers0ld.rtf
COPY "D:\ MODIFYING\7 DLL+ W.I.P.s\Elmers.rtf" "C:\Windows\System32\Elmers.rtf"
N.B. The space at the start of the folder called " Modifying" (its an "Alt+ 160) is deliberate, not a typo.

I've made a mock up so I'm assuming the first two (takeown & cacls) are working.
Update, Appears not!!
The rename bit works no problem. It's the copying of the replacement file that's not happening for me :(

This is to automate (eventually!) the changing of my imageres.dll file and another three or four system files I've modified and always change. Thus speeding up a pretty fast routine I've already got (by hand).

Help appreciated.

Update, Appears not!! Tried on a system file, didn't work. Looks like I need to start from scratch :(.
 
Last edited:

Core

all ball, no chain
Moderator
Joined
Feb 13, 2009
Messages
1,175
Reaction score
272
So if you enter them by hand one by one, they do work?
 
Joined
Oct 23, 2010
Messages
13
Reaction score
2
I'm trying to write a batch file that will:-
a) Take full ownership
b) Rename original file
c) Copy replacement file from point A (different) to the original locations (system 32 and SysWOW64 involved here)

The story so far:-
Code:
@echo off
takeown /f C:\Windows\System32\Elmers.rtf
cacls C:\Windows\System32\Elmers.rtf
REN C:\Windows\System32\Elmers.rtf Elmers0ld.rtf
COPY "D:\ MODIFYING\7 DLL+ W.I.P.s\Elmers.rtf" "C:\Windows\System32\Elmers.rtf"
N.B. The space at the start of the folder called " Modifying" (its an "Alt+ 160) is deliberate, not a typo.

I've made a mock up so I'm assuming the first two (takeown & cacls) are working.
Update, Appears not!!
The rename bit works no problem. It's the copying of the replacement file that's not happening for me :(

This is to automate (eventually!) the changing of my imageres.dll file and another three or four system files I've modified and always change. Thus speeding up a pretty fast routine I've already got (by hand).

Help appreciated.

Update, Appears not!! Tried on a system file, didn't work. Looks like I need to start from scratch :(.
http://www.blogsdna.com/2159/how-to...sions-to-access-files-folder-in-windows-7.htm
 
Last edited by a moderator:

Elmer BeFuddled

Resident eejit
Joined
Jun 12, 2010
Messages
1,050
Reaction score
251
Thanks for the Link IonDarkWatch, but I know how to take ownership of a file or folder.

Just not with my crappy .bat file!! :confused:

I'm trying to simplify that process (and others) into one mouse double-click for multiple randomly located files if possible.
 

Core

all ball, no chain
Moderator
Joined
Feb 13, 2009
Messages
1,175
Reaction score
272
You mean like, one batch to take ownership, pause, one to rename, pause, one to replace?
I'll give that a go.
No, I meant if you type the commands one by one into the command prompt, do you get auth probs or do they process...
 

Elmer BeFuddled

Resident eejit
Joined
Jun 12, 2010
Messages
1,050
Reaction score
251
No, I meant if you type the commands one by one into the command prompt, do you get auth probs or do they process...
Okay my icacls was all wrong! Modified the code to
Code:
takeown /f C:\Windows\Elmers.rtf
[B][COLOR=Navy]i[/COLOR][/B]cacls C:\Windows\Elmers.rtf[COLOR=Navy][B]  /grant administrators:F /t[/B][/COLOR]
REN C:\Windows\Elmers.rtf Elmers0ld.rtf
COPY "D:\ MODIFYING\7 DLL+ W.I.P.s\Elmers.rtf" "C:\Windows\Elmers.rtf"
We now have take ownership and rename :D but no copy :(.

"The system cannot find the path specified". I've tried the copy with and without "quotes".

Fire Cat I'll have to look into that, Thanks for the link.
 
Last edited:

Core

all ball, no chain
Moderator
Joined
Feb 13, 2009
Messages
1,175
Reaction score
272
Okay my icacls was all wrong! Modified the code to
Code:
takeown /f C:\Windows\Elmers.rtf
[B][COLOR=Navy]i[/COLOR][/B]cacls C:\Windows\Elmers.rtf[COLOR=Navy][B]  /grant administrators:F /t[/B][/COLOR]
REN C:\Windows\Elmers.rtf Elmers0ld.rtf
COPY "D:\ MODIFYING\7 DLL+ W.I.P.s\Elmers.rtf" "C:\Windows\Elmers.rtf"
We now have take ownership and rename :D but no copy :(.

"The system cannot find the path specified". I've tried the copy with and without "quotes".

Fire Cat I'll have to look into that, Thanks for the link.
When you type out the copy command, make sure you enter the space before the word MODIFYING not with a space key, but by holding down ALT and typing 0160 on your numpad.
 

Elmer BeFuddled

Resident eejit
Joined
Jun 12, 2010
Messages
1,050
Reaction score
251
When you type out the copy command, make sure you enter the space before the word MODIFYING not with a space key, but by holding down ALT and typing 0160 on your numpad.
It still confused it.... So I took the Alt+0160 out for now (it just made it the top left / first folder in its parent folder) and it worked!! Cheers Core. Now to try it on a "locked" system file (if I've any left that is!).
 

Elmer BeFuddled

Resident eejit
Joined
Jun 12, 2010
Messages
1,050
Reaction score
251
Well the finished script is working a treat, I've tried it 5 or 6 times now with no problems.
First it prompts me to make a restore point so I've put a shortcut to a utility to do that in the same folder. I can't find a way to automate this (yet!). I then hit Y and enter.
It takes ownership and grants full control to admins of the (18) files I swap. Appends 0ld to the original file names. Copies and Pastes the modified files from the storage folders to their locations. Does a Disk Cleanup of the thumbnails cache (only), deletes the Iconcache.db** file and finally restarts the PC.

I'm well chuffed!! :proud: :proud: :proud:

** I couldn't get it to delete the Iconcache.db file until I set it to remove the hidden attribute first. Does that sound right?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top