gooderp18绿色标准版
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

60 lines
1.7KB

  1. ' Copyright (c) 2012-2020, EnterpriseDB Corporation. All rights reserved
  2. ' VBscript test script - check that the scripting host appears functional
  3. Set WshShell = WScript.CreateObject("WScript.Shell")
  4. Set WshSysEnv = WshShell.Environment("PROCESS")
  5. strSystemRoot = WshSysEnv("TEMP")
  6. If strSystemRoot = "" Then
  7. WScript.Echo "Unable to read the value of the TEMP environment variable."
  8. WScript.Quit 1
  9. End If
  10. ' Check if temp path is writable
  11. isWritable = IsPathWriteable(strSystemRoot)
  12. If isWritable = False Then
  13. WScript.Echo "Unable to write inside TEMP environment variable path."
  14. WScript.Quit 1
  15. End If
  16. ' check if we can run a script from temp folder
  17. Dim fso 'As Scripting.FileSystemObject
  18. Dim Temp_Path 'As String
  19. Set fso = CreateObject("Scripting.FileSystemObject")
  20. Temp_Path = strSystemRoot & "\" & fso.GetTempName() & ".vbs"
  21. On Error Resume Next
  22. fso.CreateTextFile Temp_Path
  23. WriteLineToFile(Temp_Path)
  24. canExecute = WshShell.Run("Temp_Path")
  25. fso.DeleteFile Temp_Path
  26. If canExecute <> 0 Then
  27. WScript.Echo "Unable to execute from TEMP environment variable path."
  28. WScript.Quit 2
  29. End If
  30. WScript.Echo "The scripting host appears to be functional."
  31. WScript.Quit 0
  32. Function WriteLineToFile(Path)
  33. Const ForWriting = 2
  34. Dim fso, f
  35. Set fso = CreateObject("Scripting.FileSystemObject")
  36. Set f = fso.OpenTextFile(Path, ForWriting, True)
  37. f.WriteLine "a = 1"
  38. End Function
  39. Function IsPathWriteable(Path)' As Boolean
  40. Dim fso 'As Scripting.FileSystemObject
  41. Dim Temp_Path 'As String
  42. Set fso = CreateObject("Scripting.FileSystemObject")
  43. Temp_Path = Path & "\" & fso.GetTempName()
  44. On Error Resume Next
  45. fso.CreateTextFile Temp_Path
  46. IsPathWriteable = Err.Number = 0
  47. fso.DeleteFile Temp_Path
  48. On Error Goto 0
  49. End Function
上海开阖软件有限公司 沪ICP备12045867号-1