none
start if not running (game server) "i'm a noob on script" RRS feed

  • Question

  • while 1
        If not ProcessExists"7DaysToDieServer.exe" then
            ShellExecute"C:\Program Files (x86)\Steam\steamapps\common\7 Days to Die Dedicated Server\startdedicated.bat""""C:\Program Files (x86)\Steam\steamapps\common\7 Days to Die Dedicated Server"
        End If
        Sleep(30000)

    WEnd

    "somebody can tell me what i doing wrong with this script please?

    i need a script loop to revive my server when he's auto shutdown. thx in advance"

    I'm on windows 10



    • Edited by Frenchies03 Friday, November 15, 2019 8:05 PM
    Friday, November 15, 2019 8:03 PM

All replies

  • The formatting of your question makes it very difficult to understand.

    The problem with your script is that it's not valid code.

    Please read the following post from the top of this forum:

    This forum is for scripting questions rather than script requests


    -- Bill Stewart [Bill_Stewart]

    Friday, November 15, 2019 8:24 PM
    Moderator
  • ok thanks. I'm a beginner in script,i will ask for advice in the forum of my games. Thank you for the reply
    Friday, November 15, 2019 8:51 PM
  • Just add the exe to a scheduled task that runs on startup.

    Your issue is not a scripting issue but is a "how do I use Windows" issue.

    Follow Bill's advice and hire a consultant.


    \_(ツ)_/

    Friday, November 15, 2019 9:18 PM
  • Your logic seems to be correct. However running a loop like this might cost unnecessary process cycles and its prone to failures(ex:accidental closure of the script). I think the best way to go about that is making your script without a loop and register it as a scheduled task to trigger it.

    ps script

    https://stackoverflow.com/questions/8834278/powershell-if-a-process-is-not-running-start-it

    schedule task creation

    https://stackoverflow.com/questions/4249542/run-a-task-every-x-minutes-with-windows-task-scheduler

    run ps script as a command

    https://stackoverflow.com/questions/2035193/how-to-run-a-powershell-script

    Friday, November 15, 2019 10:05 PM
  • The task scheduler running once per minute would be easiest.  PowerShell would be easiest.

    No one who does not know scripting should use VBScript as it is obsolete and soon to be removed from Windows.  Don't waste time learning it as you first scripting language.


    \_(ツ)_/

    Friday, November 15, 2019 10:11 PM
  • There is no ProcessExists or ShellExecute function in VB script. Even if there were, there should be parens around the passed arguments like the Sleep command.

    If not ProcessExists("7DaysToDieServer.exe") then

    I don't know what that is. Psuedo code? 

     
    Saturday, November 16, 2019 1:09 AM
  • There is no ProcessExists or ShellExecute function in VB script. Even if there were, there should be parens around the passed arguments like the Sleep command.

    If not ProcessExists("7DaysToDieServer.exe") then

    I don't know what that is. Psuedo code? 

     

    VBScript does not use parens on sub routine calls. On function calls they are not used except when you are assigning the output to a variable.

    In an "if/Then" they would be used as you have shown but that is because an if/then test is assigning a varuiablke although the variable is an "anonymous" variable that is created hidden so that syntax assumes the call is to a function.

    "ProcessExists" is an old VBS library call that exists in some subsystems.

    The lesson here is DON"T USE VBSCRIPT for any new work.


    \_(ツ)_/

    Saturday, November 16, 2019 2:13 AM