Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Delete folders on a different Server

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,36297
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Delete folders on a different Server
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Delete folders on a different Server - 7/19/2006 2:44:43 AM   
  fvlmasl2

 

Posts: 10
Score: 0
Joined: 7/19/2006
Status: offline
Hello All,

New to this forum and somewhat new to VBscript.  I have this script below and works fine if everything is located on my pc.  But I need to do this folder delete on a different server.  is it possible within this script?


Thanks
Frank



Const DeleteReadOnly = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\Documents and Settings\All Users\Application Data\FormScapeSoftware\data\Logs" )
Set colSubfolders = objFolder.Subfolders
For Each objSubfolder in colSubfolders
   If DateAdd("d",-30, Now()) > objSubfolder.DateCreated then 
       objFSO.deletefolder  objSubfolder, DeleteReadOnly 
   End If
Next

Set objFSO = Nothing
Set objFolder = Nothing
Set objSubFolder = Nothing
Set colSubfolders = Nothing
Wscript.Quit
 
 
Post #: 1
 
 RE: Delete folders on a different Server - 7/19/2006 5:02:39 AM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
Hiya Frank, welcome...

I don't see why it wouldn't be possible...IF the folder actually exists ofcourse..

You could better place an FolderExists before running the FolderDelete process..

What have you tried for it to work on a different server?

Snipah

_____________________________

For more information, please see the "Read me First" topic.

http://www.visualbasicscript.com

(in reply to fvlmasl2)
 
 
Post #: 2
 
 RE: Delete folders on a different Server - 7/19/2006 6:18:01 AM   
  fvlmasl2

 

Posts: 10
Score: 0
Joined: 7/19/2006
Status: offline
I tried directing as below.....


This is the original
Set objFolder = objFSO.GetFolder("C:\Documents and Settings\All Users\Application Data\FormScapeSoftware\data\Logs" )


This is what I tried
Set objFolder = objFSO.GetFolder("\\svrapps1\Documents and Settings\All Users\Application Data\FormScapeSoftware\data\Logs" )

(in reply to fvlmasl2)
 
 
Post #: 3
 
 RE: Delete folders on a different Server - 7/19/2006 6:52:00 AM   
  ebgreen


Posts: 4969
Score: 31
Joined: 7/12/2005
Status: online
Did it work? Did you get errors? What were the errors? Did nothing happen?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to fvlmasl2)
 
 
Post #: 4
 
 RE: Delete folders on a different Server - 7/19/2006 7:51:35 AM   
  Country73


Posts: 732
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
Do you have a typo on the line that you tried for your server?

Shouldn't it be something like:

Set objFolder = objFSO.GetFolder("\\svrapps1\C$\Documents and Settings\All Users\Application Data\FormScapeSoftware\data\Logs" )

(in reply to fvlmasl2)
 
 
Post #: 5
 
 RE: Delete folders on a different Server - 7/19/2006 12:47:07 PM   
  fvlmasl2

 

Posts: 10
Score: 0
Joined: 7/19/2006
Status: offline
With both the ways I have tried I keep getting "Path not found" error.

Thanks for the suggestions........any other ideas?

fvlmasl2

(in reply to Country73)
 
 
Post #: 6
 
 RE: Delete folders on a different Server - 7/19/2006 11:43:05 PM   
  Country73


Posts: 732
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
Did you try what Snipah suggested?


Const DeleteReadOnly = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
IF objFSO.FolderExists("\\svrapps1\C$\Documents and Settings\All Users\Application Data\FormScapeSoftware\data\Logs" )
  Set objFolder = objFSO.GetFolder("\\svrapps1\C$\Documents and Settings\All Users\Application Data\FormScapeSoftware\data\Logs" )
  Set colSubfolders = objFolder.Subfolders
  For Each objSubfolder in colSubfolders
      If DateAdd("d",-30, Now()) > objSubfolder.DateCreated then 
          objFSO.deletefolder  objSubfolder, DeleteReadOnly 
    End If
  Next
  Set objFSO = Nothing
  Set objFolder = Nothing
  Set objSubFolder = Nothing
  Set colSubfolders = Nothing
END IF
Wscript.Quit

