Page 1 of 1

Not running as different user

Posted: Fri Feb 01, 2019 7:39 am
by mqh777
I have a form that when compiled will just run some code, no interaction with the end user. This code when run from PowerShell ISE works as expected. It changed the Chrome Browser homepage to what you specify.

Code: Select all

	$policyexists = Test-Path HKLM:\SOFTWARE\Policies\Google\Chrome
	$policyexistshome = Test-Path HKLM:\SOFTWARE\Policies\Google\Chrome\RestoreOnStartupURLs
	$regKeysetup = "HKLM:\SOFTWARE\Policies\Google\Chrome"
	$regKeyhome = "HKLM:\SOFTWARE\Policies\Google\Chrome\RestoreOnStartupURLs"
	$url = ""
	if ($policyexists -eq $false)
		New-Item -path HKLM:\SOFTWARE\Policies\Google
		New-Item -path HKLM:\SOFTWARE\Policies\Google\Chrome
		New-ItemProperty -path $regKeysetup -Name PasswordManagerEnabled -PropertyType DWord -Value 0
		New-ItemProperty -path $regKeysetup -Name RestoreOnStartup -PropertyType Dword -Value 4
		New-ItemProperty -path $regKeysetup -Name HomepageLocation -PropertyType String -Value $url
		New-ItemProperty -path $regKeysetup -Name HomepageIsNewTabPage -PropertyType DWord -Value 0
		Set-ItemProperty -Path $regKeysetup -Name PasswordManagerEnabled -Value 0
		Set-ItemProperty -Path $regKeysetup -Name RestoreOnStartup -Value 4
		Set-ItemProperty -Path $regKeysetup -Name HomepageLocation -Value $url
		Set-ItemProperty -Path $regKeysetup -Name HomepageIsNewTabPage -Value 0
	if ($policyexistshome -eq $false)
		New-Item -path HKLM:\SOFTWARE\Policies\Google\Chrome\RestoreOnStartupURLs
		New-ItemProperty -path $regKeyhome -Name 1 -PropertyType String -Value $url
		Set-ItemProperty -Path $regKeyhome -Name 1 -Value $url

In PowerShell Stuido I have tried the following.

Script Engine: v3 host (windows forms)
output settings: No Manifest, alternate credentials Domain\AdminUser Password: P@$$word (this is an admin account that has local admin rights)

using these settings does not work. I run the compiled .EXE and it does not change the Chrome homepage. I have right clicked my .EXE and picked both "run as Admin" and "run as different user" and neither works.

Thanks for any help you can provide.

Re: Not running as different user

Posted: Fri Feb 01, 2019 9:35 am
by jvierra
This will only change the values for the admin account that it is specified to run under. If you set the policies it is not certain that the policies will be applied to a user on first login.

The functionality of this may also depend on the domain GP settings which will override local machine settings. I recommend using the domain GP template for Google to do this.