c# - Programmatically login 10 users to remote desktop session -
i trying create application programmatically login 10 users using rdp. purpose autologin these users not have manually it. first server tested against (server 2012) worked fine. however, tried server 2008 r2 , continues prompt me password. here code.
static void main(string[] args) { var password = configurationmanager.appsettings["password"]; var machine = configurationmanager.appsettings["machinename"]; var usernamelist = new list<string>(configurationmanager.appsettings["username"].split(new char[] { ';' })); foreach(string name in usernamelist) { process rdpprocess = new process(); rdpprocess.startinfo.filename = environment.expandenvironmentvariables(@"%systemroot%\system32\cmdkey.exe"); rdpprocess.startinfo.arguments = "/generic:termsrv/" + machine + "/user:" + name + " /pass:" + password; rdpprocess.start(); rdpprocess.startinfo.filename = environment.expandenvironmentvariables(@"%systemroot%\system32\mstsc.exe"); rdpprocess.startinfo.arguments = "/v " + machine; rdpprocess.start(); thread.sleep(3000); } }
i added sleep connections coming fast , getting "connection busy" errors.
can see doing wrong?
don't know why case 2008 servers not work fqdn. ip works fine though. whatever..
Comments
Post a Comment