Jump to content

DirRemove question


fly
 Share

Recommended Posts

Okay, this is some code I have in a function:

ElseIf FileExists($datastore & "\" & GUICtrlRead($userCombo)) Then
        $overwrite = MsgBox(20, "Uh-oh", "Directory already found for user.  Overwrite?")
            If $overwrite = 6 Then
            ;MsgBox(0, "del", "deleting dir: |" & $datastore & "\" & GUICtrlRead($userCombo) & "|")
            ;DirRemove($datastore & "\" & GUICtrlRead($userCombo), 1)
                $vUserCombo = GUICtrlRead($userCombo)
            ;$datastore = "\\usmtserv1\backup$"
                $test = DirRemove($datastore & "\" & $vUserCombo, 1)
                MsgBox(0, "fdsf", $test)
            Else
                MsgBox(0, "Well then...", "Please remove/rename existing datastore directory")
            EndIf

It will see that the folder exists on my server, but refuses to actually delete the folder (although I get a return code of 1, saying it was successfully deleted.) What am I doing wrong? Please excuse the comments, I've been running tests to try and see what I'm doing wrong.

Thanks for any help.

Link to comment
Share on other sites

Could it be a permissions issue.

Have you tried deleting manually to check if it can be done outside of the script.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Yes. I can def delete the folder. sorry, I should have mentioned that.

Try using the DirRemove command with the full pathname instead of variable to see if that does it.

I am clutching at straws here.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Try using the DirRemove command with the full pathname instead of variable to see if that does it.

I am clutching at straws here.

Nope.

Hmmm

If I take the DirRemove out of the function, it works fine.

Link to comment
Share on other sites

Nope.

Hmmm

If I take the DirRemove out of the function, it works fine.

Can you msgbox $userCombo before DirRemove to see if there's any unwanted characters in there?

Or

msgbox(0, "", $datastore & "\" & GUICtrlRead($userCombo))

If that's Ok then maybe...

$Dir2Rem = $datastore & "\" & GUICtrlRead($userCombo)
DirRemove($Dir2Rem, 1)

Ben

Link to comment
Share on other sites

Can you msgbox $userCombo before DirRemove to see if there's any unwanted characters in there?

Or

msgbox(0, "", $datastore & "\" & GUICtrlRead($userCombo))

If that's Ok then maybe...

$Dir2Rem = $datastore & "\" & GUICtrlRead($userCombo)
DirRemove($Dir2Rem, 1)
Yeah, I put in

MsgBox(0, "del", "deleting dir: |" & $datastore & "\" & GUICtrlRead($userCombo) & "|")

to see if there were any extra characters or spaces, and everything looked right.

The 2nd code you gave me also gives me a return code of 1, meaning it deleted, but didn't delete anything either.

Link to comment
Share on other sites

Could the "$" in $datastore = "\\usmtserv1\backup$" be causing problems.

Still clutching at straws.

Edit - If it is you could map a drive letter to it instead.

Edited by BigDod


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Could the "$" in $datastore = "\\usmtserv1\backup$" be causing problems.

Still clutching at straws.

Edit - If it is you could map a drive letter to it instead.

Good thought. I tried mapping the drive like this:

$Dir2Rem = "U:\" & GUICtrlRead($userCombo)
                $test = DirRemove($Dir2Rem, 1)
                MsgBox(0, "fdsf", $test)

Still didn't work. I have to be doing something wrong, cause it works outside the function...

Link to comment
Share on other sites

Could you post the whole function to see if that gives some clues.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Are you trying to delete the contents of the share? or are you trying to remove the share from the computer?

if anyone else is using any file from within that pipe, it will not let you delete the item unless you close the session.

Edited by blademonkey

---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Link to comment
Share on other sites

Could you post the whole function to see if that gives some clues.

Here it is. I write horrible code. B)

Func checkNullVars()
    MsgBox(0, "fdsa", "checkNullVars()")
    If Not GUICtrlRead($userCombo) Then; Check that an ID was selected
        SetError(1)
        Return("User ID not selected.")
    ElseIf GUICtrlRead($loadGroupY) = 1 Then; If 'load to new' is selected, check all this crap
        If Not GUICtrlRead($adminID) Then
            SetError(1)
            Return("Administrator ID not entered.")
        ElseIf Not GUICtrlRead($adminPass) Then
            SetError(1)
            Return("Administrator password not entered.")
        ElseIf Not GUICtrlRead($newPC) Then
            SetError(1)
            Return("New PC name not entered.")
        EndIf
    ElseIf FileExists($datastore & "\" & GUICtrlRead($userCombo)) Then
        $overwrite = MsgBox(20, "Uh-oh", "Directory already found for user.  Overwrite?")
            If $overwrite = 6 Then
            ;MsgBox(0, "del", "deleting dir: |" & $datastore & "\" & GUICtrlRead($userCombo) & "|")
            ;DirRemove($datastore & "\" & GUICtrlRead($userCombo), 1)
            ;$vUserCombo = GUICtrlRead($userCombo)
            ;$datastore = "\\usmtserv1\backup$"
            ;DirRemove("\\usmtserv1\backup$\holmesz", 1)
                Dim $Dir2Rem
            ;$Dir2Rem = $datastore & "\" & GUICtrlRead($userCombo)
                $Dir2Rem = "U:\" & GUICtrlRead($userCombo)
                $test = DirRemove($Dir2Rem, 1)
                MsgBox(0, "fdsf", $test)
            Else
                MsgBox(0, "Well then...", "Please remove/rename existing datastore directory")
            EndIf
    Else; Everything checks out!
        SetError(0)
        Return("")
    EndIf

EndFunc
Link to comment
Share on other sites

Here it is. I write horrible code. B)

Func checkNullVars()
    MsgBox(0, "fdsa", "checkNullVars()")
    If Not GUICtrlRead($userCombo) Then; Check that an ID was selected
        SetError(1)
        Return("User ID not selected.")
    ElseIf GUICtrlRead($loadGroupY) = 1 Then; If 'load to new' is selected, check all this crap
        If Not GUICtrlRead($adminID) Then
            SetError(1)
            Return("Administrator ID not entered.")
        ElseIf Not GUICtrlRead($adminPass) Then
            SetError(1)
            Return("Administrator password not entered.")
        ElseIf Not GUICtrlRead($newPC) Then
            SetError(1)
            Return("New PC name not entered.")
        EndIf
    ElseIf FileExists($datastore & "\" & GUICtrlRead($userCombo)) Then
        $overwrite = MsgBox(20, "Uh-oh", "Directory already found for user.  Overwrite?")
            If $overwrite = 6 Then
            ;MsgBox(0, "del", "deleting dir: |" & $datastore & "\" & GUICtrlRead($userCombo) & "|")
            ;DirRemove($datastore & "\" & GUICtrlRead($userCombo), 1)
            ;$vUserCombo = GUICtrlRead($userCombo)
            ;$datastore = "\\usmtserv1\backup$"
            ;DirRemove("\\usmtserv1\backup$\holmesz", 1)
                Dim $Dir2Rem
            ;$Dir2Rem = $datastore & "\" & GUICtrlRead($userCombo)
                $Dir2Rem = "U:\" & GUICtrlRead($userCombo)
                $test = DirRemove($Dir2Rem, 1)
                MsgBox(0, "fdsf", $test)
            Else
                MsgBox(0, "Well then...", "Please remove/rename existing datastore directory")
            EndIf
    Else; Everything checks out!
        SetError(0)
        Return("")
    EndIf

EndFunc
Ah, I didn't even notice he was referencing a hiddenshare. It might not be so much a problem with the $ sign in the name, but perhaps how AutoIT works with the filesystem - which I'm not even sure how that is. Does DirRemove just send API's? I don't know, but one thing to try is to create another share for backup$ that isn't hidden.

Ben

Link to comment
Share on other sites

  • Developers

Does DirRemove just send API's? I don't know, but one thing to try is to create another share for backup$ that isn't hidden.

It uses the standard RemoveDirectory() function for none recursion directory deletion.

It is using SHFileOperation for FIle& recursion deletion.

Could it be that Hidden files are not deleted and thus the file isn't delete ?

EDIT: updated

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Ah, I didn't even notice he was referencing a hiddenshare. It might not be so much a problem with the $ sign in the name, but perhaps how AutoIT works with the filesystem - which I'm not even sure how that is. Does DirRemove just send API's? I don't know, but one thing to try is to create another share for backup$ that isn't hidden.

I tried it from another directory that wasn't behind a hidden share, and that deleted. Odd that it happens even if you map the hidden share, and that it only happens in a function...

Would this qualify as a bug?

edit: I didn't actually try the same directory, I tried to delete a folder in another directory from that function. I'll try resharing that backup$ directory tomorrow unhidden and give it a full test. Leaving for the day. Thanks for the help!

Edited by fly
Link to comment
Share on other sites

I tried it from another directory that wasn't behind a hidden share, and that deleted. Odd that it happens even if you map the hidden share, and that it only happens in a function...

Would this qualify as a bug?

edit: I didn't actually try the same directory, I tried to delete a folder in another directory from that function. I'll try resharing that backup$ directory tomorrow unhidden and give it a full test. Leaving for the day. Thanks for the help!

Oooook.

I have no idea what is going on here. I tried it from an unhidden share, and it still refuses to delete. I am using the beta, if that matters...

Link to comment
Share on other sites

are you the only 1 using this dir?

if there's just 1 more person using it it will refuse to be deleted!

maybe you could try using dos to help you

net use | more > test.txt

to write it to a file who is using which application/folder

then you can check the file line by line if someone's using the folder you want to delete

Link to comment
Share on other sites

are you the only 1 using this dir?

if there's just 1 more person using it it will refuse to be deleted!

maybe you could try using dos to help you

to write it to a file who is using which application/folder

then you can check the file line by line if someone's using the folder you want to delete

Nope. No one is in it. Its my test server. And the return code is 1, so it thinks it deleted it...
Link to comment
Share on other sites

as i see from your script (maybe i'm wrong) your returncode should be " "

have you tried the *same* script on a different directory?

i've seen you tried something on a different directory but was it that script?

you said the dirremove works from outside the function (on that dir?)

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...