Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey,

I have a c# code that connects remotely to a winServer2008 machine (with a local user of that machine).

How do I configure via automated code the logon script that will be executed as soon as the connection is established ?

Cheers,
Posted
Comments
Michel Godfroid 4-May-10 1:22am    
What kind or remote connection is this? Is it a remote cmd prompt, a rdp session, a remote powershell? Do you actually logon to the system?

1 solution

On remote machines, WMI and PSExec will create non-interactive tasks. the RDP logon is a normal user (interactive) logon. Once it has started, you have no control over it anymore.
You could assign a logon script to the user, and test for any of the following environment variables:
CLIENTNAME, which will be the name of the computer from which you connect.
SESSIONNAME, which will be set to the RDP session identifier (note: probably not the case if you connect with the console option)

You could check these and take appropriate action.

Note that I'm not sure if using PSExec or WMI AFTER you create your logon session would not create an interactive process, which would revert to logged-on user. (The question is: what if the user is logged on twice? Which session would it then display on?)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900