473,472 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Please Help my script wont work even after it executes correctly.

1 New Member
Expand|Select|Wrap|Line Numbers
  1. ' -----------------------------------------------------------------------------
  2. ' Aplica la politica de retencion de copias de backup en disco externo
  3. ' Menusal (M): Se guardan 6 meses
  4. ' Semanal o Full (F): Se guradan 2 meses
  5. ' Diario o Incremental (I): Se guardan 4 semanas
  6. ' -----------------------------------------------------------------------------
  7.  
  8. On Error Resume Next
  9.  
  10. dCurrentDate = Now
  11.  
  12. a = ApplyPolicy("F:\Backups")
  13. a = ApplyPolicy("F:\Control")
  14. a = ApplyPolicy("F:\Logs")
  15.  
  16. WScript.Quit 0
  17.  
  18. ' -----------------------------------------------------------------------------
  19. ' Esta funcion aplica la politica de retencion de backup en disco externo
  20. ' -----------------------------------------------------------------------------
  21. Function ApplyPolicy(sFolder)
  22.    Dim oFS, oFP, oFiles, oFC
  23.  
  24.    Set oFS = CreateObject("Scripting.FileSystemObject")
  25.    sAbsFolder = oFS.GetAbsolutePathName(sFolder)
  26.    WScript.Echo "Processing " & sAbsFolder
  27.    bRetVal = oFS.FolderExists(sAbsFolder)
  28.    Set oFP = oFS.GetFolder(sAbsFolder)
  29.    Set oFiles = oFP.Files
  30.    For each oFC in oFiles
  31.       sFileName = oFC.Name
  32.       sFilePrefix = Left(sFileName, 15)
  33.       sFullFileName = oFS.BuildPath(sAbsFolder, sFileName)
  34.       dBackupDate = oFC.DateCreated
  35.       If sFilePrefix = "Backup_M_PlaTON" Then
  36.          If (Month(dBackupDate) - Month(dCurrentDate)) > 6 Then
  37.             WScript.Echo " DEL => " & sFileName & " (" & dBackupDate & ")"
  38.             b = oFS.DeleteFile(sFullFileName, true)
  39.          Else
  40.             WScript.Echo "  Ok => " & sFileName & " (" & dBackupDate & ")"
  41.          End If
  42.       End If
  43.       If sFilePrefix = "Backup_F_PlaTON" Then
  44.          If (Month(dBackupDate) - Month(dCurrentDate)) > 2 Then
  45.             WScript.Echo " DEL => " & sFileName & " (" & dBackupDate & ")"
  46.             b = oFS.DeleteFile(sFullFileName, true)
  47.          Else
  48.             WScript.Echo "  Ok => " & sFileName & " (" & dBackupDate & ")"
  49.          End If
  50.       End If
  51.       If sFilePrefix = "Backup_I_PlaTON" Then
  52.          If (dBackupDate - dCurrentDate) > 30 Then
  53.             WScript.Echo " DEL => " & sFileName & " (" & dBackupDate & ")"
  54.             b = oFS.DeleteFile(sFullFileName, true)
  55.          Else
  56.             WScript.Echo "  Ok => " & sFileName & " (" & dBackupDate & ")"
  57.          End If
  58.       End If
  59.    Next
  60.  
  61.    ApplyPolicy = bRetVal
  62. End Function
Please can someone help me out I'm losing my hair over this situation.
Sep 4 '07 #1
4 1085
Killer42
8,435 Recognized Expert Expert
What situation? You haven't told us what the problem is.

If it "executes correctly" then in what way can it be said to not work?

Also, It might also help if you could fill in more detail about the script. Since you refer to it as a "script", this is in VBA, right? If so, in what application? If not, what version of VB is it?
Sep 6 '07 #2
Killer42
8,435 Recognized Expert Expert
After a quick glance at it I can at least give you one tip. Use the DateDiff() function to determine how far apart two dates are. The Month() function just returns a number between 1 and 12, which can produce strange results.

For example, take these two dates...
5th September 2007
1st January 2008.
The Month() function will simply return 9 and 1, respectively, which is pointless for comparison purposes. On the other hand, feed them into DateDiff() function and you can find out how far apart they are in...
Years : 1 (I guess it rounds up)
Months : 4
Weeks : 16
Days : 118
Seconds : 10195200
Sep 6 '07 #3
hariharanmca
1,977 Top Contributor
I suggest every one to do not use

Expand|Select|Wrap|Line Numbers
  1. On Error Resume Next
It will not throw any error then; how can be possible to get what is the status?

Better use

Expand|Select|Wrap|Line Numbers
  1. On Error Goto ErrLable
Sep 6 '07 #4
Killer42
8,435 Recognized Expert Expert
I suggest every one to do not use
Expand|Select|Wrap|Line Numbers
  1. On Error Resume Next
Good point.

I do sometimes use that statement, but generally because I want to be able to continue on and check Err.Number to see what happened. I believe this gives you something fairly similar to the new Try...Catch logic.
Sep 6 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Sticks | last post by:
ok... im not quite sure how to describe my problem. i have a php script that runs through my entire php site and writes the resulting output to html files. this is necessary as the nature of the...
9
by: Jerry | last post by:
Hi People ! I have an Urgent Problem and greatly appreciate your help: My script sends multipart emails using the MAIL_MIME package from pear.php.net Works great so far but..... ...
2
by: ASallade | last post by:
Hello, I've scoured my books and the web, but am still daunted, hopefully some of the users in this newsgroup will have advice for my problem. I am not an experienced javascript programmer,...
3
by: Daniel Bass | last post by:
where szStartDate, szEndDate, szStatus, szMsgType, szClient, szFilter are all strings declared and containing data as this code executes... ' hook up a refresh event to the refresh button Dim...
1
by: Russ | last post by:
I've been trying to get my head around this for 3 days now and it seems like everything I try does not work for one reason or another. I built a test page using the TabStrip and MultiPage controls....
1
by: Vince | last post by:
I'm using VS 2003 and I have a button in a page where I've used "btnViewData.Attributes.Add ("onclick", "javascript:return doPostBack (\"" + btnViewData.ClientID + "\");");" to have it execute...
3
by: =?Utf-8?B?SlA=?= | last post by:
<asp:GridView ID="gridResults" runat="server" AutoGenerateColumns="False" Width="98%" PageSize="25" AllowPaging="True" OnSorting="gridResults_Sorting" OnPageIndexChanging...
2
manuelgk
by: manuelgk | last post by:
Hello everybody, yesterday I have troubles with my js. It executes very well in pages that don't have a "window.onload" function, even if they have another script but, if the Web page contain a js...
118
by: Chuck Cheeze | last post by:
This might be in the wrong group, but... Here is an example of my data: entry_id cat_id 1 20 2 25 3 30 4 25 5 35
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.