Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How do I make sure that when user A tries to open a .doc(x) file, it will open in Word Viewer, and that when user B does the same it opens in Word 2013. The software is already installed on the system, I'm just wondering how to differentiate between the 2. Both users work remotely on RDS.

share|improve this question
    
Update, see again. –  STTR Aug 19 '13 at 13:40

1 Answer 1

up vote 1 down vote accepted

Way 1, WSH vbscript, WMI query:

GetProcessInfo.vbs:

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE (Name = ""winword.exe"" OR Name = ""WORDVIEW.EXE"") ")

Dim strInfo

Wscript.Echo  "Caption      ProcessId ParentProcessId SessionId ThreadCount UserName                            CommandLine"

For Each objProcess in colProcessList
    strInfo = objProcess.Caption
    strInfo = strInfo & "  " & objProcess.ProcessId
    strInfo = strInfo & "          " & objProcess.ParentProcessId
    strInfo = strInfo & "            " & objProcess.SessionId
    strInfo = strInfo & "          " & objProcess.ThreadCount
    objProcess.GetOwner strNameOfUser, strUserDomain
    strInfo = strInfo & "         " & strUserDomain & "\" & strNameOfUser
    strInfo = strInfo & "         " & objProcess.CommandLine
    Wscript.Echo strInfo
Next

Output:

Caption      ProcessId ParentProcessId SessionId ThreadCount UserName                            CommandLine
WINWORD.EXE  10032          10480            0          7         HT\Administrator         "C:\App32\Microsoft Office\Office12\WINWORD.EXE"
WORDVIEW.EXE  17120          17800            0          4         HT\Administrator         "C:\App32\Microsoft Office\OFFICE11\WORDVIEW.EXE"

Get SessionId command line:

query user

Output:

 USERNAME              SESSIONNAME        ID  STATE   IDLE TIME  LOGON TIME
>administrator         console             0  Active          .  13.08.2013 18:52

Way 2, tasklist, command line:

tasklist /FI "IMAGENAME eq WINWORD.EXE" /V /FO CSV | find /V /I "INFO:"
tasklist /FI "IMAGENAME eq WORDVIEW.EXE" /V /FO CSV | find /V /I "INFO:"

Way 3, Task Manager GUI:

Task Manager User Name, PID, SessionID

Way 4, command line, powershell:

powershell ps^|?{$_.Name -eq'WINWORD' -or $_.Name -eq'WORDVIEW'}^|FT MainWindowTitle,Path,Id,Name,SessionId -Au;query user

Way 5, powershell script:

GetProcessInfo.ps1:

$own=@{};gwmi win32_process|%{$own[$_.handle]=$_.getowner().user}
ps|?{$_.Name -eq 'WINWORD' -or $_.Name -eq 'WORDVIEW'}|FT MainWindowTitle,Path,SessionId,Name,Id,@{n="Owner";e={$own[$_.Id.ToString()]}} -Au
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.