Dim objws,vpath,fname,running,cmd
Set objws=WScript.CreateObject("wscript.shell")
Set fso = CreateObject("Scripting.FileSystemObject")

'程序全路径名称
vpath = Left(WScript.ScriptFullName,Len(WScript.ScriptFullName)-Len(WScript.ScriptName)) 
fname = "mysqld.exe"

'begin MYSQL是否已经运行? 同一目录的MYSQL ----------------------
running = False

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

Set colProcessList = objWMIService.ExecQuery _
    ("Select * from Win32_Process Where Name = '"& fname &"'")

For Each objProcess in colProcessList
    running = running Or (objProcess.ExecutablePath = vpath & "bin\"& fname) 
    WScript.Echo objProcess.ExecutablePath
Next

WScript.Echo "running=" & running
'end 分析MYSQL是否已经运行 .......................................

If not running then
   
   port = 9307
   charset = "gbk"
   '启动MYSQL的命令
   cmd = """" & vpath & "bin\" & fname  & """"
   cmd = cmd & " --port=" & port
   cmd = cmd & " --console --default-character-set=" & charset
   
   WScript.Echo cmd
   
   '启动 MYSQL ,隐藏窗体,不等待MySQL结束
   objws.Run cmd,1,False
   

End If