Automatic shutdown after compile?

Discussion in 'Mapping Questions & Discussion' started by Werewolf, Mar 1, 2015.

  1. Werewolf

    aa Werewolf Probably not a real Werewolf

    Messages:
    793
    Positive Ratings:
    235
    This is just a theoretical question but I imagine someone might have a use for it.

    Is it somehow possible to have your computer shut itself down after you have finished compiling? I imagine you would use a batch file to force both hammer to close and then your computer after a short delay, and that you'd have these run from the expert compile menu. The idea would be that it after it has compile, instead of opening the game it would open the batch file/shutdown.exe instead

    Beyond that I'd have no idea, so perhaps someone else might?
     
    Last edited: Mar 1, 2015
  2. A Boojum Snark

    aa A Boojum Snark Toraipoddodezain Mazahabado

    Messages:
    4,769
    Positive Ratings:
    5,536
    If you already know shutdown.exe is a thing... what are you asking? :huh: Yes it is entirely possible, you run it from the expert compile just as you said. Wouldn't really need to force Hammer to close, shutdown sequence already closes anything that is open.
     
  3. Werewolf

    aa Werewolf Probably not a real Werewolf

    Messages:
    793
    Positive Ratings:
    235
    OK I was assuming there might be an extra step you might have to do to make hammer save and close properly before it runs shutdown.exe. I'd also have it run my backup batch file, which as the name suggests makes backups of my files.
     
  4. A Boojum Snark

    aa A Boojum Snark Toraipoddodezain Mazahabado

    Messages:
    4,769
    Positive Ratings:
    5,536
    You've already saved if you are compiling, because you can't compile without the map file :) If you mean't the BSP, the compilers write that themselves, Hammer has nothing to do with it.
     
  5. Werewolf

    aa Werewolf Probably not a real Werewolf

    Messages:
    793
    Positive Ratings:
    235
    Well I've done what I probably should have done in the first place and googled how to do all this, though to be fair I wanted to see if any of the experts here had any insight into the practicalities of this.

    Regardless, I thought I'd share what I have so others can use it. This is what I have got in my batch file:
    Code:
    taskkill /im hammer.exe
    TIMEOUT 10
    copy "C:\Program Files (x86)\Steam\SteamApps\common\Team Fortress 2\content\tf\mapsrc" "C:\Users\Adam\Dropbox\Backup Folder\Source SDK Backups"
    copy "C:\Program Files (x86)\Steam\SteamApps\common\Team Fortress 2\content\tf\mapsrc" "I:\Hammer Backup"
    TIMEOUT 60
    shutdown.exe /s /t 00
    What it should do is close hammer, wait 10 seconds, copy the content of my save directory to my 2 backup locations, wait another 60 seconds, then finally shutdown my PC. The 60 seconds is to give it time to copy all the files to their respective locations.

    For anyone who does not know how to make a batch file, simply open notepad and enter your commands in line by line (1 command per line).
    When saving the document, save it as "<yourfilename>.bat". You might need to add the .bat onto the end. Now if you doubleclick on the Batch file, it will run the commands you told it in the command line
     
    Last edited: Mar 1, 2015
  6. henke37

    aa henke37

    Messages:
    1,947
    Positive Ratings:
    462
    You are new to programming, right? Copy is a synchronous command, execution does not continue until it's done.
     
  7. Werewolf

    aa Werewolf Probably not a real Werewolf

    Messages:
    793
    Positive Ratings:
    235
    Yes I am, hence why I had to Google this stuff and thought to ask people here if it was a safe thing to do, in case doing so would corrupt saves or something. :glare: