Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue in setting the registry for auto logon and resolving the domain user #3760

Merged
merged 5 commits into from
Mar 13, 2017

Conversation

nigurr
Copy link

@nigurr nigurr commented Mar 9, 2017

  • Fix issue in finding the test user session active. Previously we are checking for Active sessions available which doesn't give right result whether test user has active session or not
  • Fix issue in resolving the Domain\Username in Local user groups
  • Fix issue in DTA Process handling if same machine used for v1 and v2

Testing:

$isSessionActive = IsAnySessionActive
if (-not ($isSessionActive))
Set-DisableScreenSaverReg | Out-Null
ConfigurePowerOptions -MachineCredential $MachineUserCredential | Out-Null
Copy link
Contributor

@vimegh vimegh Mar 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConfigurePowerOptions -MachineCredential $MachineUserCredential [](start = 4, length = 64)

ConfigurePowerOptions -MachineCredential $MachineUserCredential [](start = 4, length = 64)

ConfigurePowerOptions function doesn't have any param to accept. Please check. #Resolved

Copy link
Author

@nigurr nigurr Mar 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. PS didn't complain #Resolved

@nigurr nigurr force-pushed the users/nigurr/FixUIIssues branch from c17dc33 to cce533c Compare March 9, 2017 13:43
}
}

# Getting rid of old Session check. WTSEnumerateSessions spits out if there are any active sessions are available
Copy link
Contributor

@vimegh vimegh Mar 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are [](start = 100, length = 3)

are [](start = 100, length = 3)

[opt] not needed #Resolved

Copy link
Author

@nigurr nigurr Mar 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't get this one. comments/stories are good to have ;)
#Resolved

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hence I had said optional [opt]


In reply to: 105172459 [](ancestors = 105172459)

{
$computer = $env:COMPUTERNAME
try {
$quserOut = quser.exe /SERVER:$computer 2>&1
Copy link
Contributor

@vimegh vimegh Mar 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quser [](start = 20, length = 5)

Please check windows 7 supports it or not.
as https://technet.microsoft.com/en-us/library/cc754583(v=ws.11).aspx says
Applies To: Windows Vista, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows 8 #WontFix

Copy link
Author

@nigurr nigurr Mar 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't support Windows 7 in v2 #Resolved

# For UI testing, we need active local users logged in instead of sessions check
function IsTestUserCurrentlyLoggedIn($TestUserName)
{
$computer = $env:COMPUTERNAME
Copy link
Contributor

@vimegh vimegh Mar 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$computer [](start = 4, length = 9)

This is being used only once. Do we really need it. You can directly pass $env:COMPUTERNAME to quser #WontFix

Remove-ItemProperty -Path 'REGISTRY::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name AutoLogonCount -ErrorAction SilentlyContinue
Remove-ItemProperty -Path 'REGISTRY::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefaultPassword -ErrorAction SilentlyContinue
[MS.VS.TestTools.Config.RegHelper]::SetAutoLogonPassword($TestUserPassword)
if ($quserOut -match "No user exists")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$quserOut -match "No user exists" [](start = 8, length = 33)

will this comparison hold in machine with different locales? please check.

return $false
}

$users = $quserOut -replace '\s{2,}', ',' | ConvertFrom-CSV -Header 'username', 'sessionname', 'id', 'state', 'idleTime', 'logonTime'
Copy link
Contributor

@vimegh vimegh Mar 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'username', 'sessionname', 'id', 'state', 'idleTime', 'logonTime' [](start = 72, length = 65)

'username', 'sessionname', 'id', 'state', 'idleTime', 'logonTime' [](start = 72, length = 65)

check for machines with different locales #Resolved

foreach ($user in $users)
{
Write-Verbose "Logged in user: $($user.username) $($user.state)" -Verbose
if(($user.username -ieq $TestUserName) -and ($user.state -ieq 'active')) {
Copy link
Contributor

@vimegh vimegh Mar 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$user.state -ieq 'active' [](start = 53, length = 25)

$user.state -ieq 'active' [](start = 53, length = 25)

please check for different locales #Resolved

Remove-ItemProperty -Path 'REGISTRY::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefaultPassword -ErrorAction SilentlyContinue

[MS.VS.TestTools.Config.RegHelper]::SetAutoLogonPassword($TestUserPassword)
}
Copy link
Contributor

@vimegh vimegh Mar 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add log message - autologon successfully enabled #Resolved

Copy link
Author

@nigurr nigurr Mar 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We print that from C# side for success #Resolved

@vimegh
Copy link
Contributor

vimegh commented Mar 9, 2017

$groupPolicy = (Get-ItemProperty -Path 'REGISTRY::HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop' -ErrorAction SilentlyContinue).ScreenSaveActive

Will this point to wow6432node in 64bit machine?


Refers to: Tasks/DeployVisualStudioTestAgent/SetupTestMachineForUITests.ps1:3 in 7bd2674. [](commit_id = 7bd2674, deletion_comment = False)

Copy link
Member

@RanjanarMS RanjanarMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good..

return true;
}
WTSFreeMemory(userPtr);
WTSFreeMemory(domainPtr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WTS FreeMemory calls should be place in finally

Write-Verbose -Message("Trying to delete service {0}" -f $ServiceName) -Verbose
if($service)
{
$service.StopService()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$service.StopService() [](start = 11, length = 23)

Please check, what happens, if stopping the service throws an error, as we are not handling that?

Write-Verbose -Message("Trying to delete service {0}" -f $ServiceName) -Verbose
if($service)
{
$service.StopService()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$service.StopService() [](start = 11, length = 23)

Should we use -Force option here ?

{
$service.StopService()
$deleteServiceCode = $service.Delete()
if($deleteServiceCode -eq 0)
Copy link
Contributor

@vimegh vimegh Mar 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f($deleteServiceCode -eq 0) [](start = 13, length = 27)

As per https://msdn.microsoft.com/en-us/library/aa389960(VS.85).aspx Delete method returns 0 if the request was accepted and not for error scenario. Please check.

@nigurr nigurr merged commit 0342e8d into master Mar 13, 2017
@nigurr nigurr deleted the users/nigurr/FixUIIssues branch April 10, 2017 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants