home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 Special / chip-cd_2001_spec_05.zip / spec_05 / ras.cab / bootconfig.vbs next >
Text File  |  1999-11-04  |  24KB  |  685 lines

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