home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 Special / chip-cd_2001_spec_05.zip / spec_05 / ras.cab / cdromdrives.vbs < prev    next >
Text File  |  1999-11-04  |  23KB  |  664 lines

  1. '********************************************************************
  2. '*
  3. '* File:           CDRomDrives.vbs 
  4. '* Created:        March 1999
  5. '* Version:        1.0
  6. '*
  7. '*  Main Function:  Outputs Information on CDRomDrives.
  8. '*
  9. '*  CDRomDrives.vbs  [/S <server>] [/U <username>] [/W <password>] 
  10. '*                   [/O <outputfile>]
  11. '*
  12. '* Copyright (C) 1999 Microsoft Corporation
  13. '*
  14. '********************************************************************
  15.  
  16. OPTION EXPLICIT
  17.  
  18.     'Define constants
  19.     CONST CONST_ERROR                   = 0
  20.     CONST CONST_WSCRIPT                 = 1
  21.     CONST CONST_CSCRIPT                 = 2
  22.     CONST CONST_SHOW_USAGE              = 3
  23.     CONST CONST_PROCEED                 = 4
  24.  
  25.     'Declare variables
  26.     Dim intOpMode, i
  27.     Dim strServer, strUserName, strPassword, strOutputFile
  28.  
  29.     'Make sure the host is csript, if not then abort
  30.     VerifyHostIsCscript()
  31.  
  32.     'Parse the command line
  33.     intOpMode = intParseCmdLine(strServer     ,  _
  34.                                 strUserName   ,  _
  35.                                 strPassword   ,  _
  36.                                 strOutputFile    )
  37.  
  38.  
  39.     Select Case intOpMode
  40.  
  41.         Case CONST_SHOW_USAGE
  42.             Call ShowUsage()
  43.  
  44.         Case CONST_PROCEED                 
  45.             Call CdRomDrives(strServer    , _
  46.                             strOutputFile , _
  47.                             strUserName   , _
  48.                             strPassword     )
  49.  
  50.         Case CONST_ERROR
  51.             'Do Nothing
  52.  
  53.         Case Else                    'Default -- should never happen
  54.             Call Wscript.Echo("Error occurred in passing parameters.")
  55.  
  56.     End Select
  57.  
  58. '********************************************************************
  59. '* End of Script
  60. '********************************************************************
  61.  
  62. '********************************************************************
  63. '*
  64. '* Sub CdRomDrives()
  65. '*
  66. '* Purpose: Outputs Information on CDRomDrives.
  67. '*
  68. '* Input:   strServer           a machine name
  69. '*          strOutputFile       an output file name
  70. '*          strUserName         the current user's name
  71. '*          strPassword         the current user's password
  72. '*
  73. '* Output:  Results are either printed on screen or saved in strOutputFile.
  74. '*
  75. '********************************************************************
  76. Private Sub CdRomDrives(strServer, strOutputFile, strUserName, strPassword)
  77.  
  78.     ON ERROR RESUME NEXT
  79.  
  80.     Dim objFileSystem, objOutputFile, objService, objSet, obj, objInst
  81.     Dim strLine
  82.  
  83.     'Open a text file for output if the file is requested
  84.     If Not IsEmpty(strOutputFile) Then
  85.         If (NOT blnOpenFile(strOutputFile, objOutputFile)) Then
  86.             Call Wscript.Echo ("Could not open an output file.")
  87.             Exit Sub
  88.         End If
  89.     End If
  90.  
  91.     'Establish a connection with the server.
  92.     If blnConnect("root\cimv2" , _
  93.                    strUserName , _
  94.                    strPassword , _
  95.                    strServer   , _
  96.                    objService  ) Then
  97.         Call Wscript.Echo("")
  98.         Call Wscript.Echo("Please check the server name, " _
  99.                         & "credentials and WBEM Core.")
  100.         Exit Sub
  101.     End If
  102.  
  103.  
  104.     'Get the first instance
  105.     Set objSet = objService.InstancesOf("Win32_CDRomDrive")
  106.     If blnErrorOccurred ("obtaining the Win32_CDRomDrive.") Then Exit Sub
  107.  
  108.     if objSet.Count = 0 then
  109.         WriteLine "There are no CD-Rom drives detected.", objOutputFile
  110.         Exit Sub
  111.     End If
  112.     For Each objInst In objSet
  113.  
  114.         WriteLine vbCRLF & _
  115.            objInst.Manufacturer& " "& _
  116.            objInst.Description& ", drive "& _
  117.            objInst.Drive& " on "& _
  118.            objInst.SystemName, objOutputFile
  119.         WriteLine "Status:                     "& objInst.Status, objOutputFile
  120.         WriteLine "Media Loaded:               "& _
  121.                    strYesOrNo(objInst.MediaLoaded), objOutputFile
  122.         if objInst.MediaLoaded Then
  123.             WriteLine "Volume Name:                "& CStr(objInst.VolumeName)_
  124.                                                     , objOutputFile
  125.             WriteLine "Volume Serial Number:       "& _
  126.                        CStr(objInst.VolumeSerialNumber), objOutputFile
  127.             WriteLine "Maximum Component Length:   "& _
  128.                        objInst.MaximumComponentLength, objOutputFile
  129.         End If
  130.         WriteLine "Device ID:                  "& objInst.DeviceID _
  131.                                                 , objOutputFile
  132.         If len(objInst.PNPDeviceID) < 45 then
  133.              WriteLine "PNP Device ID:              "& objInst.PNPDeviceID _
  134.                                                      , objOutputFile
  135.         End If
  136.         WriteLine "SCSI Target Id:             "& objInst.SCSITargetId _
  137.                                                 , objOutputFile
  138.         WriteLine "Drive Integrity:            "& objInst.DriveIntegrity _
  139.                                                 , objOutputFile
  140.         WriteLine "Config Manager Error Code:  "& _
  141.                    objInst.ConfigManagerErrorCode, objOutputFile
  142.         WriteLine "Config Manager User Config: "& _
  143.                    objInst.ConfigManagerUserConfig, objOutputFile
  144.         WriteLine "Creation Class Name:        "& objInst.CreationClassName _
  145.                                                 , objOutputFile
  146.  
  147.     Next
  148.  
  149.     If IsObject(objOutputFile) Then
  150.         objOutputFile.Close
  151.         Call Wscript.Echo ("Results are saved in file " & strOutputFile & ".")
  152.     End If
  153.  
  154. End Sub
  155.  
  156. '********************************************************************
  157. '*
  158. '* Function intParseCmdLine()
  159. '*
  160. '* Purpose: Parses the command line.
  161. '* Input:   
  162. '*
  163. '* Output:  strServer         a remote server ("" = local server")
  164. '*          strUserName       the current user's name
  165. '*          strPassword       the current user's password
  166. '*          strOutputFile     an output file name
  167. '*
  168. '********************************************************************
  169. Private Function intParseCmdLine( ByRef strServer,        _
  170.                                   ByRef strUserName,      _
  171.                                   ByRef strPassword,      _
  172.                                   ByRef strOutputFile     )
  173.  
  174.  
  175.     ON ERROR RESUME NEXT
  176.  
  177.     Dim strFlag
  178.     Dim intState, intArgIter
  179.     Dim objFileSystem
  180.  
  181.     If Wscript.Arguments.Count > 0 Then
  182.         strFlag = Wscript.arguments.Item(0)
  183.     End If
  184.  
  185.     If IsEmpty(strFlag) Then                'No arguments have been received
  186.         intParseCmdLine = CONST_PROCEED
  187.         Exit Function
  188.     End If
  189.  
  190.     'Check if the user is asking for help or is just confused
  191.     If (strFlag="help") OR (strFlag="/h") OR (strFlag="\h") OR (strFlag="-h") _
  192.         OR (strFlag = "\?") OR (strFlag = "/?") OR (strFlag = "?") _ 
  193.         OR (strFlag="h") Then
  194.         intParseCmdLine = CONST_SHOW_USAGE
  195.         Exit Function
  196.     End If
  197.  
  198.     'Retrieve the command line and set appropriate variables
  199.      intArgIter = 0
  200.     Do While intArgIter <= Wscript.arguments.Count - 1
  201.         Select Case Left(LCase(Wscript.arguments.Item(intArgIter)),2)
  202.   
  203.             Case "/s"
  204.                 If Not blnGetArg("Server", strServer, intArgIter) Then
  205.                     intParseCmdLine = CONST_ERROR
  206.                     Exit Function
  207.                 End If
  208.                 intArgIter = intArgIter + 1
  209.  
  210.             Case "/o"
  211.                 If Not blnGetArg("Output File", strOutputFile, intArgIter) Then
  212.                     intParseCmdLine = CONST_ERROR
  213.                     Exit Function
  214.                 End If
  215.                 intArgIter = intArgIter + 1
  216.  
  217.             Case "/u"
  218.                 If Not blnGetArg("User Name", strUserName, intArgIter) Then
  219.                     intParseCmdLine = CONST_ERROR
  220.                     Exit Function
  221.                 End If
  222.                 intArgIter = intArgIter + 1
  223.  
  224.             Case "/w"
  225.                 If Not blnGetArg("User Password", strPassword, intArgIter) Then
  226.                     intParseCmdLine = CONST_ERROR
  227.                     Exit Function
  228.                 End If
  229.                 intArgIter = intArgIter + 1
  230.  
  231.             Case Else 'We shouldn't get here
  232.                 Call Wscript.Echo("Invalid or misplaced parameter: " _
  233.                    & Wscript.arguments.Item(intArgIter) & vbCRLF _
  234.                    & "Please check the input and try again," & vbCRLF _
  235.                    & "or invoke with '/?' for help with the syntax.")
  236.                 Wscript.Quit
  237.  
  238.         End Select
  239.  
  240.     Loop '** intArgIter <= Wscript.arguments.Count - 1
  241.  
  242.     If IsEmpty(intParseCmdLine) Then _
  243.         intParseCmdLine = CONST_PROCEED
  244.  
  245. End Function
  246.  
  247. '********************************************************************
  248. '*
  249. '* Sub ShowUsage()
  250. '*
  251. '* Purpose: Shows the correct usage to the user.
  252. '*
  253. '* Input:   None
  254. '*
  255. '* Output:  Help messages are displayed on screen.
  256. '*
  257. '********************************************************************
  258. Private Sub ShowUsage()
  259.  
  260.     Wscript.Echo ""
  261.     Wscript.Echo "Outputs Information on CD-ROM Drives."
  262.     Wscript.Echo ""
  263.     Wscript.Echo "SYNTAX:"
  264.     Wscript.Echo "  CDRomDrives.vbs [/S <server>] [/U <username>]" _
  265.                 &" [/W <password>]"
  266.     Wscript.Echo "  [/O <outputfile>]"
  267.     Wscript.Echo ""
  268.     Wscript.Echo "PARAMETER SPECIFIERS:"
  269.     Wscript.Echo "   server        A machine name."
  270.     Wscript.Echo "   username      The current user's name."
  271.     Wscript.Echo "   password      Password of the current user."
  272.     Wscript.Echo "   outputfile    The output file name."
  273.     Wscript.Echo ""
  274.     Wscript.Echo "EXAMPLE:"
  275.     Wscript.Echo "1. cscript CdRomDrives.vbs"
  276.     Wscript.Echo "   Get the CD-ROM configuration for the current machine."
  277.     Wscript.Echo "2. cscript CdRomDrives.vbs /S MyMachine2"
  278.     Wscript.Echo "   Get the CD-ROM configuration for the machine MyMachine2."
  279.  
  280. End Sub
  281.  
  282. '********************************************************************
  283. '* General Routines
  284. '********************************************************************
  285.  
  286. '********************************************************************
  287. '*
  288. '* Function strYesOrNo(blnB)
  289. '*
  290. '* Purpose: To give a boolean value to a string
  291. '*
  292. '* Input:   blnB    A BooleanValue
  293. '*
  294. '* Output:  "Yes" if Ture and "No" if False 
  295. '*
  296. '********************************************************************
  297. Private Function strYesOrNo(blnB)
  298.     strYesOrNo = "No"
  299.     If blnB Then strYesOrNo = "Yes"
  300. End Function
  301.  
  302. '********************************************************************
  303. '*
  304. '* Function strPackString()
  305. '*
  306. '* Purpose: Attaches spaces to a string to increase the length to intWidth.
  307. '*
  308. '* Input:   strString   a string
  309. '*          intWidth    the intended length of the string
  310. '*          blnAfter    Should spaces be added after the string?
  311. '*          blnTruncate specifies whether to truncate the string or not if
  312. '*                      the string length is longer than intWidth
  313. '*
  314. '* Output:  strPackString is returned as the packed string.
  315. '*
  316. '********************************************************************
  317. Private Function strPackString( ByVal strString, _
  318.                                 ByVal intWidth,  _
  319.                                 ByVal blnAfter,  _
  320.                                 ByVal blnTruncate)
  321.  
  322.     ON ERROR RESUME NEXT
  323.  
  324.     intWidth      = CInt(intWidth)
  325.     blnAfter      = CBool(blnAfter)
  326.     blnTruncate   = CBool(blnTruncate)
  327.  
  328.     If Err.Number Then
  329.         Call Wscript.Echo ("Argument type is incorrect!")
  330.         Err.Clear
  331.         Wscript.Quit
  332.     End If
  333.  
  334.     If IsNull(strString) Then
  335.         strPackString = "null" & Space(intWidth-4)
  336.         Exit Function
  337.     End If
  338.  
  339.     strString = CStr(strString)
  340.     If Err.Number Then
  341.         Call Wscript.Echo ("Argument type is incorrect!")
  342.         Err.Clear
  343.         Wscript.Quit
  344.     End If
  345.  
  346.     If intWidth > Len(strString) Then
  347.         If blnAfter Then
  348.             strPackString = strString & Space(intWidth-Len(strString))
  349.         Else
  350.             strPackString = Space(intWidth-Len(strString)) & strString & " "
  351.         End If
  352.     Else
  353.         If blnTruncate Then
  354.             strPackString = Left(strString, intWidth-1) & " "
  355.         Else
  356.             strPackString = strString & " "
  357.         End If
  358.     End If
  359.  
  360. End Function
  361.  
  362. '********************************************************************
  363. '* 
  364. '*  Function blnGetArg()
  365. '*
  366. '*  Purpose: Helper to intParseCmdLine()
  367. '* 
  368. '*  Usage:
  369. '*
  370. '*     Case "/s" 
  371. '*       blnGetArg ("server name", strServer, intArgIter)
  372. '*
  373. '********************************************************************
  374. Private Function blnGetArg ( ByVal StrVarName,   _
  375.                              ByRef strVar,       _
  376.                              ByRef intArgIter) 
  377.  
  378.     blnGetArg = False 'failure, changed to True upon successful completion
  379.  
  380.     If Len(Wscript.Arguments(intArgIter)) > 2 then
  381.         If Mid(Wscript.Arguments(intArgIter),3,1) = ":" then
  382.             If Len(Wscript.Arguments(intArgIter)) > 3 then
  383.                 strVar = Right(Wscript.Arguments(intArgIter), _
  384.                          Len(Wscript.Arguments(intArgIter)) - 3)
  385.                 blnGetArg = True
  386.                 Exit Function
  387.             Else
  388.                 intArgIter = intArgIter + 1
  389.                 If intArgIter > (Wscript.Arguments.Count - 1) Then
  390.                     Call Wscript.Echo( "Invalid " & StrVarName & ".")
  391.                     Call Wscript.Echo( "Please check the input and try again.")
  392.                     Exit Function
  393.                 End If
  394.  
  395.                 strVar = Wscript.Arguments.Item(intArgIter)
  396.                 If Err.Number Then
  397.                     Call Wscript.Echo( "Invalid " & StrVarName & ".")
  398.                     Call Wscript.Echo( "Please check the input and try again.")
  399.                     Exit Function
  400.                 End If
  401.  
  402.                 If InStr(strVar, "/") Then
  403.                     Call Wscript.Echo( "Invalid " & StrVarName)
  404.                     Call Wscript.Echo( "Please check the input and try again.")
  405.                     Exit Function
  406.                 End If
  407.  
  408.                 blnGetArg = True 'success
  409.             End If
  410.         Else
  411.             strVar = Right(Wscript.Arguments(intArgIter), _
  412.                      Len(Wscript.Arguments(intArgIter)) - 2)
  413.             blnGetArg = True 'success
  414.             Exit Function
  415.         End If
  416.     Else
  417.         intArgIter = intArgIter + 1
  418.         If intArgIter > (Wscript.Arguments.Count - 1) Then
  419.             Call Wscript.Echo( "Invalid " & StrVarName & ".")
  420.             Call Wscript.Echo( "Please check the input and try again.")
  421.             Exit Function
  422.         End If
  423.  
  424.         strVar = Wscript.Arguments.Item(intArgIter)
  425.         If Err.Number Then
  426.             Call Wscript.Echo( "Invalid " & StrVarName & ".")
  427.             Call Wscript.Echo( "Please check the input and try again.")
  428.             Exit Function
  429.         End If
  430.  
  431.         If InStr(strVar, "/") Then
  432.             Call Wscript.Echo( "Invalid " & StrVarName)
  433.             Call Wscript.Echo( "Please check the input and try again.")
  434.             Exit Function
  435.         End If
  436.         blnGetArg = True 'success
  437.     End If
  438. End Function
  439.  
  440. '********************************************************************
  441. '*
  442. '* Function blnConnect()
  443. '*
  444. '* Purpose: Connects to machine strServer.
  445. '*
  446. '* Input:   strServer       a machine name
  447. '*          strNameSpace    a namespace
  448. '*          strUserName     name of the current user
  449. '*          strPassword     password of the current user
  450. '*
  451. '* Output:  objService is returned  as a service object.
  452. '*          strServer is set to local host if left unspecified
  453. '*
  454. '********************************************************************
  455. Private Function blnConnect(ByVal strNameSpace, _
  456.                             ByVal strUserName,  _
  457.                             ByVal strPassword,  _
  458.                             ByRef strServer,    _
  459.                             ByRef objService)
  460.  
  461.     ON ERROR RESUME NEXT
  462.  
  463.     Dim objLocator, objWshNet
  464.  
  465.     blnConnect = False     'There is no error.
  466.  
  467.     'Create Locator object to connect to remote CIM object manager
  468.     Set objLocator = CreateObject("WbemScripting.SWbemLocator")
  469.     If Err.Number then
  470.         Call Wscript.Echo( "Error 0x" & CStr(Hex(Err.Number)) & _
  471.                            " occurred in creating a locator object." )
  472.         If Err.Description <> "" Then
  473.             Call Wscript.Echo( "Error description: " & Err.Description & "." )
  474.         End If
  475.         Err.Clear
  476.         blnConnect = True     'An error occurred
  477.         Exit Function
  478.     End If
  479.  
  480.     'Connect to the namespace which is either local or remote
  481.     Set objService = objLocator.ConnectServer (strServer, strNameSpace, _
  482.        strUserName, strPassword)
  483.     ObjService.Security_.impersonationlevel = 3
  484.     If Err.Number then
  485.         Call Wscript.Echo( "Error 0x" & CStr(Hex(Err.Number)) & _
  486.                            " occurred in connecting to server " _
  487.            & strServer & ".")
  488.         If Err.Description <> "" Then
  489.             Call Wscript.Echo( "Error description: " & Err.Description & "." )
  490.         End If
  491.         Err.Clear
  492.         blnConnect = True     'An error occurred
  493.     End If
  494.  
  495.     'Get the current server's name if left unspecified
  496.     If IsEmpty(strServer) Then
  497.         Set objWshNet = CreateObject("Wscript.Network")
  498.     strServer     = objWshNet.ComputerName
  499.     End If
  500.  
  501. End Function
  502.  
  503. '********************************************************************
  504. '*
  505. '* Sub      VerifyHostIsCscript()
  506. '*
  507. '* Purpose: Determines which program is used to run this script.
  508. '*
  509. '* Input:   None
  510. '*
  511. '* Output:  If host is not cscript, then an error message is printed 
  512. '*          and the script is aborted.
  513. '*
  514. '********************************************************************
  515. Sub VerifyHostIsCscript()
  516.  
  517.     ON ERROR RESUME NEXT
  518.  
  519.     Dim strFullName, strCommand, i, j, intStatus
  520.  
  521.     strFullName = WScript.FullName
  522.  
  523.     If Err.Number then
  524.         Call Wscript.Echo( "Error 0x" & CStr(Hex(Err.Number)) & " occurred." )
  525.         If Err.Description <> "" Then
  526.             Call Wscript.Echo( "Error description: " & Err.Description & "." )
  527.         End If
  528.         intStatus =  CONST_ERROR
  529.     End If
  530.  
  531.     i = InStr(1, strFullName, ".exe", 1)
  532.     If i = 0 Then
  533.         intStatus =  CONST_ERROR
  534.     Else
  535.         j = InStrRev(strFullName, "\", i, 1)
  536.         If j = 0 Then
  537.             intStatus =  CONST_ERROR
  538.         Else
  539.             strCommand = Mid(strFullName, j+1, i-j-1)
  540.             Select Case LCase(strCommand)
  541.                 Case "cscript"
  542.                     intStatus = CONST_CSCRIPT
  543.                 Case "wscript"
  544.                     intStatus = CONST_WSCRIPT
  545.                 Case Else       'should never happen
  546.                     Call Wscript.Echo( "An unexpected program was used to " _
  547.                                        & "run this script." )
  548.                     Call Wscript.Echo( "Only CScript.Exe or WScript.Exe can " _
  549.                                        & "be used to run this script." )
  550.                     intStatus = CONST_ERROR
  551.                 End Select
  552.         End If
  553.     End If
  554.  
  555.     If intStatus <> CONST_CSCRIPT Then
  556.         Call WScript.Echo( "Please run this script using CScript." & vbCRLF & _
  557.              "This can be achieved by" & vbCRLF & _
  558.              "1. Using ""CScript CdRomDrives.vbs arguments"" for Windows 95/98 or" _
  559.              & vbCRLF & "2. Changing the default Windows Scripting Host " _
  560.              & "setting to CScript" & vbCRLF & "    using ""CScript " _
  561.              & "//H:CScript //S"" and running the script using" & vbCRLF & _
  562.              "    ""CdRomDrives.vbs arguments"" for Windows NT/2000." )
  563.         WScript.Quit
  564.     End If
  565.  
  566. End Sub
  567.  
  568. '********************************************************************
  569. '*
  570. '* Sub WriteLine()
  571. '* Purpose: Writes a text line either to a file or on screen.
  572. '* Input:   strMessage  the string to print
  573. '*          objFile     an output file object
  574. '* Output:  strMessage is either displayed on screen or written to a file.
  575. '*
  576. '********************************************************************
  577. Sub WriteLine(ByVal strMessage, ByVal objFile)
  578.  
  579.     On Error Resume Next
  580.     If IsObject(objFile) then        'objFile should be a file object
  581.         objFile.WriteLine strMessage
  582.     Else
  583.         Call Wscript.Echo( strMessage )
  584.     End If
  585.  
  586. End Sub
  587.  
  588. '********************************************************************
  589. '* 
  590. '* Function blnErrorOccurred()
  591. '*
  592. '* Purpose: Reports error with a string saying what the error occurred in.
  593. '*
  594. '* Input:   strIn        string saying what the error occurred in.
  595. '*
  596. '* Output:  displayed on screen 
  597. '* 
  598. '********************************************************************
  599. Private Function blnErrorOccurred (ByVal strIn)
  600.  
  601.     If Err.Number Then
  602.         Call Wscript.Echo( "Error 0x" & CStr(Hex(Err.Number)) & ": " & strIn)
  603.         If Err.Description <> "" Then
  604.             Call Wscript.Echo( "Error description: " & Err.Description)
  605.         End If
  606.         Err.Clear
  607.         blnErrorOccurred = True
  608.     Else
  609.         blnErrorOccurred = False
  610.     End If
  611.  
  612. End Function
  613.  
  614. '********************************************************************
  615. '* 
  616. '* Function blnOpenFile
  617. '*
  618. '* Purpose: Opens a file.
  619. '*
  620. '* Input:   strFileName        A string with the name of the file.
  621. '*
  622. '* Output:  Sets objOpenFile to a FileSystemObject and setis it to 
  623. '*            Nothing upon Failure.
  624. '* 
  625. '********************************************************************
  626. Private Function blnOpenFile(ByVal strFileName, ByRef objOpenFile)
  627.  
  628.     ON ERROR RESUME NEXT
  629.  
  630.     Dim objFileSystem
  631.  
  632.     Set objFileSystem = Nothing
  633.  
  634.     If IsEmpty(strFileName) OR strFileName = "" Then
  635.         blnOpenFile = False
  636.         Set objOpenFile = Nothing
  637.         Exit Function
  638.     End If
  639.  
  640.     'Create a file object
  641.     Set objFileSystem = CreateObject("Scripting.FileSystemObject")
  642.     If blnErrorOccurred("Could not create filesystem object.") Then
  643.         blnOpenFile = False
  644.         Set objOpenFile = Nothing
  645.         Exit Function
  646.     End If
  647.  
  648.     'Open the file for output
  649.     Set objOpenFile = objFileSystem.OpenTextFile(strFileName, 8, True)
  650.     If blnErrorOccurred("Could not open") Then
  651.         blnOpenFile = False
  652.         Set objOpenFile = Nothing
  653.         Exit Function
  654.     End If
  655.     blnOpenFile = True
  656.  
  657. End Function
  658.  
  659. '********************************************************************
  660. '*                                                                  *
  661. '*                           End of File                            *
  662. '*                                                                  *
  663. '********************************************************************
  664.