gooderp18绿色标准版
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

87 lines
2.5KB

  1. ' Copyright (c) 2012-2020, EnterpriseDB Corporation. All rights reserved
  2. On Error Resume Next
  3. ' PostgreSQL server control script for Windows
  4. ' Check the command line
  5. If WScript.Arguments.Count = 0 OR WScript.Arguments.Count > 2 Then
  6. usage
  7. End If
  8. Dim objShell, objFso, objTempFolder, objWMI
  9. ' Get temporary filenames
  10. Set objShell = WScript.CreateObject("WScript.Shell")
  11. strWinDir = objShell.ExpandEnvironmentStrings("%WINDIR%")
  12. bWait = False
  13. If WScript.Arguments.Count = 2 Then
  14. If WScript.Arguments.Item(1) = "wait" Then
  15. bWait = True
  16. Else
  17. usage
  18. End If
  19. End If
  20. strAction = WScript.Arguments.Item(0)
  21. iRet = 0
  22. Select Case strAction
  23. Case "start"
  24. iRet = DoCmd("""" & strWinDir & """\System32\net start PostgreSQL_For_Odoo")
  25. Case "stop"
  26. iRet = DoCmd("""" & strWinDir & """\System32\net stop PostgreSQL_For_Odoo")
  27. Case "reload"
  28. iRet = DoCmd("""d:\Program Files\Odoo 17.2alpha1.20240315\PostgreSQL\bin\pg_ctl.exe"" -D ""d:\Program Files\Odoo 17.2alpha1.20240315\PostgreSQL\data"" reload")
  29. Case "restart"
  30. iRet = DoCmd("""" & strWinDir & """\System32\net stop PostgreSQL_For_Odoo")
  31. If iRet = 0 Then
  32. iRet = DoCmd("""" & strWinDir & """\System32\net start PostgreSQL_For_Odoo")
  33. End If
  34. Case Else
  35. usage
  36. End Select
  37. If bWait = True Then
  38. If Err.Number <> 0 Then
  39. WScript.Echo "An error occured executing the " & strAction & " command (" & Err.Number & ")"
  40. End If
  41. If iRet <> 0 Then
  42. WScript.Echo "The " & strAction & " command returned an error (" & iRet & ")"
  43. End If
  44. WScript.StdOut.Write vbCrLf & "Press <return> to continue..."
  45. WScript.StdIn.ReadLine
  46. End If
  47. WScript.Quit iRet
  48. ' Execute a command
  49. Function DoCmd(cmd)
  50. Dim objShell, objOutput
  51. Set objShell = WScript.CreateObject("WScript.Shell")
  52. Set objOutput = objShell.Exec(cmd)
  53. Do While Not objOutput.StdOut.AtEndOfStream
  54. If Not objOutput.StdOut.AtEndOfStream Then
  55. strOutput = strOutput & vbCrLf & objOutput.StdOut.ReadLine
  56. End If
  57. Loop
  58. Do While Not objOutput.StdErr.AtEndOfStream
  59. If Not objOutput.StdErr.AtEndOfStream Then
  60. strOutput = strOutput & vbCrLf & objOutput.StdErr.ReadLine
  61. End If
  62. Loop
  63. WScript.Echo strOutput
  64. DoCmd = objOutput.ExitCode
  65. Set objOutput = Nothing
  66. Set objShell = Nothing
  67. End Function
  68. ' Usage message
  69. Sub usage()
  70. Wscript.Echo "Usage: serverctl.vbs start|stop|reload|restart [wait]"
  71. iRet = 127
  72. WScript.Quit iRet
  73. End Sub
上海开阖软件有限公司 沪ICP备12045867号-1