Solved

Connecting to Windows7 professional using MSTSC

Posted on 2011-02-21
16
1,188 Views
Last Modified: 2012-05-11
I have a rdp file, that contains user name and password as well as an alternate shell. For my test case the alternate shell is a batch file that calls notepad and waits until notepad exits. Then it logs me out. This works perfectly when connecting to a Windows Server 2003 SP1 Enterprise Edition. I modified the full address parameter to point to a Windows 7 Professional and it logs in successfully to the machine, but does not run the alternate shell (my batch script). If I call the batch script, it works as expected. What's the issue here?

I am connecting from a Windows XP SP3 with Remote Desctop Connection Version 6.17600
0
Comment
Question by:cmnt
  • 9
  • 5
  • 2
16 Comments
 
LVL 68

Expert Comment

by:Qlemo
Comment Utility
The feature to provide an alternative shell is (AFAIK) only available on server, not client OS. Since W7 is a client OS, that will not work.
0
 
LVL 3

Assisted Solution

by:brd24gor
brd24gor earned 150 total points
Comment Utility
This is a known bug in Windows 7. The remote server needs to have Terminal Services installed for remote execution to work.

http://social.technet.microsoft.com/Forums/en-US/winserverTS/thread/2b55ff33-3706-44e4-88a6-19c0b140cd25
0
 

Author Comment

by:cmnt
Comment Utility
@brd24gor:
Your link gave me a good idea. That I am testing right now. Using scheduled tasks should enable me to solve my problem. I need to run automated UI tests and therefore need to use the terminal server (otherwise the UI components are not available to the test software. The win7 scheduled tasks offer a lot of options, so that I am (theoretically) able to run a program when a specific user logs on.

I will hopefully know if it works in an hour.
0
 
LVL 3

Expert Comment

by:brd24gor
Comment Utility
Good deal! Let us know how it works out.
0
 

Author Comment

by:cmnt
Comment Utility
In General the solution works. I encountered a different issue now. It used to be, that there are two rdp licenses per server (so two people can connect at the same time). Can someone confirm that there is either only one remote session available or that there is indeed two sessions possible for a desktop OS (Windows 7 Professional)?

Is there a way to force a connection?  I get the following screenshot and it will disconnect me if I don't press 'yes'. However, the whole process should run automated without human intervention. Any Ideas?

 screenshot for disconnect user message
0
 
LVL 68

Assisted Solution

by:Qlemo
Qlemo earned 350 total points
Comment Utility
MS Licensing requires that you only can use one "interactive" session at any time on a MS client OS. So any other session needs to be "disconnected" - the session exists, but cannot be used without connecting the latter one again.
0
 

Author Comment

by:cmnt
Comment Utility
So questions for the number of interactive sessions is satisfactorily answered. How about an option to force the connection to be established. Is there a corresponding entry in the rdp file or am I forced to use qwinsta and rwinsta? The first option is preferred because less scripting is required for this.
0
 
LVL 68

Expert Comment

by:Qlemo
Comment Utility
There is no logout enforcement option.
The issue with qwinsta/rwinsta is that you need to be logged in to use them.
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:cmnt
Comment Utility
Not sure what you mean by "you need to be logged in to use them"? I used them successfully with server OSs (Win2003 enterprise edition). Isn't there a way to enable them to run from remote?

I found an article that mentioned that I need to set
HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\AllowRemoteRPC
to 1

see http://www.codesoil.net/2007/08/16/big-problem-access-denied-when-using-qwinstaexe-or-wtsopenserver-api/

I am not sure if that will apply to my case as well (win7 prof). I am actually not the owner of the target machine and not an administrator. So I am a little bit limited for using the trial and error strategy. :(
0
 
LVL 68

Accepted Solution

by:
Qlemo earned 350 total points
Comment Utility
Sorry, I was mislead by memory. You can remotely execute query session/reset session, even without setting the above reg entry (at least while in the same domain).

The whole requires you to execute the following before RDPing into the machine:
for /F "tokens=3" %%S in ('qwinsta /server:W7PC ^| find /i "active"') do reset session /server:W7PC %%S
0
 

Author Comment

by:cmnt
Comment Utility
When I run

qwinsta /server:W7PC

Open in new window


I get following error Message:

Error opening Terminal server nettechrobot
Error [1722]:The RPC server is unavailable.

Open in new window


What troubles me, that I can access the
\\W7PC\C$

Open in new window

. When I run
net use \\W7PC

Open in new window

I get the following print out:

Status       Local     Remote                    Network

-------------------------------------------------------------------------------
...
OK                     \\W7PC\IPC$       Microsoft Windows Network
The command completed successfully.

Open in new window


And I can connect to the server using mstsc using the account that I am logged in with locally.

Any Idea to solve this issue??
0
 

Author Comment

by:cmnt
Comment Utility
Update: I missed that HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\AllowRemoteRPC was actually defined. Unfortunately to 0. I changed it to 1 and now I can run qwinsta from a different machine. Therefore, ...

Ignore my last comment.
0
 

Assisted Solution

by:cmnt
cmnt earned 0 total points
Comment Utility
Great it works now. I had to change the command provided to Qlemo to

for /F "tokens=3" %%S in ('qwinsta /server:W7PC ^| find /i "active"') do rwinsta /server:W7PC %%S

Open in new window


The problem was, that on my test command prompt the reset command acted goofy which caused the for-loop to call itself and never actually resetting the terminal server session. rwinsta in contrast worked without issues.
0
 
LVL 68

Expert Comment

by:Qlemo
Comment Utility
Note:
query session is the same as qwinsta
reset session is the same as rwinsta
0
 

Author Comment

by:cmnt
Comment Utility
@Qlemo:

I think you are right with what you said. However, for some reason I got the expected result only with rwinsta and not with reset sessions.

It took me 30 minutes to figure that out. It might have been a problem with my console window or a general problem. I didn't try to figure out if that was a permanent problem or not. I already spent too much time on the original task. :(
0
 

Author Closing Comment

by:cmnt
Comment Utility
Added my own comment, to provide the command line that worked for me.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now