Results 1 to 3 of 3

Thread: Deleting and renaming files using Batch file on Windows 7 x64

  1. #1
    Join Date
    Apr 2011
    Posts
    63

    Deleting and renaming files using Batch file on Windows 7 x64

    I want to create personal shortcut on my desktop for changing password using shiftkeys .exe (C:\Windows\System32\sethc.exe). I want to automate the process in a way where my batch file will remove itself after completing its task. I am having .exe file renaming sethc.exe to sethc2.exe, Below is the code that i am using:

    del sethc.exe
    ren sethc2.exe sethc.exe
    del %0

    Batch file is deleting itself somehow but it's not able to remove of the .exe and the renaming. Is there anything that i am missing out here????

  2. #2
    Join Date
    May 2008
    Posts
    991
    Have you tried running above BAT file with Administrative privileges?? If not than right click on it and try running it as Administrator and check out if that's making any difference. If you still don't get lucky than try running it as followed:
    ]del /F /S /Q /A sethc.exe
    ren sethc2.exe sethc.exe
    del %0

    Let me know if you find it helping.

    For reference:
    /F - Force deleting read only files.
    /S - Deletes specified files from sub-directories.
    /Q - It's Quite mode and it would not prompt if it is ok to remove all the global wild cards.
    /A - It choose a file and delete it on the basis of the provided attribute.

  3. #3
    Join Date
    Apr 2009
    Posts
    1,107
    As far as i can guess you might not be having ownership of the file. sethc.exe is owned by TrustedInstaller and one needs to have ownership of it, one should set file's permissions to "Allow" your user account "Full Control" of the file as well. Just cross check and make sure that you are having above conditions true, if not than file wont get deleted.

Similar Threads

  1. Need batch file to delete user files in Windows XP
    By mcamp32 in forum Windows XP Support
    Replies: 1
    Last Post: 26-05-2011, 10:54 PM
  2. Renaming and Deleting a file with Java
    By Spy$Eyes in forum Tips & Tweaks
    Replies: 4
    Last Post: 08-09-2010, 10:07 PM
  3. Deleting files equal to 0 in a batch file.
    By Luis-Fernando in forum Operating Systems
    Replies: 5
    Last Post: 27-03-2010, 08:04 PM
  4. A Simple File and Folder renaming batch code : RenameR
    By Rudra.J in forum Tips & Tweaks
    Replies: 2
    Last Post: 05-03-2009, 02:59 PM
  5. Batch Renaming Software for files inside zip
    By Aditix360 in forum Windows Software
    Replies: 2
    Last Post: 30-01-2009, 10:18 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,727,030,965.41608 seconds with 17 queries