We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


Script or Batch that removes an older version of install file

quickslvr asked
Medium Priority
Last Modified: 2012-06-27
we use a Software that updates the security on programs. Each time an update is ready, it gets provided by that software vendor which is then ready to install.

the problem is that the patch always has the same name and therefore the patching is not effective.To avoid this,i need to get the old file renamed and removed.

How would a patch or script look like which renames the old "update.exe" into say,"updateold.exe", then deletes it and installs the new one instead?
Watch Question

Are you looking for a login script?


no, a script or batcvh which exactly the above: rename,delete

RENAME [drive:][path]filename1 filename2.
REN [drive:][path]filename1 filename2.

DEL [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names

rename c:\win.exe c:\win.old
del c:\win.old

Is that what you want?


thats the idea. is there another way of doing it?

what are these DEL attributes exactly?
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

I created a file called win.exe in the root of my c:drive and it renamed it and deleted it.


ok,ill try it and let you know.

what are these DEL attributes exactly?

Don't use
rename c:\win.exe c:\win.old
del c:\win.old

rename c:\win.exe win.old
del c:\win.old

I had the syntax wrong in the top one.

DEL [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
ERASE [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names

  names         Specifies a list of one or more files or directories.
                Wildcards may be used to delete multiple files. If a
                directory is specified, all files within the directory
                will be deleted.

  /P            Prompts for confirmation before deleting each file.
  /F            Force deleting of read-only files.
  /S            Delete specified files from all subdirectories.
  /Q            Quiet mode, do not ask if ok to delete on global wildcard
  /A            Selects files to delete based on attributes
  attributes    R  Read-only files            S  System files
                H  Hidden files               A  Files ready for archiving
                I  Not content indexed Files  L  Reparse Points
                -  Prefix meaning not

If Command Extensions are enabled DEL and ERASE change as follows:

The display semantics of the /S switch are reversed in that it shows
you only the files that are deleted, not the ones it could not find.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.