2

We have a Windows Server 2008 using Terminal Services. When users login, an executable on a network share starts up which contains some hotkeys and macros for various tasks they do.

Whenever I update the executable, I have to close all copies of the program in Task Manager for every single user before the new version of the executable will get launched. If I don't, launching the executable will open the old version, not the new version.

Is there a more efficient way to get Windows to open the new version of the executable instead of the old one?

Going through Task Manager and hitting End Task on every single session is extremely tedious, and it stops everyone's macros from working until they figure out they need to manually restart the program.

Rachel
  • 630
  • 4
  • 12
  • 22
  • I'm thinking you need to make a /TSAWARE application: http://msdn.microsoft.com/en-us/library/01cfys9z%28v=vs.80%29.aspx – Ryan Ries Jan 22 '13 at 19:52
  • 1
    @RyanRies I looked through the link, however I don't think it's related. In addition, the application is written in C# which defaults to all applications to being `TSAWARE:YES` – Rachel Jan 22 '13 at 20:02
  • Instead of having the user launch the binary, why not have the users shortcut/script run a launcher program, that simply runs a version-specific binary. So user runs `launcher.vbs` that starts `program-version-buldnumber.exe`. When you update, you change the launcher, and add the new binary into the folder. – Zoredache Jan 22 '13 at 20:14
  • @Zoredache I was hoping there was something built into Windows that allowed this functionality, as we actually have more than one application on the network share that is accessed by multiple users at once, and exhibit the same problem when I update them. But that's definitely an option I'll keep in mind :) – Rachel Jan 22 '13 at 20:21
  • @Rachel: you may want to elaborate on your update process. Are you renaming the old executable and copying the new file? Is this a straight xcopy deployment? – Greg Askew Jan 22 '13 at 20:38
  • @GregAskew I use [Unlocker](http://en.wikipedia.org/wiki/Unlocker) to unlock the file, then copy/paste the new copy of the executable over top of the old one. I did try renaming the existing file once instead of replacing it, but it didn't make a difference. – Rachel Jan 22 '13 at 20:41

1 Answers1

3

Instead of using task manager you can use taskkill.exe to terminate all instances:

taskkill.exe myapplicationname.exe  


TASKKILL [/S system [/U username [/P [password]]]]
         { [/FI filter] [/PID processid | /IM imagename] } [/T] [/F]

Description:
    This tool is used to terminate tasks by process id (PID) or image name.

Parameter List:
    /S    system           Specifies the remote system to connect to.

    /U    [domain\]user    Specifies the user context under which the
                           command should execute.

    /P    [password]       Specifies the password for the given user
                           context. Prompts for input if omitted.

    /FI   filter           Applies a filter to select a set of tasks.
                           Allows "*" to be used. ex. imagename eq acme*

    /PID  processid        Specifies the PID of the process to be terminated.
                           Use TaskList to get the PID.

    /IM   imagename        Specifies the image name of the process
                           to be terminated. Wildcard '*' can be used
                           to specify all tasks or image names.

    /T                     Terminates the specified process and any
                           child processes which were started by it.

    /F                     Specifies to forcefully terminate the process(es).

    /?                     Displays this help message.

Filters:
    Filter Name   Valid Operators           Valid Value(s)
    -----------   ---------------           -------------------------
    STATUS        eq, ne                    RUNNING |
                                            NOT RESPONDING | UNKNOWN
    IMAGENAME     eq, ne                    Image name
    PID           eq, ne, gt, lt, ge, le    PID value
    SESSION       eq, ne, gt, lt, ge, le    Session number.
    CPUTIME       eq, ne, gt, lt, ge, le    CPU time in the format
                                            of hh:mm:ss.
                                            hh - hours,
                                            mm - minutes, ss - seconds
    MEMUSAGE      eq, ne, gt, lt, ge, le    Memory usage in KB
    USERNAME      eq, ne                    User name in [domain\]user
                                            format
    MODULES       eq, ne                    DLL name
    SERVICES      eq, ne                    Service name
    WINDOWTITLE   eq, ne                    Window title

    NOTE
    ----
    1) Wildcard '*' for /IM switch is accepted only when a filter is applied.
    2) Termination of remote processes will always be done forcefully (/F).
    3) "WINDOWTITLE" and "STATUS" filters are not considered when a remote
       machine is specified.

Examples:
    TASKKILL /IM notepad.exe
    TASKKILL /PID 1230 /PID 1241 /PID 1253 /T
    TASKKILL /F /IM cmd.exe /T
    TASKKILL /F /FI "PID ge 1000" /FI "WINDOWTITLE ne untitle*"
    TASKKILL /F /FI "USERNAME eq NT AUTHORITY\SYSTEM" /IM notepad.exe
    TASKKILL /S system /U domain\username /FI "USERNAME ne NT*" /IM *
    TASKKILL /S system /U username /P password /FI "IMAGENAME eq note*"
Greg Askew
  • 34,339
  • 3
  • 52
  • 81
  • This looks like it will be a much faster way of ending all open copies of the application, although ideally I would like to find a way that does not require me to end every session if possible (since that typically results in help desk calls like "My F2 key isn't working!") :) – Rachel Jan 22 '13 at 20:00
  • Im not sure if it is possible or not. However I will say this may be due to how Windows shares the information about the file across sessions. – Greg Askew Jan 22 '13 at 21:54
  • As an update, I had to use `/F` (force) and `/IM` (image name) to end all instances of an application by name: `taskkill /f /im myapplication.exe`. Simply typing it the way you have it (`taskkill myapplication.exe`) results in an error. – Rachel Mar 28 '13 at 16:05