cloudbase / windows-imaging-tools

Tools to automate the creation of a Windows image for OpenStack, supporting KVM, Hyper-V, ESXi and more.
Apache License 2.0
677 stars 227 forks source link

Cannot set value in ini file #208

Closed ksalman closed 6 years ago

ksalman commented 6 years ago

I am trying to create an online image without anything special. From the readme I tried New-WindowsOnlineImage -ConfigFilePath $ConfigFilePath and I am getting this error. Any ideas how to fix that?

PS C:\Users\Administrator\Desktop\windows-openstack-imaging-tools> New-WindowsOnlineImage -ConfigFilePath $ConfigFilePath
6/25/2018 3:58:31 PM - Windows online image generation started.
6/25/2018 3:58:35 PM - Cannot set value in ini file: 3
Cannot set value in ini file: 3
At C:\Users\Administrator\Desktop\windows-openstack-imaging-tools\UnattendResources\ini.psm1:128 char:13
+             throw "Cannot set value in ini file: " + [PSCloudbase.Win ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Cannot set value in ini file: 3:String) [], RuntimeException
    + FullyQualifiedErrorId : Cannot set value in ini file: 3
ksalman commented 6 years ago

I think it's some kind of permission issue but I cannot figure out what exactly. It does create the config.ini.offline file and I think the error is due to it having trouble editing the file after creation. Powershell is running as Adminstrator.

I tried running cmd as Administrator, then started powershell from there and I don't see the error.

ader1990 commented 6 years ago

Hello,

The image generation is required to be run as Administrator. Have you solved the issue by running as Administrator?

Thank you, Adrian

ksalman commented 6 years ago

Yea, I realize that. However the issue is that I see the problem when running Powershell as Administrator. I do not see the problem when I run cmd as Administrator, then starting Powershell from there.

ader1990 commented 6 years ago

Is "$ConfigFilePath" a relative or absolute path? ini powershell module does not work with relative paths.

ksalman commented 6 years ago

Oh wow, you are right. When I use absolute path for $ConfigFilePath, it works.

Shouldn't it also not work when starting Powershell from cmd? I am really curious how it works with relative path path when I fire up Powershell from cmd.

ader1990 commented 6 years ago

Hello,

I will create a patch to convert the relative path to an absolute path in the ini.psm1 module, to make sure this never happens again. Thanks for the bug report.

ader1990 commented 6 years ago

Can you try this fix: https://github.com/cloudbase/windows-openstack-imaging-tools/pull/210 ? It should solve this issue.

ksalman commented 6 years ago

Hi, thanks for the patch. I tested it and it works.

ader1990 commented 6 years ago

Great, I have also merged the PR.

Adrian.