[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Bat file to run .reg file and detele couple of folders and record the log file

Posted on 2011-05-09
11
Medium Priority
?
437 Views
Last Modified: 2012-08-14
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_Removal.txt

please help.
0
Comment
Question by:collage_jeanz
  • 8
  • 3
11 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 35721758

myfile.reg

pushd "c:\program files"
for /D %%D in (Lexmark*) do rd/s/q "%%D"
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 35721777
: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"
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 35721799
:all that, and I forgot to log it -- sorry, third time's the charm...

@echo %date% %time% >>c:\windows\logs\Lexmark_Removal.txt
regedit.exe /s  "c:\myfolder\myfile.reg" >>c:\windows\logs\Lexmark_Removal.txt
pushd "c:\program files"
for /D %%D in (Lexmark*) do rd/s/q "%%D" >>c:\windows\logs\Lexmark_Removal.txt
echo. >>c:\windows\logs\Lexmark_Removal.txt
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:collage_jeanz
ID: 35721942
Folders are not getting deleted. I think the only reason, bcoz they are on read-only mode. Help !!!
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 35721952
:what does the error log say?  Let's try this:

@echo %date% %time% >>c:\windows\logs\Lexmark_Removal.txt
regedit.exe /s  "c:\myfolder\myfile.reg" >>c:\windows\logs\Lexmark_Removal.txt
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.txt
echo. >>c:\windows\logs\Lexmark_Removal.txt
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 35721963
If the folders contain documents that are currently opened by other users, they may not delete.  Could this be the case?
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 35721971
also, it could be a user permission issue.  Run the script as an administrator.  (This is most likely the issue IMO)
0
 

Author Comment

by:collage_jeanz
ID: 35722102
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>lexmark_removal.bat

C:\Documents and Settings\abc\Desktop>regedit.exe /s  "\\server\share\name\Registry.reg"  1>>c:\windows\logs\Lexmark_Removal.txt

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.txt
Lexmark\S300-S~1\lxeacaps.dll - Accès refusé.
Lexmark\S300-S~1\lxeacfg.dll - Accès refusé.
Lexmark\S300-S~1\lxeacnv4.dll - Accès refusé.
Lexmark\S300-S~1\lxeadrs.dll - 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.txt

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.
0
 
LVL 33

Accepted Solution

by:
knightEknight earned 500 total points
ID: 35722122
Yes, it seems you have running processes that are dependent on the DLL files in these folders.  You should stop and restart what ever services you may have upgraded, or otherwise stop the processes from running.

Here is the same script that will (hopefully) log the errors also:

@echo %date% %time% 1>>c:\windows\logs\Lexmark_Removal.txt
regedit.exe /s  "c:\myfolder\myfile.reg" 1>>c:\windows\logs\Lexmark_Removal.txt  2>>c:\windows\logs\Lexmark_Removal.txt
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" 1>>c:\windows\logs\Lexmark_Removal.txt  2>>c:\windows\logs\Lexmark_Removal.txt
echo. >>c:\windows\logs\Lexmark_Removal.txt
0
 

Author Comment

by:collage_jeanz
ID: 35722607
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.
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 35722789
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.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question