collage_jeanz
asked on
Bat file to run .reg file and detele couple of folders and record the log file
I have one abc.reg file, which I want to run with the batch file and update the registry and after that I have couple of folders which I want to delete for example, I have 6 folders in c:\program files\lexmarkXXXXX
I want to delete all the folders in c:\program files\ starting with "Lexmark" name, and I want to delete these folders in quite mode.
After running the batch file, it should make a log file for any errors in c:\windows\logs\Lexmark_Re moval.txt
please help.
I want to delete all the folders in c:\program files\ starting with "Lexmark" name, and I want to delete these folders in quite mode.
After running the batch file, it should make a log file for any errors in c:\windows\logs\Lexmark_Re
please help.
:oops, left out the regedit part -- try this instead:
regedit.exe /s "c:\myfolder\myfile.reg"
pushd "c:\program files"
for /D %%D in (Lexmark*) do rd/s/q "%%D"
regedit.exe /s "c:\myfolder\myfile.reg"
pushd "c:\program files"
for /D %%D in (Lexmark*) do rd/s/q "%%D"
:all that, and I forgot to log it -- sorry, third time's the charm...
@echo %date% %time% >>c:\windows\logs\Lexmark_ Removal.tx t
regedit.exe /s "c:\myfolder\myfile.reg" >>c:\windows\logs\Lexmark_ Removal.tx t
pushd "c:\program files"
for /D %%D in (Lexmark*) do rd/s/q "%%D" >>c:\windows\logs\Lexmark_ Removal.tx t
echo. >>c:\windows\logs\Lexmark_ Removal.tx t
@echo %date% %time% >>c:\windows\logs\Lexmark_
regedit.exe /s "c:\myfolder\myfile.reg" >>c:\windows\logs\Lexmark_
pushd "c:\program files"
for /D %%D in (Lexmark*) do rd/s/q "%%D" >>c:\windows\logs\Lexmark_
echo. >>c:\windows\logs\Lexmark_
ASKER
Folders are not getting deleted. I think the only reason, bcoz they are on read-only mode. Help !!!
:what does the error log say? Let's try this:
@echo %date% %time% >>c:\windows\logs\Lexmark_ Removal.tx t
regedit.exe /s "c:\myfolder\myfile.reg" >>c:\windows\logs\Lexmark_ Removal.tx t
cd/d "c:\program files"
for /D %%D in (Lexmark*) do attrib -s -h -r "%%D"
for /D %%D in (Lexmark*) do rd/s/q "%%D" >>c:\windows\logs\Lexmark_ Removal.tx t
echo. >>c:\windows\logs\Lexmark_ Removal.tx t
@echo %date% %time% >>c:\windows\logs\Lexmark_
regedit.exe /s "c:\myfolder\myfile.reg" >>c:\windows\logs\Lexmark_
cd/d "c:\program files"
for /D %%D in (Lexmark*) do attrib -s -h -r "%%D"
for /D %%D in (Lexmark*) do rd/s/q "%%D" >>c:\windows\logs\Lexmark_
echo. >>c:\windows\logs\Lexmark_
If the folders contain documents that are currently opened by other users, they may not delete. Could this be the case?
also, it could be a user permission issue. Run the script as an administrator. (This is most likely the issue IMO)
ASKER
You are rite, when I opened command prompt with Runas (admin account) and run the batch file it showed me something
C:\Documents and Settings\abc\Desktop>lexma rk_removal .bat
C:\Documents and Settings\abc\Desktop>reged it.exe /s "\\server\share\name\Regis try.reg" 1>>c:\windows\logs\Lexmark _Removal.t xt
C:\Documents and Settings\abc\Desktop>cd/d "c:\program files"
C:\Program Files>for / %D in (Lexmark*) do attrib -s -h -r "%D"
C:\Program Files>attrib -s -h -r "Lexmark"
C:\Program Files>attrib -s -h -r "Lexmark S300-S400 Series"
C:\Program Files>for / %D in (Lexmark*) do rd/s/q "%D" 1>>c:\windows\logs\Lexma
rk_Removal.txt
C:\Program Files>rd/s/q "Lexmark" 1>>c:\windows\logs\Lexmark _Removal.t xt
Lexmark\S300-S~1\lxeacaps. dll - Accès refusé.
Lexmark\S300-S~1\lxeacfg.d ll - Accès refusé.
Lexmark\S300-S~1\lxeacnv4. dll - Accès refusé.
Lexmark\S300-S~1\lxeadrs.d ll - Accès refusé.
Lexmark\S300-S~1\lxeamicro .dll - Accès refusé.
C:\Program Files>rd/s/q "Lexmark S300-S400 Series" 1>>c:\windows\logs\Lexmark _R
emoval.txt
Lexmark S300-S400 Series\lxeacaps.dll - Accès refusé.
Lexmark S300-S400 Series\LXEAcfg.dll - Accès refusé.
Lexmark S300-S400 Series\lxeacnv4.dll - Accès refusé.
Lexmark S300-S400 Series\lxeacomc.dll - Accès refusé.
Lexmark S300-S400 Series\lxeadrs.dll - Accès refusé.
Lexmark S300-S400 Series\lxeamon.exe - Accès refusé.
Lexmark S300-S400 Series\lxeamonr.dll - Accès refusé.
Lexmark S300-S400 Series\lxeascw.dll - Accès refusé.
C:\Program Files>echo. 1>>c:\windows\logs\Lexmark _Removal.t xt
But in the log file it was only
2011-05-09 12:46:47,49
2011-05-09 12:49:32,12
mentioned, It should show the whole process as It showed when I ran from CMD, I have the admin rights to the local machine where I am testing this, is there any command available to take ownership of the lexmark folder's as well? Thanks for being quick.
C:\Documents and Settings\abc\Desktop>lexma
C:\Documents and Settings\abc\Desktop>reged
C:\Documents and Settings\abc\Desktop>cd/d "c:\program files"
C:\Program Files>for / %D in (Lexmark*) do attrib -s -h -r "%D"
C:\Program Files>attrib -s -h -r "Lexmark"
C:\Program Files>attrib -s -h -r "Lexmark S300-S400 Series"
C:\Program Files>for / %D in (Lexmark*) do rd/s/q "%D" 1>>c:\windows\logs\Lexma
rk_Removal.txt
C:\Program Files>rd/s/q "Lexmark" 1>>c:\windows\logs\Lexmark
Lexmark\S300-S~1\lxeacaps.
Lexmark\S300-S~1\lxeacfg.d
Lexmark\S300-S~1\lxeacnv4.
Lexmark\S300-S~1\lxeadrs.d
Lexmark\S300-S~1\lxeamicro
C:\Program Files>rd/s/q "Lexmark S300-S400 Series" 1>>c:\windows\logs\Lexmark
emoval.txt
Lexmark S300-S400 Series\lxeacaps.dll - Accès refusé.
Lexmark S300-S400 Series\LXEAcfg.dll - Accès refusé.
Lexmark S300-S400 Series\lxeacnv4.dll - Accès refusé.
Lexmark S300-S400 Series\lxeacomc.dll - Accès refusé.
Lexmark S300-S400 Series\lxeadrs.dll - Accès refusé.
Lexmark S300-S400 Series\lxeamon.exe - Accès refusé.
Lexmark S300-S400 Series\lxeamonr.dll - Accès refusé.
Lexmark S300-S400 Series\lxeascw.dll - Accès refusé.
C:\Program Files>echo. 1>>c:\windows\logs\Lexmark
But in the log file it was only
2011-05-09 12:46:47,49
2011-05-09 12:49:32,12
mentioned, It should show the whole process as It showed when I ran from CMD, I have the admin rights to the local machine where I am testing this, is there any command available to take ownership of the lexmark folder's as well? Thanks for being quick.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry It didnt help, the purpose of deleting those folders and then deleting lxea*.* files from system32 bcoz whenever we plug in lexmark printer, the computer picks up the driver automattically, I thought to delete all lexmark related files from computer and clean registry with Lexmark name. But it seems to be not helping. If you can help me resolving this issue it would be great, What I want, whenever I plugin any lexmark device, it should ask me for the driver files and should not install anything by itslef.
If you unplug the printer and reboot, will the script above remove the directories?
As to the second part of your question: "...whenever I plugin any lexmark device, it should ask me for the driver files..."
that is a different question than simply removing directories, and being unfamiliar with the device I can't help with that.
As to the second part of your question: "...whenever I plugin any lexmark device, it should ask me for the driver files..."
that is a different question than simply removing directories, and being unfamiliar with the device I can't help with that.
myfile.reg
pushd "c:\program files"
for /D %%D in (Lexmark*) do rd/s/q "%%D"