PC Review


Reply
 
 
=?Utf-8?B?ZHJfYWhtZWQ=?=
Guest
Posts: n/a
 
      7th Jul 2007
i need to include a line to empty recycle bin within batch file
i already include a line to display it:
explorer ::{645FF040-5081-101B-9F08-00AA002F954E}

but i now want to empty it without even opening it, i will tell you what i
have:
i beleive that it could be done through RUNDLL32.EXE shell32.dll,entry point
but i don't know the right one, in registry i found this key (search for it)
@shell32.dll,-31331 with value= Empty the Recycle Bin, i thought it was
what i
want, but it is not and this value is the text will appear in the tasks
panel in
RecycleBin window.
another thing:
i already found the entry point it is SHEmptyRecycleBin and when i right
the line
like that: RUNDLL32.EXE shell32.dll,SHEmptyRecycleBin in start>run or in
Cmd.exe
it appears that it accept it and no error originates, but it does nothing.

please, any help will be useful
 
Reply With Quote
 
 
 
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      7th Jul 2007

"dr_ahmed" <(E-Mail Removed)> wrote in message
news:A62C0CDE-2C29-4CCC-A9BF-(E-Mail Removed)...
>i need to include a line to empty recycle bin within batch file
> i already include a line to display it:
> explorer ::{645FF040-5081-101B-9F08-00AA002F954E}
>
> but i now want to empty it without even opening it, i will tell you what i
> have:
> i beleive that it could be done through RUNDLL32.EXE shell32.dll,entry
> point
> but i don't know the right one, in registry i found this key (search for
> it)
> @shell32.dll,-31331 with value= Empty the Recycle Bin, i thought it was
> what i
> want, but it is not and this value is the text will appear in the tasks
> panel in
> RecycleBin window.
> another thing:
> i already found the entry point it is SHEmptyRecycleBin and when i right
> the line
> like that: RUNDLL32.EXE shell32.dll,SHEmptyRecycleBin in start>run or in
> Cmd.exe
> it appears that it accept it and no error originates, but it does
> nothing.
>
> please, any help will be useful


You could simply delete all files in the Recycle Bin:

del /s /q C:\RECYCLER\S-1-5-21-4233798886-620521722-3728218106-1004


 
Reply With Quote
 
Ayush
Guest
Posts: n/a
 
      7th Jul 2007
[dr_ahmed] wrote-:
> i need to include a line to empty recycle bin within batch file
> i already include a line to display it:
> explorer ::{645FF040-5081-101B-9F08-00AA002F954E}
>


You can use a WSH script and run it from your batch file like:
cscript //nologo Scriptpath


---JScript:


Bin=new ActiveXObject("Shell.Application").NameSpace(10).Self
Bin.InvokeVerbEx("Empty recycle &bin")


---VBScript:

Set Bin=CreateObject("Shell.Application").NameSpace(10).Self
Bin.InvokeVerbEx("Empty recycle &bin")


Good Luck, Ayush.
--
XP-Tips & Tricks [Use keyboard shortcuts] :
http://www.microsoft.com/windowsxp/u...shortcuts.mspx
 
Reply With Quote
 
=?Utf-8?B?ZHJfYWhtZWQ=?=
Guest
Posts: n/a
 
      7th Jul 2007
when i tried that it tolds me that: The system cannot find the file specified.
i just copy and paste it
 
Reply With Quote
 
=?Utf-8?B?ZHJfYWhtZWQ=?=
Guest
Posts: n/a
 
      7th Jul 2007
when i tried that it tolds me :The system cannot find the file specified.
i just copy and pste it
 
Reply With Quote
 
=?Utf-8?B?ZHJfYWhtZWQ=?=
Guest
Posts: n/a
 
      7th Jul 2007

it does really work, although iam not familiar with scripts
thanks for help
 
Reply With Quote
 
Vanguard
Guest
Posts: n/a
 
      7th Jul 2007
"dr_ahmed" wrote in message
news:20594AB7-013F-490F-927B-(E-Mail Removed)...
> when i tried that it tolds me that: The system cannot find the file
> specified.
> i just copy and paste it


DO NOT RUN THE FOLLOWING BATCH SCRIPT
Only showing what could be done in a .bat file.
Running this batch script will clean out the Recycle Bin but also render
it unusable until the next reboot.

Windows will withhold permissions from some programs for "special"
folders. You cannot use the 'del' command at a DOS prompt. Instead use
the 'for' command to walk through every subfolder to delete the files
within each one. The 'for', like the 'cd' command, will let you
navigate into those special folders and then you can use relative
references to delete the files.

pushd
C:
for /r c:\recycler %I in (.) do (
cd /d "%I"
attrib -h -s *
del /f /q *
)
popd

The above works from the DOS prompt. In a batch file, you need to
double up on the percent signs; i.e., %I becomes %%I. That is to ensure
the command parser sees in a batch file that you are identifying a
replaceable parameter (variable) rather than trying to retrieve its
value.

