home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 February / maximum-cd-2009-02.iso / DiscContents / TrueImage2009_d_en.exe / AcronisTrueImage.msi / Binary.RegisterComPlusScript < prev    next >
Encoding:
Text File  |  2008-11-21  |  17.7 KB  |  665 lines

  1. 'cscript for registering/unregistering Acronis VSS Provider
  2.  
  3. Option Explicit
  4. Dim ProviderName, ProviderDLL, ProviderDescription
  5. Dim Ok, OnRollback
  6.  
  7. Function VBScriptCA_RollbackUninst()
  8.   Ok = 1
  9.   OnRollback = 1
  10.   WriteToLog "Args passed: "&Session.Property("CustomActionData")
  11.   
  12.   Dim Args
  13.   Args = Split(Session.Property("CustomActionData"), ";")
  14.   
  15.   Dim Count, Dummy
  16.   Count = 0
  17.   WriteToLog "Parameters parsed:"
  18.   For Each Dummy In Args
  19.     Count = Count + 1
  20.     WriteToLog "  "&Dummy
  21.   Next
  22.   
  23.   If Count = 0 Then
  24.     WriteToLog "No parameters were passed"
  25.       VBScriptCA_RollbackUninst = 3
  26.       Exit Function
  27.   End If
  28.   
  29.   If Count > 0 Then
  30.     If Args(0) = "-register" AND Count = 4 Then 
  31.       WriteToLog "Uninstall rollback mode detected.."
  32.       ProviderName = Args(1)
  33.       ProviderDLL = Args(2)
  34.       ProviderDescription = Args(3)
  35.  
  36.       InstallClusterMSDTC
  37.  
  38.       If NOT Ok = 1 Then
  39.         VBScriptCA_RollbackUninst = 1
  40.         Exit Function
  41.       End If
  42.  
  43.       InstallProvider
  44.  
  45.       Err = 0
  46.     End If 
  47.   End If
  48.   VBScriptCA_RollbackUninst = 1
  49.   Exit Function
  50. End Function
  51.  
  52. Function VBScriptCA_RollbackInst()
  53.   Ok = 1
  54.   OnRollback = 1
  55.   WriteToLog "Args passed: "&Session.Property("CustomActionData")
  56.   
  57.   Dim Args
  58.   Args = Split(Session.Property("CustomActionData"), ";")
  59.   
  60.   Dim Count, Dummy
  61.   Count = 0
  62.   WriteToLog "Parameters parsed:"
  63.   For Each Dummy In Args
  64.     Count = Count + 1
  65.     WriteToLog "  "&Dummy
  66.   Next
  67.   
  68.   If Count = 0 Then
  69.     WriteToLog "No parameters were passed"
  70.     VBScriptCA_RollbackInst = 1
  71.     Exit Function
  72.   End If
  73.   
  74.   If Count > 0 Then
  75.     If Args(0) = "-unregister" AND Count = 3 Then 
  76.       WriteToLog "Rollback mode detected.."
  77.       ProviderName = Args(1)
  78.       ProviderDLL = Args(2)
  79.  
  80.       UninstallProvider
  81.  
  82.       If NOT Ok = 1 Then
  83.       VBScriptCA_RollbackInst = Ok
  84.       Exit Function
  85.       End If
  86.     End If
  87.   End If
  88.   VBScriptCA_RollbackInst = 1
  89.   Exit Function
  90. End Function
  91.  
  92. Function VBScriptCA_Uninstall()
  93.   Ok = 1
  94.   OnRollback = 0
  95.   WriteToLog "Args passed: "&Session.Property("CAUnRegisterComPLus_Acronis_VSS_Provider")
  96.   
  97.   Dim Args
  98.   Args = Split(Session.Property("CAUnRegisterComPLus_Acronis_VSS_Provider"), ";")
  99.   
  100.   Dim Count, Dummy
  101.   Count = 0
  102.   WriteToLog "Parameters parsed:"
  103.   For Each Dummy In Args
  104.     Count = Count + 1
  105.     WriteToLog "  "&Dummy
  106.   Next
  107.   
  108.   If Count = 0 Then
  109.     WriteToLog "No parameters were passed"
  110.     VBScriptCA_Uninstall = 3
  111.     Exit Function
  112.   End If
  113.   
  114.   If Count > 0 Then
  115.     If Args(0) = "-unregister" AND Count = 3 Then 
  116.       WriteToLog "Unregistering mode detected.."
  117.       ProviderName = Args(1)
  118.       ProviderDLL = Args(2)
  119.  
  120.       UninstallProvider
  121.  
  122.       If NOT Ok = 1 Then
  123.         VBScriptCA_Uninstall = Ok
  124.         Exit Function
  125.       End If
  126.     End If
  127.   End If
  128.  
  129.   VBScriptCA_Uninstall = 1
  130.   Exit Function
  131. End Function
  132.  
  133. Function VBScriptCA_Install()
  134.   Ok = 1
  135.   OnRollback = 0
  136.   WriteToLog "Args passed: "&Session.Property("CustomActionData")
  137.   
  138.   Dim Args
  139.   Args = Split(Session.Property("CustomActionData"), ";")
  140.   
  141.   Dim Count, Dummy
  142.   Count = 0
  143.   WriteToLog "Parameters parsed:"
  144.   For Each Dummy In Args
  145.     Count = Count + 1
  146.     WriteToLog "  "&Dummy
  147.   Next
  148.   
  149.   If Count = 0 Then
  150.     WriteToLog "No parameters were passed"
  151.       VBScriptCA_Install = 3
  152.       Exit Function
  153.   End If
  154.   
  155.   If Count > 0 Then
  156.     If Args(0) = "-register" AND Count = 4 Then 
  157.       WriteToLog "Registering mode detected.."
  158.       ProviderName = Args(1)
  159.       ProviderDLL = Args(2)
  160.       ProviderDescription = Args(3)
  161.  
  162.       InstallClusterMSDTC
  163.  
  164.       If NOT Ok = 1 Then
  165.         VBScriptCA_Install = Ok
  166.         Exit Function
  167.       End If
  168.  
  169.       UninstallProvider
  170.  
  171.       If NOT Ok = 1 Then
  172.         VBScriptCA_Install = Ok
  173.         Exit Function
  174.       End If
  175.  
  176.       InstallProvider
  177.  
  178.       If NOT Ok = 1 Then
  179.  
  180.         VBScriptCA_Install = Ok
  181.  
  182.         WriteToLog "Error on provider installation.."
  183.         WriteToLog "Remove " & ProviderName & ":"
  184.  
  185.         Ok = 1
  186.         UninstallProvider
  187.  
  188.         Exit Function
  189.       End If
  190.  
  191.     End If 
  192.   End If
  193.   VBScriptCA_Install = 1
  194.   Exit Function
  195. End Function
  196.  
  197. '******************************************************************************
  198. ' WriteToLogs the usage
  199. '******************************************************************************
  200. Sub WriteToLogsUsage
  201.   WriteToLog "" 
  202.   WriteToLog "Usage:" 
  203.   WriteToLog "" 
  204.   WriteToLog " 1) Registering a VSS/VDS Provider as a COM+ application:" 
  205.   WriteToLog "      CScript.exe " & Wscript.ScriptName & " -register <Provider_Name> <Provider.DLL>  <Provider_Description>" 
  206.   WriteToLog "" 
  207.   WriteToLog " 2) Unregistering a COM+ application associated with a VSS/VDS provider:" 
  208.   WriteToLog "      CScript.exe " & Wscript.ScriptName & " -unregister <Provider_Name>" 
  209.   WriteToLog "" 
  210. End Sub
  211.  
  212.  
  213. '******************************************************************************
  214. ' Installs the Provider
  215. '******************************************************************************
  216. Sub InstallProvider
  217.   On Error Resume Next
  218.  
  219.   WriteToLog "- Sleep for a second initially."
  220.   Sleep 1000
  221.   If NOT Ok = 1 Then Exit Sub
  222.  
  223.   WriteToLog "Creating a new COM+ application:" 
  224.   WriteToLog "- Creating the catalog object "
  225.   Dim cat
  226.   Set cat = CreateObject("COMAdmin.COMAdminCatalog")     
  227.   CheckError 101
  228.   If NOT Ok = 1 Then Exit Sub
  229.  
  230.   WriteToLog "- Get the Applications collection"
  231.   Dim collApps
  232.   Set collApps = cat.GetCollection("Applications")
  233.   CheckCollectionError 102, cat
  234.   If NOT Ok = 1 Then Exit Sub
  235.  
  236.   WriteToLog "- Populate..." 
  237.   collApps.Populate 
  238.   CheckCollectionError 103, collApps
  239.   If NOT Ok = 1 Then Exit Sub
  240.  
  241.   WriteToLog "- Add new application object" 
  242.   Dim app
  243.   Set app = collApps.Add 
  244.   CheckCollectionError 104, collApps
  245.   If NOT Ok = 1 Then Exit Sub
  246.  
  247.   WriteToLog "- Set app name = " & ProviderName & " "
  248.   app.Value("Name") = ProviderName
  249.   CheckObjectError 105, collApps, app
  250.   If NOT Ok = 1 Then Exit Sub
  251.  
  252.   WriteToLog "- Set app description = " & ProviderDescription & " "
  253.   app.Value("Description") = ProviderDescription 
  254.   CheckObjectError 106, collApps, app
  255.   If NOT Ok = 1 Then Exit Sub
  256.  
  257.   ' Only roles added below are allowed to call in.
  258.   WriteToLog "- Set app access check = true "
  259.   app.Value("ApplicationAccessChecksEnabled") = 1   
  260.   CheckObjectError 107, collApps, app
  261.   If NOT Ok = 1 Then Exit Sub
  262.  
  263.   ' Encrypting communication
  264.   WriteToLog "- Set encrypted COM communication = true "
  265.   app.Value("Authentication") = 6                      
  266.   CheckObjectError 108, collApps, app
  267.   If NOT Ok = 1 Then Exit Sub
  268.  
  269.   ' Secure references
  270.   WriteToLog "- Set secure references = true "
  271.   app.Value("AuthenticationCapability") = 2         
  272.   CheckObjectError 109, collApps, app
  273.   If NOT Ok = 1 Then Exit Sub
  274.  
  275.   ' Do not allow impersonation
  276.   WriteToLog "- Set impersonation = false "
  277.   app.Value("ImpersonationLevel") = 2
  278.   CheckObjectError 110, collApps, app
  279.   If NOT Ok = 1 Then Exit Sub
  280.  
  281.   WriteToLog "- Save changes..."
  282.   collApps.SaveChanges
  283.   CheckCollectionError 111, collApps
  284.   If NOT Ok = 1 Then Exit Sub
  285.  
  286.   WriteToLog "- Create Windows service running as Local System"
  287.   cat.CreateServiceForApplication ProviderName, ProviderName , "SERVICE_AUTO_START", "SERVICE_ERROR_NORMAL", "", ".\localsystem", "", 0
  288.   CheckCollectionError 112, cat
  289.   If NOT Ok = 1 Then
  290.     Ok = 1
  291.     Err = 0
  292.     WriteToLog "- Create Windows service failed."
  293.     WriteToLog "- Sleep for 3 seconds then try again.."
  294.     Sleep 3000
  295.     If NOT Ok = 1 Then Exit Sub
  296.  
  297.     WriteToLog "- Create Windows service running as Local System"
  298.     cat.CreateServiceForApplication ProviderName, ProviderName , "SERVICE_AUTO_START", "SERVICE_ERROR_NORMAL", "", ".\localsystem", "", 0
  299.     CheckCollectionError 112, cat
  300.   End If
  301.   If NOT Ok = 1 Then Exit Sub
  302.  
  303.   WriteToLog "- Add the DLL component"
  304.   cat.InstallComponent ProviderName, ProviderDLL , "", ""
  305.   CheckCollectionError 113, cat
  306.   If NOT Ok = 1 Then Exit Sub
  307.   WriteToLog "Done!"
  308.     
  309.   ' Add the new role for the Local SYSTEM account
  310.  
  311.   WriteToLog "Secure the COM+ application:"
  312.   WriteToLog "- Get roles collection"
  313.   Dim collRoles
  314.   Set collRoles = collApps.GetCollection("Roles", app.Key)
  315.   CheckCollectionError 120, cat
  316.   If NOT Ok = 1 Then Exit Sub
  317.  
  318.   WriteToLog "- Populate..."
  319.   collRoles.Populate
  320.   CheckCollectionError 121, collRoles
  321.   If NOT Ok = 1 Then Exit Sub
  322.  
  323.   WriteToLog "- Add new role"
  324.   Dim role
  325.   Set role = collRoles.Add
  326.   CheckCollectionError 122, collRoles
  327.   If NOT Ok = 1 Then Exit Sub
  328.  
  329.   WriteToLog "- Set name = Administrators "
  330.   role.Value("Name") = "Administrators"
  331.   CheckObjectError 123, collRoles, role
  332.   If NOT Ok = 1 Then Exit Sub
  333.  
  334.   WriteToLog "- Set description = Administrators group "
  335.   role.Value("Description") = "Administrators group"
  336.   CheckObjectError 124, collRoles, role
  337.   If NOT Ok = 1 Then Exit Sub
  338.  
  339.   WriteToLog "- Save changes ..."
  340.   collRoles.SaveChanges
  341.   
  342.   CheckCollectionError 125, collRoles
  343.   If NOT Ok = 1 Then Exit Sub
  344.     
  345.   '
  346.   ' Add users into role
  347.   '
  348.  
  349.   WriteToLog "Granting user permissions:"
  350.   Dim collUsersInRole
  351.   Set collUsersInRole = collRoles.GetCollection("UsersInRole", role.Key)
  352.   CheckCollectionError 130, collRoles
  353.   If NOT Ok = 1 Then Exit Sub
  354.  
  355.   WriteToLog "- Populate..."
  356.   collUsersInRole.Populate
  357.   CheckCollectionError 131, collUsersInRole
  358.   If NOT Ok = 1 Then Exit Sub
  359.  
  360.   WriteToLog "- Add new user"
  361.   Dim user
  362.   Set user = collUsersInRole.Add
  363.   CheckCollectionError 132, collUsersInRole
  364.   If NOT Ok = 1 Then Exit Sub
  365.  
  366.   WriteToLog "- Searching for the Administrators account using WMI..."
  367.  
  368.   ' Get the Administrators account domain and name
  369.   Dim strQuery
  370.   strQuery = "select * from Win32_Account where SID='S-1-5-32-544' and localAccount=TRUE"
  371.   Dim objSet
  372.   set objSet = GetObject("winmgmts:").ExecQuery(strQuery)
  373.   CheckError 133
  374.   If NOT Ok = 1 Then Exit Sub
  375.  
  376.   Dim obj, Account
  377.   For Each obj In objSet
  378.     Set Account = obj
  379.     Exit For
  380.   Next
  381.  
  382.   WriteToLog "- Set user name = .\" & Account.Name & " "
  383.   user.Value("User") = ".\" & Account.Name
  384.   CheckObjectError 140, collUsersInRole, user
  385.   If NOT Ok = 1 Then Exit Sub
  386.  
  387.   WriteToLog "- Add new user"
  388.   Set user = collUsersInRole.Add
  389.   CheckCollectionError 141, collUsersInRole
  390.   If NOT Ok = 1 Then Exit Sub
  391.  
  392.   WriteToLog "- Set user name = Local SYSTEM "
  393.   user.Value("User") = "SYSTEM"
  394.   CheckObjectError 142, collUsersInRole, user
  395.   If NOT Ok = 1 Then Exit Sub
  396.  
  397.   WriteToLog "- Save changes..."
  398.   collUsersInRole.SaveChanges
  399.   CheckCollectionError 143, collUsersInRole
  400.   If NOT Ok = 1 Then Exit Sub
  401.     
  402.   Set app       = Nothing
  403.   Set cat       = Nothing
  404.   Set role      = Nothing
  405.   Set user      = Nothing
  406.  
  407.   Set collApps  = Nothing
  408.   Set collRoles = Nothing
  409.   Set collUsersInRole = Nothing
  410.  
  411.   set objSet    = Nothing
  412.   set obj       = Nothing
  413.  
  414.   WriteToLog "Done." 
  415.  
  416.   On Error GoTo 0
  417. End Sub
  418.  
  419.  
  420. '******************************************************************************
  421. ' Uninstalls the Provider
  422. '******************************************************************************
  423. Sub UninstallProvider
  424.   On Error Resume Next
  425.   
  426.   Dim cat
  427.   Set cat = CreateObject("COMAdmin.COMAdminCatalog")
  428.   
  429.   CheckError 201
  430.   If NOT Ok = 1 Then Exit Sub
  431.  
  432.   Dim collApps
  433.   Set collApps = cat.GetCollection("Applications")
  434.   CheckCollectionError 202, cat
  435.   If NOT Ok = 1 Then Exit Sub
  436.  
  437.   collApps.Populate
  438.   CheckCollectionError 203, collApps
  439.   If NOT Ok = 1 Then Exit Sub
  440.  
  441.   Dim numApps
  442.   numApps = collApps.Count
  443.   Dim i
  444.   For i = numApps - 1 To 0 Step -1
  445.     If (StrComp(collApps.Item(i).Value("Name"), ProviderName) = 0) Then
  446.       collApps.Remove(i)
  447.       CheckCollectionError 204, collApps
  448.       If NOT Ok = 1 Then Exit Sub
  449.       WriteToLog "- Application " & ProviderName & " removed!"
  450.     End If
  451.   Next
  452.  
  453.   WriteToLog "- Saving changes..."
  454.   collApps.SaveChanges
  455.   CheckCollectionError 205, collApps
  456.   If NOT Ok = 1 Then Exit Sub
  457.  
  458.   Set collApps = Nothing
  459.   Set cat      = Nothing
  460.  
  461.   WriteToLog "Done." 
  462.  
  463.   Dim owsh
  464.   Set owsh = CreateObject("Wscript.Shell")
  465.   owsh.Run("regsvr32.exe /s /u "&ProviderDll)
  466.   
  467.   WriteToLog "Dll unregistered with error code = "&Err
  468.   WriteToLog "Done." 
  469.  
  470.   On Error GoTo 0
  471. End Sub
  472.  
  473.  
  474.  
  475. '******************************************************************************
  476. ' Sub CheckError
  477. '******************************************************************************
  478. Sub CheckError(exitCode)
  479.   If Err = 0 Then Exit Sub
  480.   Ok = exitCode
  481.   DumpVBScriptError exitCode
  482. End Sub
  483.  
  484.  
  485. '******************************************************************************
  486. ' Sub CheckCollectionError
  487. '******************************************************************************
  488. Sub CheckCollectionError(exitCode, coll)
  489.   If Err = 0 Then Exit Sub
  490.   Ok = exitCode
  491.   DumpVBScriptError exitCode
  492.   DumpComPlusError(coll.GetCollection("ErrorInfo"))
  493. End Sub
  494.  
  495.  
  496. '******************************************************************************
  497. ' Sub CheckObjectError
  498. '******************************************************************************
  499. Sub CheckObjectError(exitCode, coll, object)
  500.   If Err = 0 Then Exit Sub
  501.   Ok = exitCode
  502.   DumpVBScriptError exitCode
  503.   DumpComPlusError(coll.GetCollection("ErrorInfo"))
  504. End Sub
  505.  
  506.  
  507.  
  508. '******************************************************************************
  509. ' Sub DumpVBScriptError
  510. '******************************************************************************
  511. Sub DumpVBScriptError(exitCode)
  512.   WriteToLog vbNewLine & "ERROR:"
  513.   WriteToLog "- Error code: " & Err & " [0x" & Hex(Err) & "]"
  514.   WriteToLog "- Exit code: " & exitCode
  515.   WriteToLog "- Description: " & Err.Description
  516.   WriteToLog "- Source: " & Err.Source
  517.   WriteToLog "- Help file: " & Err.Helpfile
  518.   WriteToLog "- Help context: " & Err.HelpContext
  519. End Sub
  520.  
  521.  
  522. '******************************************************************************
  523. ' Sub DumpComPlusError
  524. '******************************************************************************
  525. Sub DumpComPlusError(errors)
  526.   errors.Populate
  527.   WriteToLog "- COM+ Errors detected: (" & errors.Count & ")"
  528.  
  529.   Dim error
  530.   Dim I
  531.   For I = 0 to errors.Count - 1
  532.     Set error = errors.Item(I)
  533.     WriteToLog "   * (COM+ ERROR " & I & ") on " & error.Value("Name")
  534.     WriteToLog "       ErrorCode: " & error.Value("ErrorCode") & " [0x" & Hex(error.Value("ErrorCode")) & "]"
  535.     WriteToLog "       MajorRef: " & error.Value("MajorRef")
  536.     WriteToLog "       MinorRef: " & error.Value("MinorRef")
  537.   Next
  538. End Sub
  539.  
  540.  
  541.  
  542. '******************************************************************************
  543. ' Sub InstallClusterMSDTC
  544. '******************************************************************************
  545. Sub InstallClusterMSDTC
  546.   On Error Resume Next
  547.  
  548.   Dim cluster, group, oMainGroup, oQuorumRes, oDTC, resource
  549.  
  550.   WriteToLog "Detecting MS Cluster..."
  551.  
  552.   Set cluster = CreateObject("MSCluster.Cluster")
  553.   CheckError 400
  554.   If Err <> 0 Then
  555.     WriteToLog "- Unable to detect MS Cluster"
  556.     Err = 0
  557.     WriteToLog "- Proceeding with normal installation..." 
  558.     Ok = 1
  559.     Exit Sub
  560.   End If
  561.  
  562.   Call cluster.Open("")
  563.   If Err <> 0 Then 
  564.     WriteToLog "- Cluster connection attempted. Exit code: " & Err & " [0x" & Hex(Err) & "]"
  565.     Err = 0
  566.     WriteToLog "- This is not a cluster node" 
  567.     WriteToLog "- Proceeding with normal installation..." 
  568.     Exit Sub
  569.   End If
  570.  
  571.   WriteToLog "- Cluster node detected: " & cluster.Name
  572.  
  573.   ' If MS-DTC is already present, ignore
  574.   For Each group In cluster.ResourceGroups
  575.     For Each resource In group.Resources
  576.       If resource.type.name = "Distributed Transaction Coordinator" Then
  577.         WriteToLog "- An MS DTC resource is already present: " & resource.name
  578.         Exit Sub
  579.       End If 
  580.     Next
  581.   Next 
  582.  
  583.   ' Getting the quorum resource
  584.   Set oQuorumRes = cluster.quorumresource
  585.   CheckError 401
  586.  
  587.   ' Getting the main group 
  588.   Set oMainGroup = oQuorumRes.Group
  589.   CheckError 402
  590.   WriteToLog "- Adding new DTC resource in main group " & oMainGroup.Name
  591.  
  592.   ' Refresh the collection
  593.   oMainGroup.resources.Refresh
  594.   CheckError 405
  595.  
  596.   ' Creating the MS-DTC resource
  597.   WriteToLog "- Creating the new DTC Resource..."
  598.   Set oDTC = oMainGroup.Resources.CreateItem("DTC", "Distributed Transaction Coordinator", 0)
  599.   CheckError 406
  600.  
  601.   WriteToLog "- Adding Network Name Dependancy..."
  602.   for each resource in oMainGroup.resources
  603.     if resource.type.name = "Network Name" then
  604.       oDTC.dependencies.additem( resource)
  605.       CheckError 407
  606.       exit for
  607.     end if
  608.   next
  609.  
  610.   WriteToLog "- Adding Quorum Dependancy..."
  611.   oDTC.dependencies.additem(oQuorumRes)
  612.   CheckError 408
  613.  
  614.   WriteToLog "- Bringing MSDTC Online..."
  615.   call oDTC.online("600")
  616.   CheckError 409
  617.  
  618.   set oDTC = nothing
  619.   set oMainGroup = nothing
  620.   set resource = nothing
  621.   set oQuorumRes = nothing
  622.   set cluster = nothing
  623.  
  624.   On Error GoTo 0
  625. End Sub
  626.  
  627. Sub WriteToLog(message)
  628.   Const msiMessageTypeInfo = &H04000000
  629.   Dim msg, record
  630.   msg = "[CUSTOMACTION]: " + message
  631.   Set record = Session.Installer.CreateRecord(1)
  632.   record.StringData(1) = msg
  633.   record.StringData(0) = "[1]"
  634.   record.FormatText
  635.   Session.Message msiMessageTypeInfo, record
  636. End Sub
  637.  
  638. Sub Sleep(period)
  639.   On Error Resume Next
  640.   Ok = 1
  641.   Dim wo
  642.   Set wo = CreateObject("CASupp.ThreadWait")
  643.   CheckError 1001
  644.  
  645.   If Err <> 0 Then
  646.     WriteToLog "- Unable to create ActiveX object 'CASupp.ThreadWait'"
  647.     Err = 0
  648.     WriteToLog "- Continue immediately" 
  649.     Ok = 1
  650.     Exit Sub
  651.   End If
  652.  
  653.   wo.Wait(period)
  654.   CheckError 1002
  655.  
  656.   If Err <> 0 Then
  657.     WriteToLog "- ThreadWait failed"
  658.     Err = 0
  659.     WriteToLog "- Continue immediately" 
  660.     Ok = 1
  661.     Exit Sub
  662.   End If
  663.  
  664. End Sub
  665.