Automatic shutdown after compile?

Werewolf

Probably not a real Werewolf
aa
Apr 12, 2011
873
309
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:

A Boojum Snark

Toraipoddodezain Mazahabado
aa
Nov 2, 2007
4,775
7,670
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.
 

Werewolf

Probably not a real Werewolf
aa
Apr 12, 2011
873
309
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.
 

A Boojum Snark

Toraipoddodezain Mazahabado
aa
Nov 2, 2007
4,775
7,670
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.
 

Werewolf

Probably not a real Werewolf
aa
Apr 12, 2011
873
309
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:

henke37

aa
Sep 23, 2011
2,075
515
You are new to programming, right? Copy is a synchronous command, execution does not continue until it's done.
 

Werewolf

Probably not a real Werewolf
aa
Apr 12, 2011
873
309
You are new to programming, right? Copy is a synchronous command, execution does not continue until it's done.
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: