Link to home
Start Free TrialLog in
Avatar of keizerpiet
keizerpiet

asked on

closing a 'pipeline' (open connection to a server share) from VBSCRIPT

Hi all,

I have a problem with a script.
When I copy data from a server share and then delete the share I receive the error:

Err ID: 46 "Permission Denied"

This happens when copying and deleting is done in the same run of the script.

But when I run the script copy, don't delete it works fine
and
when I run the script don't copy/delete it works fine also.

But I want both functions into one run of the script. It looks to me there is still a connection (from the copying) which is not closed, that maybe the reason I receive the error.

I do have enough permissions to copy/delete etc from the server share.

A summary of the code:
==========

<object id="objFSO"             progid="Scripting.FileSystemObject"/>


Set TestFolder = objFSO.GetFolder("\\" & strServernaam & "\" & testfolder) 'This is correct!
IF Err.Number <> 0 THEN
   tsLogFile.WriteLine "    [DeleteShare] ERROR: Error ID: " & Hex(Err.Number) & " " & Err.Description            
   err.clear
ELSE
   err.clear
   TestFolder.Delete
    IF Err.Number <> 0 THEN
      tsLogFile.WriteLine "    [DeleteShare] ERROR: share could not be deleted. Error ID:" & Hex(Err.Number) & " " & Err.Description
    ELSE
      tsLogFile.WriteLine "    [DeleteShare] Success: share succesfully deleted"
   END IF
END IF

==========

The error occurs after the testfolder.delete command. When I put a SLEEP 60000 command before deleting (maybe it needs some time for closing the connection) it does not matter.

Any help? I'm thinking of an open connection... but how to close... Thanks!

Best Regards,

P. Keizer
(the Netherlands)

Avatar of EDDYKT
EDDYKT
Flag of Canada image

Set TestFolder = nothing

and then reopen by using

Set TestFolder = objFSO.GetFolder("\\" & strServernaam & "\" & testfolder) 'This is correct!


?
ASKER CERTIFIED SOLUTION
Avatar of RanjeetRain
RanjeetRain

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of keizerpiet
keizerpiet

ASKER

the Set Nothing does not work all the time.... I keep something the Permission Denied error.

Mapping could work, but we are not allowed to map drive unfortunately.

Is there a way by viewing active 'pipes' or access made to a drive/folder?

Thanks for the replies so far!