Error [7045]:The requested session access is denied. when running 2 times

10,113

I've found the solution, use the command with runas! runas /savecred /user:yogurt\administrator "tscon.exe 3 /dest:console" , to pass the password for the administrator use the script on http://www.sysopt.com/showthread.php?153867-quot-runas-quot-command-line-without-manually-typing-a-password

Share:
10,113

Related videos on Youtube

Nicholas
Author by

Nicholas

Updated on September 18, 2022

Comments

  • Nicholas
    Nicholas over 1 year

    I'm trying to run some automated GUI tests without a screen by using the command

    tscon 3 /dest:console 
    

    This worked great on a Windows Server 2008 (32bit) but I'm trying to move everything to Windows Server 2008 R2 (64bit) and running into a problem with this. On the original machine it was no problem to run the tests without a screen for multiple times (without entering the machine by RDP). Now on the new machine the tests are also able to run with the same command for one time but when trying it for a second time (without entering the machine by using RDP) I get the error:

    Error [7045]:The requested session access is denied.

    I tried to use the following script found on this issue:

    for /f %%i in ('qwinsta ^| grep "^>" ^| awk "{print $4}"') do set VAR=%%i
    tscon %var% /dest:console
    

    but it also only works the 1st time. The second time it also returns ID 3 but then I get the access is denied error.

    • Nicholas
      Nicholas about 10 years
      I've found the solution, use the command with runas! runas /savecred /user:yogurt\administrator "tscon.exe 3 /dest:console" , to pass the password for the administrator use the script on sysopt.com/…
    • K_Rol
      K_Rol over 7 years
      You should answer your own question and mark it as good answer.