c# - Log off Remote Desktop Session on a non admin account programmatically -


i making tool displays remote desktop sessions , spesific process , show if process running on session. , need log off user. launch application right clicking , selecting "run admin", can't set requestedexecutionlevel admin because when don't have admin rights still have ability see sessions.

i first tried disconnect session(but works when run application on admin account, right clicking , selecting "run admin" doesn't work):

static public bool logoff(string sessionid) {     process process = new process();     processstartinfo startinfo = new processstartinfo();     startinfo.windowstyle = processwindowstyle.hidden;     startinfo.filename = "cmd.exe";     startinfo.arguments = "/c logoff " + sessionid;     process.startinfo = startinfo;     process.startinfo.verb = "runas";     process.start();     return true; } 

next tried using this(this works when account i'm running application on admin):

static public bool logoff(string sessionid) {     if (wtslogoffsession(wts_current_server_handle, int.parse(sessionid), true))         return true;     else         return false; } 

my question is, there way can disconnect session when run program on user account while selecting "run admin"?


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -