Jump to content

? How to gracefully shut down uT using the XP command line


WinCrazy

Recommended Posts

Posted

Is there a way to automatically shut down uT when I simply log out, restart or shut down from XP ? If there is a command-line method then I could try putting it in a .BAT or .CMD file within my %AppData%\Start Menu\Shutdown folder ? This needs to accomplish the same function as me selecting File > Exit from within uT.

The problem arises when I forget to exit uT and simply log out/shut down. When I restart uT the next time, very often uT shows errors in some or all of the ongoing DL's (but not all the torrents all the time!!). I then have to "force recheck" and restart all the errored torrents.

Posted

uT always closes _very_ quickly when I manually select File > Exit. I have set the XP "forced exit" timeout to 1.00 seconds. Shouldn't this be enough time ?

Posted

OK, you're right, but I actually meant when I right-click the System Tray icon and select Exit (The proper way to shut down uT that always works properly and doesn't corrupt the downloads).

Posted

If it has to re-check after regular closing, then your system is too slow to finish the tasks before the time limit expires. Either speed it up, stop torrent jobs first, or in Preferences > Advanced:

bt.graceful_shutdown: If enabled, µTorrent will take as long as it needs to finish its shutdown sequence (writing in-progress pieces to disk, deleting files in deletion queue, and waiting for tracker replies to stop messages -- among other things). That means that even if it takes several minutes to shutdown gracefully, it will wait for that long, and the process will remain in memory until then. If disabled, µTorrent will limit how long it waits to to 10 seconds, and regardless of the state of the shutdown sequence, µTorrent will force itself to exit.

If you're talking about Windows forced closing though, stop forcing it then :/.

Posted

You can try process -q utorrent.exe first. Then use a utility like wait.exe to wait 10 seconds. Then do a process -k to forcefully kill the process. Hopefully the -q will end µTorrent gracefully, but if µTorrent is still around after you wait time, then the -k will make sure it ends.

Posted

Is there a reason you overrode the windows default 10 second wait to 1? 10 seconds is usually enough time, 1 second... only if you run a low-torrent low-bandwidth uT. uT can get stuck though depending on what happens... noone's been able to explain WHAT can slow down the closing. There's hypotheses, and people say sometimes they have to wait up to 2 minutes before uT closes... but I always see it disappear after 8-10 seconds.

Edit: From hermanm's link that's a nifty program. The guy from http://forum.utorrent.com/viewtopic.php?pid=294440#p294440 wanted to do the same thing, heh. If you know what you're doing you can do similarly, but it requires coding knowledge. Thanks for the link hermanm :D

Posted

I did this quite a while ago because some particular misbehaving apps would not respond in a timely manner to shut down properly when logging out.

Changing the default timeout back to 10 seconds has apparently cured the uT symptoms.

Thanks for the help !!

The default setting for "bt.graceful_shutdown" is "false", meaning "µTorrent will limit how long it waits to to 10 seconds, and regardless of the state of the shutdown sequence, µTorrent will force itself to exit."

There's no hint at what bad things could happen if forced to exit after 10 seconds...

Anyhow, "all's well that ends well". I have found uT to be an incredibly well written app with so many good features that I am amazed. I know how to operate it well, but learning about the in-depth tweaks has been a problem for me. I suppose time will remedy that as I constantly play with it.

Thanks again.

Posted

Well if it's working now there is no need to touch that option, bad things would include loosing a bit of downloaded/in-progress data and having to re-check if its µT's force shutdown. If it's app killing, not sure but I think the appdata can be corrupted.

Posted

"Bad things happen" Mmmmmm love tabletop RPG. GTHK is right that's all the possibilities I know of.

Aside from the rechecking and the lack of storing the last 30 second update... and the possibility of the overwritten/corrupted resume.dat not the whole %APPDATA dir, OR maybe having to restore the unreadable resume.dat by resume.dat.old ... After these happenings you shouldn't directly load up uT if you think there's a possible cause of a problem. Use http://forum.utorrent.com/viewtopic.php?id=31306 to first verify resume.dat or resume.dat.old (if resume.dat is extremely undersized) then pop out a hex editor to fix it. Some procedures are in the BFE thread.

Posted

It's actually 13 seconds, not 10.

In case you're wondering why the graceful shutdown option is off by default, it's because it may never exit (rare, but possible, though I've never experienced it myself), and there's no way to kill it except end process. It'll be default true when there's a better way.

  • 2 months later...
Posted

I have a lot of torrents (about 700 total, 200 downloading -- Yes that is too many, but think of it as a strain test). I have noticed that if I do not set graceful shutdown, the program exits before all of the files are closed (I get rechecks).

The problem is that there is no way to tell when the program has actually exited (even for manual "exit"). I use a Windows shortcut (named "uTorrent Running" to start uTorrent with the following Target (command ) line:

CMD /c CMD /c start "uTorrent Running" /min /normal /wait "%programfiles%\uTorrent\uTorrent.exe"

The /normal is optional. It can also be /abovenormal or /belownormal.

The CMD's must be capitalized. The OS will substitute the full path to your default shell. There are two of them to get around Windows "features". They only take a tiny amount of system resources.

The "Start in" line should contain:

"%programfiles%\uTorrent"

The Run option should be "Minimized".

This will create an extra item in your taskbar that says "uTorrent running". It will show-up as soon as you start the shortcut and will not leave until Windows has closed the uTorrent program. Don't shutdown the system until you see that this taskbar item is gone. I have seen this take over 10 minutes.

After creating the shortcut, I change its icon to the uTorrent icon.

This has only been tested on Windows XP SP2. However, it should work in any version of Windows from 2000 on.

---------------------------------------

P.S. (to development staff) According to the standards, you can place a limit on the time for a TCP response during graceful shutdown. If I remember correctly, this is normally 120 seconds (to allow for high network traffic, resends, etc.), but can be increased. This should avoid the infinite shutdown time problem.

Posted

It was recently changed to wait indefinitely with graceful_shutdown ON. All I've seen to absolutely shutdown uT is some people use Window Messages to tell uT to close :/ I'm guessing you can check some variable... but I wouldn't know where to start.

Posted

If you start uTorrent from a program, you can create a thread that waits for the program to exit (the exec returns the PID, use WaitForMultipleObjects with a time out to tell when the program exits).

You can tell Windows to use the original environment when starting your program. This allows you to set an environment variable when the program starts and stops. However, it is tricky due to memory considerations.

  • 5 years later...
Posted

My solution:

uTorrent -> Preferences -> UI Settings -> Uncheck "Close button closes uT to tray". This will make utorrent to accept kill signal form taskkill command (without "force" switch).

Then script:

@echo off

echo Gracefully killing utorrent...

taskkill /im utorrent.exe

sleep 20 (Linux sleep command for windows, from Cygwin. Or otherelse delay command you want. 20 seconds to utorrent exit and restart without error/recheck)

echo Now I'll shut down..

shutdown -s -f -t 00

This work fine for me.

I hope be healpfull ;)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...