(in reply to fvlmasl2)
 
 
Post #: 7
 
 RE: Delete folders on a different Server - 7/19/2006 11:43:05 PM   
  ebgreen


Posts: 4969
Score: 31
Joined: 7/12/2005
Status: online
Please post the actual code that you are running.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to fvlmasl2)
 
 
Post #: 8
 
 RE: Delete folders on a different Server - 7/20/2006 12:11:36 AM   
  fvlmasl2

 

Posts: 10
Score: 0
Joined: 7/19/2006
Status: offline
The original code was posted in my first post.  That works well if I create a duplicate envirnment on my local machine.  When I run the one below from my local machine to delete folders on the particular server I keep getting the "Path Not Found" error, I tried with the If folderexists and i get the same error.  Both times the line number was the one with the given path.  Can someone give it a try?  I realize some of the logic has to be changed but any insight into this would be great.

Thanks again for the help.....
fvlmasl2



Const DeleteReadOnly = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("\\svrapps1\C$\Documents and Settings\All Users\Application Data\FormScapeSoftware\data\Logs" )
Set colSubfolders = objFolder.Subfolders
For Each objSubfolder in colSubfolders
   If DateAdd("d",-30, Now()) > objSubfolder.DateCreated then 
        objFSO.deletefolder  objSubfolder, DeleteReadOnly 
  End If
Next

Set objFSO = Nothing
Set objFolder = Nothing
Set objSubFolder = Nothing
Set colSubfolders = Nothing
Wscript.Quit

(in reply to ebgreen)
 
 
Post #: 9
 
 RE: Delete folders on a different Server - 7/20/2006 1:35:11 AM   
  ebgreen


Posts: 4969
Score: 31
Joined: 7/12/2005
Status: online
Are you absolutely certain that you have rights to that share?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to fvlmasl2)
 
 
Post #: 10
 
 RE: Delete folders on a different Server - 7/20/2006 3:46:45 AM   
  fvlmasl2

 

Posts: 10
Score: 0
Joined: 7/19/2006
Status: offline
I tried to access the folder \\svrapps1\C$  from my start - run and it is asking for my credentials.  Will this cause the path not found error.



Thanks
fvlmasl2

(in reply to ebgreen)
 
 
Post #: 11
 
 RE: Delete folders on a different Server - 7/20/2006 4:03:13 AM   
  ebgreen


Posts: 4969
Score: 31
Joined: 7/12/2005
Status: online
Yes. I would suggest posssibly mapping a drive in the script. I think that you can pass credentials then.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to fvlmasl2)
 
 
Post #: 12
 
 RE: Delete folders on a different Server - 7/20/2006 4:16:47 AM   
  fvlmasl2

 

Posts: 10
Score: 0
Joined: 7/19/2006
Status: offline
Is there a sample with the mapping that may shed some light as to how I can incorporate it into my script.


Thanks
Frank

(in reply to ebgreen)
 
 
Post #: 13
 
 RE: Delete folders on a different Server - 7/20/2006 4:29:00 AM   
  ebgreen


Posts: 4969
Score: 31
Joined: 7/12/2005
Status: online
There is a perfectly good example in the WSH documentation which can be obtained by reading the "Read Me First" post that is pinned at the top of this forum.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to fvlmasl2)
 
 
Post #: 14
 
 RE: Delete folders on a different Server - 7/20/2006 5:53:51 AM   
  fvlmasl2

 

Posts: 10
Score: 0
Joined: 7/19/2006
Status: offline
I'm sorry but I can't seem to find anything for me to incorporate.  I looked at buildpath, server.createobject,  I just can't put all the peices together.


Thanks
fvlmasl2

(in reply to ebgreen)
 
 
Post #: 15
 
 RE: Delete folders on a different Server - 7/20/2006 6:20:05 AM   
  ebgreen


Posts: 4969
Score: 31
Joined: 7/12/2005
Status: online
In the WSH documentation, click on the Index tab. Then type 'map' into the find box. the item that should be highlighted is the
MapNetworkDrive Method
that topic will explain how to map a network drive giving user name and password.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to fvlmasl2)
 
 
Post #: 16
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Delete folders on a different Server Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts