home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / wsh.cab / showvar.vbs < prev    next >
Text File  |  1997-09-16  |  2KB  |  65 lines

  1. ' Windows Script Host Sample Script
  2. '
  3. ' ------------------------------------------------------------------------
  4. '               Copyright (C) 1996-1997 Microsoft Corporation
  5. '
  6. ' You have a royalty-free right to use, modify, reproduce and distribute
  7. ' the Sample Application Files (and/or any modified version) in any way
  8. ' you find useful, provided that you agree that Microsoft has no warranty,
  9. ' obligations or liability for any Sample Application Files.
  10. ' ------------------------------------------------------------------------
  11.  
  12. ' This sample will list all environment variables defined on this machine.
  13.  
  14. L_Welcome_MsgBox_Message_Text    = "This script will list all environment variables defined on this machine."
  15. L_Welcome_MsgBox_Title_Text      = "Windows Scripting Host Sample"
  16. Call Welcome()
  17.  
  18.  
  19. ' ********************************************************************************
  20. ' *
  21. ' * Environment Sample
  22. ' *
  23. CRLF = Chr(13) & Chr(10)
  24.  
  25. Dim WSHShell
  26. Set WSHShell = WScript.CreateObject("WScript.Shell")
  27.  
  28.  
  29. Sub show_env(strText)
  30.     MsgBox strText, vbInformation, L_Welcome_MsgBox_Title_Text
  31. End Sub
  32.  
  33. intIndex = 0
  34. strText = ""
  35. intNumEnv = 0
  36. MAX_ENV = 20
  37. For Each strEnv In WshShell.Environment("PROCESS")
  38.     intIndex = intIndex + 1
  39.     strText = strText & CRLF & Right("    " & intIndex, 4) & " " & strEnv
  40.     intNumEnv = intNumEnv + 1
  41.     If intNumEnv >= MAX_ENV Then
  42.         Call show_env(strText)
  43.         strText = ""
  44.         intNumEnv = 0
  45.     End If
  46. Next
  47.  
  48. If intNumEnv >= 1 Then Call show_env(strText)
  49.  
  50.  
  51. ' ********************************************************************************
  52. ' *
  53. ' * Welcome
  54. ' *
  55. Sub Welcome()
  56.     Dim intDoIt
  57.  
  58.     intDoIt =  MsgBox(L_Welcome_MsgBox_Message_Text, _
  59.                       vbOKCancel + vbInformation,    _
  60.                       L_Welcome_MsgBox_Title_Text )
  61.     If intDoIt = vbCancel Then
  62.         WScript.Quit
  63.     End If
  64. End Sub
  65.