- The /r switch means to recurse through the subfolders. The 'for'
command can get into special folders that 'del' cannot.
- The "." for the set will return the list of subfolders rather than
files (since 'del' might not work into the special folder).
- The /d switch is required on the 'cd' command to ensure that you
actually change to that path when you follow with the 'attrib' and 'del'
commands. Otherwise, 'cd' (without /d) while you are on D: would end up
changing the working path on C: but you are still on D: when the
'attrib' and 'del' command executed which means you would be deleting
the wrong files.
- I added the C: just before the for-loop merely for precaution to
ensure you really are on the C: drive in case 'cd' doesn't have the /d
switch in your version of Windows.
- 'del' won't work on files with the hidden and system file attributes,
so 'attrib' removes those.
- The pushd saves where you were before changing drives/folders using
'cd /d' and popd returns you there. That way, you won't be left in some
subfolder that is different than where you started.

The above only delete the files. It won't delete any subfolders under
the <d>:\Recycler folder.

Yeah, while the above will delete the deleted files from the Recycle Bin
but it also deletes configuration files used by the Recycle Bin. When
you delete all the files, the config files are also deleted. The
Recycle Bin won't work after that; i.e., you can still delete files but
they won't get moved into the Recycle Bin. To see that the above batch
script actually works (too well), you could replace 'del /f /q *' with
'dir'. In fact, you could replace both the 'attrib' and 'del' commands
with 'dir /ah'. Then instead of deleting the files, you get a directory
listing of them in case you are curious as to what is in there.


Rather than figure out which files to delete, there are a couple
options:

1 - Delete the folder.

rmdir /s /q c:\recycler

This deletes the Recycle Bin folder (on the C: drive). That means
deleted files will no longer be saved in the Recycle Bin anytime after
that in your Windows session because the save folder doesn't exist
anymore. When you reboot Windows, and after the first file that you
delete, Windows will recreate the Recycler folder. That means you
delete the folder and reboot to continue using a cleaned up Recycle Bin.

2 - Use the Disk Clean utility.

Read http://support.microsoft.com/kb/253597/en-us. cleanmgr.exe is the
same program as Disk Cleanup found under Start -> Programs ->
Accessories -> System Tools -> Disk Cleanup. Note that cleanmgr.exe ran
from the command-line will not prompt on which drive to do the cleanup,
so all local hard drives get cleaned up using the same settings that you
specify. To me, this is handy in that I don't need to save settings for
each drive and repeatedly execute cleanmgr.exe on each one. First run:

cleanmgr.exe /sageset:1

to save the settings (in the registry). Then run:

cleanmgr.exe /sagerun:1

in your .bat file or as a scheduled task to do the cleanup. You can use
whatever number you like in the range of 0 to 64K under which to save
the settings for a drive. You could use 0 to have all items selected
for a full cleanup, 1 is for just the temp files and Recycle Bin, 2 is
just offline files, etc. I'd much prefer using strings so I could use
names that help me remember what each set of settings will do but it's
not my program.

When the window pops open in which you select what items to purge, I
select all of them except the last 3 (offline files, compress old files,
catalog files for indexer). The purpose of offline files is to have a
local copy if the file server becomes unavailable. I'm not going to
waste time compressing "old" files and then have to uncompress them
later. The program still wastes time calculating how much space would
be returned by using compression but I don't want it to actually do any
compression. I'll buy a bigger drive instead. I don't run the Indexing
Service (it is Disabled) but even if I did then I wouldn't want it to
consume CPU cycles and data bus bandwidth to reindex everything again.

This is probably the safest way included in Windows to do the cleanup
other than to use a 3rd party tool, like CCleaner (CrapCleaner). You
can specify to include the Recycle Bin in the saved settings. Because
it is a GUI program with command-line switches, you will still see its
window pop open when you run cleanmgr.

 
Reply With Quote
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      7th Jul 2007

"dr_ahmed" <(E-Mail Removed)> wrote in message
news:20594AB7-013F-490F-927B-(E-Mail Removed)...
> when i tried that it tolds me that: The system cannot find the file
> specified.
> i just copy and paste it


This is hardly surprising. You must use the correct SID that
applies to your logon account, not the one that applies to mine!


 
Reply With Quote
 
Ayush
Guest
Posts: n/a
 
      9th Jul 2007
[dr_ahmed] wrote-:
>
> it does really work, although iam not familiar with scripts
> thanks for help


Save the JScript code as .js file and in your batch file, add the following line when
you want to run the script (to empty recycle bin):

cscript //NoLogo JS-FILE-PATH

e.g.
cscript //nologo c:\scripts\empty.js


Good Luck, Ayush.
--
XP-Tips [Add a Map Drive button to the toolbar] :
http://www.microsoft.com/windowsxp/u.../mdbutton.mspx
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A script/batch to kill a batch file from scheduled tasks? Bogdan Windows XP Configuration 1 31st Jul 2009 06:05 AM
batch file call from a macro - how ? and required batch format VB-rookie Microsoft Excel Programming 3 5th Sep 2008 10:33 PM
calling multiple batch files from within a batch file yawnmoth Windows XP General 3 26th May 2008 06:47 PM
Save batch window msgs to a file from the batch prog Stephen Rainey Windows XP General 3 10th Jan 2007 12:50 AM
Photo Editor Batch supporting batch compression JPG files 29150 Freeware 2 23rd Jun 2003 06:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:22 PM.