These are chat archives for chocolatey/ChocolateyGUI

15th
May 2017
Hitesh
@TechMinder
May 15 2017 16:49
I need some guidance or help to install Chocolatey and ChocolateyGUI with batch file. so the user run the batch file as an administrator and it installs Chocolatey, ChocolateyGUI and then add source which appears in ChocolateyGUI's sources. So far it kinds or work but ChoolateyGUI needs to be run as an administrator for the first time otherwise it throws an autofac exception. Also, source added through batch(command line) doesn't show up until chocolateyGUI is run under administrator account. Am I doing correct or is there any other better way of doing the same?
@RichiCoder1 @gep13 @ferventcoder Do you guys know why it doesn't prompt for administrator rights?
Rob Reynolds
@ferventcoder
May 15 2017 17:06
@TechMinder install the prerelease
See the instructions on where to source it from in the github readme. HTH
Hitesh
@TechMinder
May 15 2017 18:12
@ferventcoder I am using prerelease version.
Richard Simpson
@RichiCoder1
May 15 2017 18:13
@TechMinder What's the AutoFac exception you're seeing? That's quite peculiar.
Hitesh
@TechMinder
May 15 2017 18:14
I will send the screenshot shortly.
Richard Simpson
@RichiCoder1
May 15 2017 18:16
:+1:. And the log file too if you can. Should be under %UserProfile%/AppData/Local/ChocolateyGui/Logs or something like that
@RichiCoder1 I don't see any log files generated under user's Appdata folder.
Richard Simpson
@RichiCoder1
May 15 2017 18:48
Hmm. That def looks like a choco issue. @ferventcoder Does choco have first-start code?
Hitesh
@TechMinder
May 15 2017 18:49
@RichiCoder1 It should prompt for administrator permission if it requires an administrator rights.
Richard Simpson
@RichiCoder1
May 15 2017 18:50
The thing is, that call shouldn't. The fact that it does it bizzare.
Hitesh
@TechMinder
May 15 2017 18:50
@RichiCoder1 @ferventcoder here is the example https://msdn.microsoft.com/en-us/library/bb756929.aspx
Richard Simpson
@RichiCoder1
May 15 2017 18:51
@TechMinder Haha, you definitely don't need to tell me about proper evelation procedures. We have a whole subprocess just to deal with admin elevation issues ;P
Hitesh
@TechMinder
May 15 2017 18:53
@RichiCoder1 :) I know you are guys know already, but I shared to clear my problem about the permission.
Rob Reynolds
@ferventcoder
May 15 2017 19:08
@RichiCoder1 @TechMinder "Access to the path 'C:\Program Files (x86)\ChocolateyGUI\redirects\choco.exe' is denied" looks like a choco issue?
@TechMinder in PowerShell, what does the following return? $env:ChocolateyInstall
Hitesh
@TechMinder
May 15 2017 19:09
@ferventcoder let me run this command
Rob Reynolds
@ferventcoder
May 15 2017 19:10
@RichiCoder1 so choco will extract resources on first run, but they are already likely to exist at C:\ProgramData\chocolatey
if it is attempting to extract them elsewhere, you are using a debug-built version of chocolatey lib or that environment variable is not available
Hitesh
@TechMinder
May 15 2017 19:13

here is my script in batch file ```
SET installerPath=\<network-location>\Packages

CD %UserProfile%\My Documents

SET chocoDir=choco
IF not exist %chocoDir% (mkdir %chocoDir%)

CD %chocoDir%

COPY "\<NetworkPath>\choco\choco.exe"

choco.exe install Chocolatey

choco.exe install chocolateygui --source https://www.myget.org/F/chocolateygui/ --pre --force

choco.exe source add -n internalApps -s %installerPath%
```

It installs both chocolatey and then chocolateygui.
@ferventcoder I checked at user's machine and above batch didn't add environment variable. so '$env:ChocolateyInstall' returns nothing.
$env:ChocolateyInstall
Rob Reynolds
@ferventcoder
May 15 2017 19:17
the batch may not have it available yet
if you ran that by cmd.exe, you should call echo %ChocolateyInstall%
Hitesh
@TechMinder
May 15 2017 19:20
@ferventcoder I ran that command in windows powershell.
Rob Reynolds
@ferventcoder
May 15 2017 19:20
so shells don't update until closed and reopened (for environment variables)
and sometimes explorer won't catch updates either
Hitesh
@TechMinder
May 15 2017 19:21
@ferventcoder got it!
Rob Reynolds
@ferventcoder
May 15 2017 19:21
if explorer hasn't noticed, you will need to reboot the machine for it to take effect
but an install of choco will set that variable
you will see it if you head into system properties and look at the variables
or into the registry where those are kept
Hitesh
@TechMinder
May 15 2017 19:30
@ferventcoder I installed chocolateygui in separate cmd.exe(Administrator). And i got the same Autofac exception on first run. If I run ChocolateyGui as administrator then it works fine.
Rob Reynolds
@ferventcoder
May 15 2017 19:31
it's creating files it should not
it won't do that if that environment variable is recognized
Hitesh
@TechMinder
May 15 2017 19:32
@ferventcoder yep! that's the issue. I don't know why it won't create environment variable even if I run the batch as administrator. Do you think it's not right approach to install chocolatey?
@ferventcoder I forgot to mention, the batch file is on shared location.
Rob Reynolds
@ferventcoder
May 15 2017 19:33
install choco as an admin
that's fine
the problem is likely elsewhere
If you see this only happen on a handful of systems
it's explorer.exe not recognizing the updated values
Hitesh
@TechMinder
May 15 2017 19:34
it's happening on every machine where I am installing using batch file.
Rob Reynolds
@ferventcoder
May 15 2017 19:35
you can try this from cmd.exe to trigger it: setx trigger 1, then close and reopen everything
take a look at how choco handles updating environment variables for clues to what may be going on - https://github.com/chocolatey/choco/blob/2f588e755e33e4476f5170494c097932a23e1554/src/chocolatey.resources/helpers/functions/Set-EnvironmentVariable.ps1
Hitesh
@TechMinder
May 15 2017 19:35
@ferventcoder thanks Rob, let me try this.
Rob Reynolds
@ferventcoder
May 15 2017 19:36
you can try killing and restarting explorer.exe (it's a bit hacktastic as compared to a reboot, but... (shrugs))
that will ensure all environment settings and changes get loaded
start with setx
Hitesh
@TechMinder
May 15 2017 19:38
Thanks Rob, I will try the options you provided.
thanks for your help. I will let you know if it gets solved..
Rob Reynolds
@ferventcoder
May 15 2017 19:45
Also, follow this -chocolatey/choco#1297
Hitesh
@TechMinder
May 15 2017 21:48
@ferventcoder as per your suggestion, I am setting up envionrment variable ChocolateyInstall through command after installing Chocolatey as an admin. It works now.
Rob Reynolds
@ferventcoder
May 15 2017 22:48
@TechMinder you should not need to, it will add it
if it doesn't, that is a bug
but I did ask you to verify that it was added to the registry already
Because many times Windows does weird stuff
it's helpful to know if it is something local acting weird or not