Qwinsta server ошибка 5 получения имен сеансов

I am getting the «access is denied» error even though I have no problem connecting with Remote Desktop Connection. My computer is Win7, the targets are WinXP or Server 2003.
Perhaps I am specifying the SERVER name incorrectly:
qwinsta /SERVER:XXYYZZ02
I have tried
qwinsta /SERVER:\\XXYYZZ02
qwinsta /SERVER:domain\XXYYZZ02
qwinsta /SERVER:domain/XXYYZZ02
qwinsta /SERVER:1.2.3.4

Am I doing something wrong? TIA…
(The problem I’m trying to solve is several support personnel needing to connect to the same servers and disconnecting each other mid-session.)

Chris J's user avatar

Chris J

30.7k6 gold badges69 silver badges111 bronze badges

asked Mar 3, 2014 at 19:48

Number8's user avatar

3

Found on Dell website, this worked for me same issue.

This means the remote RPC component failed to execute the requested
operation. It is because it is not allowed to operate on terminal
service (Remote Desktop) through RPC by default. To modify this
setting to enable Remote Desktop API through RPC, you need to find
the following registry key:

HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server

Then add a DWORD value named “AllowRemoteRPC” and change its value to
1.

In my case it was set to «0». I changed it to 1 and all was good.

informatik01's user avatar

informatik01

16k10 gold badges74 silver badges104 bronze badges

answered Nov 4, 2014 at 16:38

M_tek's user avatar

M_tekM_tek

1711 silver badge3 bronze badges

3

Refer to this link for the correct command names and alternatives: http://makezine.com/2007/08/15/howto-kill-terminal-services-s/

You might want to try executing from a cmd window run in administrator-mode.

Can you login any other way? e.g.: mstsc /console or via virtual console? I ask because then you can check the server authentication settings on the servers.

answered Mar 3, 2014 at 19:56

Arluin's user avatar

ArluinArluin

5941 gold badge8 silver badges21 bronze badges

1

in cmd, ‘Query Session’ command is returning,

Error 5 getting sessionnames
Error [5]:Access is denied

on Windows 10 Remote desktop — Administrator user.

we have set, AllowRemoteRPC ‘s value to 1

under this HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server

But still problem persists.

Questions:

  • what does AllowRemoteRPC actually do and how it’s value is being used.
  • what to do to make Query Session command work.

asked Jan 2, 2019 at 9:03

Amit's user avatar

9

I think the problem is in the UAC remote restrictions.

Do this on the target computer:

  • Run regedit
  • Navigate to the following registry subkey:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
    
  • If an entry named LocalAccountTokenFilterPolicy registry entry does not exist,
    create it as DWORD

  • Double-click LocalAccountTokenFilterPolicy and set its value to 1.

Reference:

Microsoft’s
Description of User Account Control and remote restrictions in Windows Vista.

answered Jan 9, 2019 at 16:57

harrymc's user avatar

harrymcharrymc

458k31 gold badges532 silver badges929 bronze badges

1

