Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Tools

Development::Tools 3rd Party Tools for EQEMu (DB management tools, front ends, etc...)

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 01-01-2013, 12:15 AM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

i just can't help myself...

added functionality that makes certain you don't end up running multiple instances of the same script accidentally (very bad things would have happened).

runemu.vbs
Code:
set Shell = CreateObject("WScript.Shell")

' return process object collection where process name starts with procName
function ProcessObjectList(procName)
    queryStr = "SELECT * FROM Win32_Process WHERE name LIKE '" & procName & "%'"
    set ProcessObjectList = GetObject("Winmgmts:").ExecQuery(queryStr)
end function

' is process running?
function Running(procName)
    if ProcessObjectList(procName).Count < 1 then
        Running = false
    else
        Running = true
    end if
end function

' start processes if not already running 
sub RunServer
    for each procName in array("EQEmuLoginServer", "World", "EQLaunch", "UCS")
        if not Running(procName) then
            runStr = procName & ".exe"
            if StrComp("EQLaunch", procName, 1)=0 then
                runStr = runStr & " zone"
            end if
            Shell.Run runStr, 0, false
        end if
    next
end sub

' exit if this script is already running
set processList = ProcessObjectList("wscript")
if processList.Count > 1 then
    foundScript = 0
    for each process in processList
        if StrComp(process.name, "wscript.exe", 1)=0 then
            if InStr(process.CommandLine, WScript.ScriptName) then
                foundScript = foundScript+1
            end if
        end if
        if foundScript > 1 then
            WScript.Echo WScript.ScriptName & " is already running!"
            WScript.Quit
        end if
    next
end if
set processList = Nothing

' loop forever (30000 millisecond delay)
do while true
    RunServer
    Wscript.Sleep 30000
loop
this one terminates both the monitoring script and all running emulator executables

stopemu.vbs
Code:
set Shell = CreateObject("WScript.Shell")

' return process object collection where process name starts with procName
function ProcessObjectList(procName)
    queryStr = "SELECT * FROM Win32_Process WHERE name LIKE '" & procName & "%'"
    set ProcessObjectList = GetObject("Winmgmts:").ExecQuery(queryStr)
end function

' exit if this script is already running
set processList = ProcessObjectList("wscript")
if processList.Count > 1 then
    foundScript = 0
    for each proc in processList
        if StrComp(proc.name, "wscript.exe", 1)=0 then
            if InStr(proc.CommandLine, WScript.ScriptName) then
                foundScript = foundScript+1
            end if
        end if
        if foundScript > 1 then
            WScript.Echo WScript.ScriptName & " is already running!"
            WScript.Quit
        end if
    next
end if
set processList = Nothing

' terminate all instances of emulator monitoring script server processes
for each procName in array("WScript", "EQEmuLoginServer", "World", "EQLaunch", "UCS", "Zone")
    for each process in ProcessObjectList(procName)
        terminate = true
        if StrComp(process.name, "wscript.exe", 1)=0 then
            if InStr(process.CommandLine, "runemu.vbs") < 1 then
                terminate = false
            end if
        end if
        if terminate then
            process.Terminate
        end if
    next
next
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 01:02 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3