Jump to content

obj failing, recyclebin object?


Recommended Posts

hello,

i tried porting this script to autoit, because theres no way to calculate how much space is used in the recycle bin, atleast that i know of, the problem is that i keep getting 'The requested action with this object has failed.:' what did i do wrong??? :whistle:

#cs
WSH script
http://www.microsoft.com/technet/scriptcenter/resources/qanda/may06/hey0501.mspx
Const RECYCLE_BIN = &Ha&
Const FILE_SIZE = 3

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(RECYCLE_BIN)

Set colItems = objFolder.Items

For Each objItem in colItems
    strSize = objFolder.GetDetailsOf(objItem, FILE_SIZE)
    arrSize = Split(strSize, " ")
    intSize = intSize + CLng(arrSize(0))
Next

Wscript.Echo intSize & " KB"
#ce


Const $RECYCLE_BIN = '&Ha&'
Const $FILE_SIZE = 3

Local $objShell = ObjCreate("Shell.Application")
Local $objFolder = $objShell.Namespace($RECYCLE_BIN)

Local $colItems = $objFolder.Items
Local $strSize, $intSize

For $objItem in $colItems
    $strSize = $objFolder.GetDetailsOf($objItem, $FILE_SIZE)
    $arrSize = StringSplit($strSize, " ")
    $intSize = $intSize + $arrSize(0)
Next

ConsoleWrite( $intSize & " KB")
Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Link to comment
Share on other sites

hello,

i tried porting this script to autoit, because theres no way to calculate how much space is used in the recycle bin, atleast that i know of, the problem is that i keep getting 'The requested action with this object has failed.:' what did i do wrong??? :whistle:

#cs
WSH script
http://www.microsoft.com/technet/scriptcenter/resources/qanda/may06/hey0501.mspx
Const RECYCLE_BIN = &Ha&
Const FILE_SIZE = 3

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(RECYCLE_BIN)

Set colItems = objFolder.Items

For Each objItem in colItems
    strSize = objFolder.GetDetailsOf(objItem, FILE_SIZE)
    arrSize = Split(strSize, " ")
    intSize = intSize + CLng(arrSize(0))
Next

Wscript.Echo intSize & " KB"
#ce
Const $RECYCLE_BIN = '&Ha&'
Const $FILE_SIZE = 3

Local $objShell = ObjCreate("Shell.Application")
Local $objFolder = $objShell.Namespace($RECYCLE_BIN)

Local $colItems = $objFolder.Items
Local $strSize, $intSize

For $objItem in $colItems
    $strSize = $objFolder.GetDetailsOf($objItem, $FILE_SIZE)
    $arrSize = StringSplit($strSize, " ")
    $intSize = $intSize + $arrSize(0)
Next

ConsoleWrite( $intSize & " KB")
oÝ÷ Ûú®¢×¶ÇËhmëaz«·­Mú¡¸ß¢W^®+^Â-®'Ü"¶¬h¥j»®*mjëh×6
Const $RECYCLE_BIN = "&Ha&"

$objShell = ObjCreate("Shell.Application")
$objFolder = $objShell.Namespace($RECYCLE_BIN)
$objFolderItem = $objFolder.Self
MsgBox (0, "", $objFolderItem.Path)
$colItems = $objFolder.Items

For $objItem in $colItems
    MsgBox(0, "", $objItem.Name)
Next

And it too failed?

Link to comment
Share on other sites

It seems to be the part with $objfolder.items......... I tried it with a similar script:

Const $RECYCLE_BIN = "&Ha&"

$objShell = ObjCreate("Shell.Application")
$objFolder = $objShell.Namespace($RECYCLE_BIN)
$objFolderItem = $objFolder.Self
MsgBox (0, "", $objFolderItem.Path)
$colItems = $objFolder.Items

For $objItem in $colItems
    MsgBox(0, "", $objItem.Name)
Next

And it too failed?

hmm.. didn't work for me either..
Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Link to comment
Share on other sites

&Ha& isn't a string but a hex value - 10

also, the array element in your For loop needs [] rather than ()

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

&Ha& isn't a string but a hex value - 10

also, the array element in your For loop needs [] rather than ()

Dale

thanks dale,

i had a gut feeling &Ha& was wrong.. :whistle: it's returning the wrong values now.. have to look into that Clng function

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Link to comment
Share on other sites

This worked for me.... I'm pretty sure it return the right values:

#cs
WSH script
http://www.microsoft.com/technet/scriptcen...06/hey0501.mspx
Const RECYCLE_BIN = &Ha&
Const FILE_SIZE = 3

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(RECYCLE_BIN)

Set colItems = objFolder.Items

For Each objItem in colItems
    strSize = objFolder.GetDetailsOf(objItem, FILE_SIZE)
    arrSize = Split(strSize, " ")
    intSize = intSize + CLng(arrSize(0))
Next

Wscript.Echo intSize & " KB"
#ce


Const $RECYCLE_BIN = 10
Const $FILE_SIZE = 3

Local $objShell = ObjCreate("Shell.Application")
If IsObj ($objShell) Then
    
Else
    MsgBox (0, "ERROR", "Shell.Application is not an object.")
EndIf
Local $objFolder = $objShell.Namespace($RECYCLE_BIN)

Local $colItems = $objFolder.Items
Local $strSize, $intSize

For $objItem in $colItems
    $strSize = $objFolder.GetDetailsOf($objItem, $FILE_SIZE)
    $arrSize = StringTrimRight($strSize, 3)
    $intSize = $intSize + $arrSize
Next

ConsoleWrite( $intSize & " KB")

I changed the stringsplit to a string trim and it worked.... First time it was 34.... The i changed it and came 2852.... Pretty much perfect now....

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...