Rather than changing registry values, you could always use PSEXEC from a command prompt or Invoke-Command from a PowerShell prompt to execute QWINSTA locally. Both of these will require you have administrative rights on the remote machine (which means opening the command prompt under other credentials, including the credentials as PSEXEC switches or, in the case of PowerShell, including -Credential (Get-Credential) in the command.

Command prompt example:

PSEXEC \\MYPC cmd /c "qwinsta /server:localhost"

PowerShell example:

Invoke-Command -ComputerName MyPC -ScriptBlock { qwinsta /server:localhost }

zx485's user avatar

zx485

2,17011 gold badges17 silver badges24 bronze badges

answered Sep 25, 2019 at 21:35

James Younger's user avatar

You must log in to answer this question.

Not the answer you’re looking for? Browse other questions tagged

.

To utilize the Command Prompt, take a look at this example. Alternatively, consider using PowerShell with this example. Another solution involves creating a batch file and utilizing the provided code to query information for each hostname in a text file named Server_List.txt. Ensure that the text file is placed beside the batch file you create.

Table of contents

  • Qwinsta —«Error [5]
  • Query QWINSTA in C#
  • Query session command gives error code 5 even when AllowRemoteRPC is set to 1
  • How to get IP or Hostname of connected Windows RDP users?
  • Can qwinsta get the IP/host of a connected user?
  • What is the use of qwinsta?
  • When qwinsta returns information a greater than (>) symbol is displayed?
  • How do I get qwinsta output to an object?

Qwinsta —«Error [5]


Question:

Despite having no issue connecting with the
Remote Desktop
Connection, I’m receiving an «access is
denied» error
» error. The targets are either WinXP or Server 2003, while my computer is Win7. It’s possible that I’m not correctly specifying the server name, which is why I’ve attempted the following options:

qwinsta /SERVER:XXYYZZ02


qwinsta /SERVER:\XXYYZZ02


\
\ \ \ \ qwinsta\ /SERVER:domain\XXYYZZ02\
\ \ \


qwinsta /SERVER:domain/XXYYZZ02


qwinsta /SERVER:1.2.3.4

I’m wondering if I’m making an error. Thanks in advance.
I’m trying to tackle an issue where multiple support staff members have to link to the same servers, and they end up disconnecting each other during their sessions.


Solution 1:

This solution on Dell’s website resolved my problem, which was identical.

The reason behind the failure of the requested operation by the remote RPC component is that operating on terminal service (Remote Desktop) through RPC is prohibited by default. To enable the Remote Desktop API through RPC, you must locate the specified registry key and modify its settings.


\
\ \ \ \ \ HKLM\SYSTEM\CurrentControlSet\Control\Terminal\ Server\
\ \ \ \

Create a DWORD value called «AllowRemoteRPC» and adjust its value to 1.

The value was initially set to «0» in my case, but changing it to 1 resolved the issue.


Solution 2:

For accurate command names and substitutes, please consult this webpage: http://makezine.com/2007/08/15/howto-kill-terminal-services-s/.

Consider running your operation with administrator privileges using
cmd window
.

Is it possible for you to log in using an alternative method such as mstsc /console or virtual console? This would allow you to verify the server authentication settings on the servers.

Qwinsta —«Error [5], This means the remote RPC component failed to execute the requested operation. It is because it is not allowed to operate on terminal …

Query QWINSTA in C#


Question:

Some time ago, I needed to identify the routes in C#, and to accomplish this task, I utilized the code below.

        ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_IP4RouteTable");
        foreach (ManagementObject queryObj in searcher.Get())
        {
            string destination = queryObj["Destination"].ToString();
            string mask = queryObj["Mask"].ToString();
            string metric = queryObj["Metric1"].ToString();
            string interfaceIndex = queryObj["InterfaceIndex"].ToString();
            string nexthop = queryObj["NextHop"].ToString();
            ...
        }

I am interested in logging off a remote desktop session and I am aware that this can be achieved using qwinsta commands. However, I am curious if there is a method to obtain the qwinsta output in C# similar to the aforementioned solution for netstat.


Solution:

It has been discovered that the session ID for a particular server can be obtained through the use of the Cassia library.

        ITerminalServicesManager manager = new TerminalServicesManager();
        using (ITerminalServer server = manager.GetRemoteServer(serverName))
        {
            server.Open();
            foreach (ITerminalServicesSession session in server.GetSessions())
            {
                 NTAccount account = session.UserAccount;
                if (account != null)
                {
                    if (account.ToString() == username)
                    {
                        Disconnect(serverName, session.SessionId);
                    }
                }
            }
        }

Using the aforementioned code, you can extract the necessary information for disconnecting. However, the method for performing the disconnection remains unknown as attempting to execute the logoff command via C# results in an error.



* EDIT *

I have discovered an alternative method of logging off from a remote server programmatically, which does not involve the use of logoff.exe.

    [DllImport("wtsapi32.dll", SetLastError = true)]
    static extern bool WTSLogoffSession(IntPtr hServer, int SessionId, bool bWait);
    [DllImport("wtsapi32.dll", SetLastError = true)]
    static extern IntPtr WTSOpenServer([MarshalAs(UnmanagedType.LPStr)] String pServerName);
    private void Disconnect(string serverName, int sessionId)
    {
        IntPtr server = WTSOpenServer(serverName);
        WTSLogoffSession(server, sessionId, false);
    }

Qwinsta | Microsoft Docs, To query other sessions, the user must have special access permission. If you don’t specify a session using the <username>, …

Query session command gives error code 5 even when AllowRemoteRPC is set to 1


Question:

The ‘Query Session’ command in cmd is currently producing results.

Error 5 getting sessionnames
Error [5]:Access is denied

Using the Administrator user on Remote desktop for Windows 10.

We have assigned a value of 1 to

AllowRemoteRPC

.

under this

\
\ \ \ \ HKLM\SYSTEM\CurrentControlSet\Control\Terminal\ Server\
\ \ \

But still problem persists.

Questions:

  • Can you explain the purpose of

    AllowRemoteRPC

    and how its value is utilized?
  • How to enable Query Session command functionality?


Solution 1:

It appears that the issue lies within the limitations imposed by UAC on remote access.

Do this on the target computer:

  • Run

    regedit
  • Navigate to the following registry subkey:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\
    
  • If an entry named

    LocalAccountTokenFilterPolicy

    registry entry does not exist,
    create it as DWORD

  • Double-click

    LocalAccountTokenFilterPolicy

    and set its value to

    1

    .

Reference:

Windows Vista’s User Account Control and remote limitations were explained in detail by Microsoft.


Solution 2:

Instead of relying on
changing registry
values, you have the option to utilize

PSEXEC

from a command prompt or use Invoke-Command from a PowerShell prompt to run

QWINSTA

on the local machine. For either option, it is necessary to have administrative privileges on the remote machine. This means that you will need to launch the command prompt using alternate credentials, such as those provided by

PSEXEC

switches. Alternatively, if using PowerShell, you can include

-Credential (Get-Credential)

in the command.

Command prompt example:

PSEXEC \\MYPC cmd /c "qwinsta /server:localhost"

PowerShell example:

Invoke-Command -ComputerName MyPC -ScriptBlock { qwinsta /server:localhost }

Can’t query logged on users on terminal server, Stack Exchange network consists of 180 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to …

How to get IP or Hostname of connected Windows RDP users?


Question:

My VBScript is designed to track remote user activity on a server by utilizing «qwinsta» to obtain usernames. I can efficiently monitor user sessions by continuously looping until a disconnect is detected.

After conducting a thorough search, I have not been able to find any cmd or wmi command that provides the hostname or IP address of a remote user based on their session ID or username. Unfortunately, the qwinsta command is also unable to provide this information.

Are there any alternative suggestions to obtain this information? I came across an external tool that displays the IP address, but I prefer not to use it. I believe it may be using WMI or another method to retrieve the IP address which I could potentially implement into my own script.

Although netstat and
filter port
3389 can help me identify RDP sessions and their corresponding IPs, I have no means of determining which
IP belongs
belongs to which user.


Solution 1:

The (mostly) undocumented API WinStationQueryInformationW is the only means to access this information, as it is not available through WMI, command line utility, or any COM object to my knowledge.

If you are proficient in a .NET language, the Cassia library can be utilized to manage the Win32 API calls. You may refer to ITerminalServicesSession.RemoteEndPoint and download the latest trunk build as a guest. Although I haven’t attempted it yet, utilizing
tlbexp
and regasm should enable the use of Cassia from VBScript.


Solution 2:

In a
batch file
, you can utilize the below code to input a text file of hostnames into an array and retrieve rdp session information for each of them. Ensure that the batch file you create is placed beside the Server_List.txt file.

@echo off
setlocal EnableDelayedExpansion
echo RDPSessionINFO > ./results.txt
echo ============== >> ./results.txt
set i=0
for /F %%a in (Server_List.txt) do (
   set /A i+=1
   set array[!i!]=%%a
)
set n=%i%
for /L %%i in (1,1,%n%) do echo !array[%%i]! >> ./results.txt && qwinsta /server:!array[%%i]!>> ./results.txt && echo =================== >> ./results.txt
start notepad.exe ./results.txt

Remote desktop — Query QWINSTA in C#, I Know I can do this with qwinsta commands in but I was wondering if there was some way I can get the results of qwinsta into C# like the solution …


Ok after 2 days of research and messing with policys i still have yet to resolve this issue. Due to vista not having netsend anymore I tried using the msg.exe command. So far I have got it to work just on my local computer. But sending it to other vista computers It gives me an error:

Error 5 getting session names

I am computer Atlantis

Destination: computer designated as «Challenger»

Both running Vista Business SP1

msg /server:atlantis admin «Test Message»

(local to local pc works)

msg /server:challenger admin «Test Message»

—> Response: «Error 5 Getting Session Names»

We are in the same work group, we are not part of a domain

Any help would be appreciated. From reading it seems to be a policy edit that needs to be changed, but I do not know what to change, so any detailed instructions would be greatly appreciated…

Alternative i tried: Also i downloaded netsend by czero.com and I can only send the message to XP computers. I cannot send a message to even myself. 

So you think you can QWINSTA?!

Query WINdows STAtion, for whatever reason doesn’t work for querying who is on a workstation. It works a treat with any server you have permissions on though. You use it to list all the current sessions on the server then you logoff the connection using Reset WINdows STAtion….it sounds daunting but it only resets the session or session name specified. Check them out by running qwinsta /? or rwinsta /? at the commandline.

Anyway, this doesn’t work for workstations.

1

WMIC is a pretty powerful, you can probably do this better with powershell but….shut up.

WMIC /NODE:IP.AD.DRE.SS COMPUTERSYSTEM GET USERNAME

I know these screenshot are shitty but…its something. The only thing you need to change in the above command is the IP address which i helpfully italicised and made red.

2

Понравилась статья? Поделить с друзьями:
  • Qwedl movies ошибка 201
  • Quint dc ups 10a ошибка
  • Quantum break ошибка msvcp100 dll
  • Ps4 ошибка ce 35290 9
  • Ps4 ошибка ce 34788 0 как исправить