|
|
#1 |
|
Solid State Member
Join Date: Nov 2009
Posts: 9
|
My office PC is WinXPPro SP3 with 2GB RAM, a Dell Optiplex 785 I think.
When it shuts down, it hangs, and I'm fairly certain that's because a particular running application, GoToMyPC, doesn't terminate well. (GoToMyPC lets me access the office PC from home or elsewhere.) So I'd like to run a script automatically when I shut down the PC to first turn off GoToMyPC before the rest of the PC shutdown continues. One of the contributors here told me to go to (Start -> run -> gpedit.msc -> computer configuration -> windows settings -> scripts) as the place to put the script. OK, but I've never written a script, so what script should I write to exit from the GoToMyPC application nice and smooth? Is there an app that writes the script for me just by watching my actions -- like recording a macro? If yes, could I "record" myself doing a manual exit from GoToMyPC as the script? Thanks. |
|
|
|
|
|
#2 |
|
Bogan
|
The best way i reckon would be to write a batch file to kill the Gotomypc process.
It would look something like this; Code:
@echo off chdir ROOT DIRECTORY WHERE THE GOTOMYPC EXECUTABLE IS taskkill /IM EXECUTABLE NAME /F Code:
@echo off chdir C:\programs files\gotomypc\ taskkill /IM gotomypc.exe /F Anyway, write the script in notepad and save it as a *.BAT file (FILENAME.bat)
__________________
Desktop:BitFenix Survivor~Gigabyte GA-P67A-UD3R~ i7 2600K @ 4hz~AMD 6870 1GB~12gb Team Elite DDR3 1333~3xWD In RAID5~W7 Ult Laptop:Alienware M11x~ i7-2637M 1.7GHz~16GB 1333MHz DDR3~GeForce GT 540M~W7 Ult |
|
|
|
|
|
#3 |
|
Solid State Member
Join Date: Nov 2009
Posts: 9
|
Dear Mr. dude: Great! Before I try this, should I add a couple of lines that exit from your script if, for some reason, the GoToMyPC process is NOT running when I shut down the PC? Maybe something like "IFERROR ... Quit" (which I remember only from WordPerfect's simple macro language)?
That way, I could put this script into the PC shut down process and never have to remember it. Also, after your taskkill, do we need something like "WAIT 2 seconds"? I found that helpful when doing my WordPerfect macros ten years ago. By the way -- dumb question -- what should I read to learn the basics about the scripting you are doing? Thanks very much. |
|
|
|
|
|
#4 |
|
Bogan
|
Good thing with batch files, if it errors it'll just close itself and once the commands are finished it will also close itself. So if GOTOMYPC isnt running, it will simple open,produce an error and then instantly close itself.
Batch files are pretty much DOS Commands. So you can just put DOS Commands into notepad and save the file as a BAT File, and voila you have a script. All @echo off does is make sure the commands dont appear in the DOS window, only the results. If you want more info, you can read up on them here.
__________________
Desktop:BitFenix Survivor~Gigabyte GA-P67A-UD3R~ i7 2600K @ 4hz~AMD 6870 1GB~12gb Team Elite DDR3 1333~3xWD In RAID5~W7 Ult Laptop:Alienware M11x~ i7-2637M 1.7GHz~16GB 1333MHz DDR3~GeForce GT 540M~W7 Ult |
|
|
|
|
|
#5 |
|
Solid State Member
Join Date: Nov 2009
Posts: 9
|
Dear dude: Don't think your advice is wasted on us noobies! I've been doing some research, inspired by your info and link. Have some follow-up Qs for you:
1) a) Taskkill doesn't seem to require going to the directory/folder where the application lives. I just confirmed that on my home PC, where taskmgr is running. I went to CMD, then did "chdir" to a couple of unrelated directories/folders, then typed "taskkill /im taskmgr.exe", and that works to turn off task manager wherever I am at the moment. Do you agree, or might I be missing something? b) But since my office PC is on an office network, it would be safer to make sure I'm starting somewhere on my C:\ drive, JUST IN CASE my cmd starts in a network drive like I:\ or L:\. How do I do that in my batch file? Start with a line that says "chdir C:\" ? 2) I just checked the GoTOMyPC processes that are running on my office PC. There are at least 8 processes running at the moment (and right now I'm at home using GoToMyPC to look at my office PC so maybe there are fewer running when I'm at the office PC and not linked in from home). Fortunately, all these processes have names that start with "g2". Therefore, from what I can tell, the command could be something like taskkill /fi "IMAGENAME eq g2*" Do you agree? 3) Do you think I should also use the f/ switch to terminate FORCEFULLY? (As opposed to what? Politely?) 4) Is there a command to tell the PC to bring me a scotch and soda? Thanks again! |
|
|
|
|
|
#6 | |||||
|
Site Team
Join Date: Jul 2009
Posts: 2,627
|
Quote:
Quote:
Quote:
Quote:
So yes, the /f switch is definitely required. Quote:
Code:
while(methirsty) {
fetchScotch();
fetchSoda();
}
__________________
Save the whales, feed the hungry, free the mallocs. |
|||||
|
|
|
|
|
#7 |
|
Bogan
|
berry120 summed it up quite nicely! The only reason why i Chdir is because i personally find it easier to do that when modifying scripts, so just personal preference really
__________________
Desktop:BitFenix Survivor~Gigabyte GA-P67A-UD3R~ i7 2600K @ 4hz~AMD 6870 1GB~12gb Team Elite DDR3 1333~3xWD In RAID5~W7 Ult Laptop:Alienware M11x~ i7-2637M 1.7GHz~16GB 1333MHz DDR3~GeForce GT 540M~W7 Ult |
|
|
|
|
|
#8 |
|
Solid State Member
Join Date: Nov 2009
Posts: 9
|
Dude and Berry: Many thanks!
______ ADDED: Dude and Berry: Well, now I'm trying it in the field (sitting at my office PC), and of course nothing is so simple. The .bat file works, but two issues: 1) Of the various running g2 applications, one of them, g2comm.exe, takes maybe 7 seconds to die. So, ideally, my batch file should wait 10 seconds after taskill before quitting to permit the PC shutdown to continue. How do I add "Wait 10 seconds" to the batch file? (Funny there's no direct Wait command in MS-DOS.) 2) So I ran my batch file and saw the g2 processes die. Then I hit Start - Shutdown and found that firefox asked me a question whether or not I wanted to Quit or Save & Quit, with the shutdown process waiting for my answer. Now, if I'd been at home, I wouldn't be able to answer because GoToMyPC would already be off, so the office PC would halt and not restart. I can add a taskkill firefox to my batch file, but is there a more global or elegant solution? (And taskkill firefox would cause Firefox to restart on its own when the PC reboots, which might not be desirable. And what if Firefox is not actually running to begin with - wil taskkill firefox hang?) Thanks again. |
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|