Discussion:
Setup Project DirectoryInfo UNC permission issues
(too old to reply)
Robert Ellis
2009-12-03 13:14:38 UTC
Permalink
Good afternoon,

I have a Setup Project within a Visual Studio 2008 Solution, and within the
same Solution a DLL Assembly containing an Installer class.

The Setup Project incorporates the Primary Output of the DLL and uses the
Installer class for an "AfterInstall" Custom Action.

Here is a code snippet from the AfterInstall event of the DLL Installer
class:

' This is the target Path

Dim tarPath As String = Me.Context.Parameters.Item("TARDIR").ToString

tarPath = System.IO.Path.Combine(tarPath, "Data\Gbr.001")

' Get Source path

Dim sorPath As String = Me.Context.Parameters.Item("SORDIR").ToString

If Right(sorPath, 1) <> "\" Then sorPath += "\"

Dim sorExist As Boolean = False

Dim fls() As System.IO.FileInfo = Nothing

Try

'Dim x As String = Threading.Thread.CurrentPrincipal.Identity.Name.ToString

Dim dInfo As System.IO.DirectoryInfo = New System.IO.DirectoryInfo(sorPath)

fls = dInfo.GetFiles()

sorExist = True

Catch ex As Exception

sorExist = False

End Try



The dInfo DirectoryInfo class is constructed using a UNC path as the
argument, in this case of the format \\Servername\Share\Folder. The UNC
path points to a remote server on the same LAN as my development PC.

I debug the project by right-clicking on the Setup project and choosing to
Install. When the MSI Setup Installer requests that I choose a debugger, I
choose my VS2008 IDE and I can hit a breakpoint immediately after dInfo has
been instantiated.



At this point, the situation is always the same: dInfo reports that "Access
is Denied" to the UNC path.

The UNC path is definitely good in the sense that I can browse to it; and
moreover, permissions have been configured such that EVERYONE has Full
Control of the Share, and Everyone has full control of the underlying NTFS
folders.

So taken at face value the issue would appear possibly to be that the
process does not have sufficient permission to access Network Resources from
the local PC? I have noticed that the Windows Installer Service runs under
the Local System Account, which presumably cannot access network resources.
Will I need to revise my strategy to avoid trying to access network
resources from an MSI Installer?



As a temporary workaround, I have tried modifying the Log On properties of
the Windows Service to utilise a Domain Admin account. The service will
start okay using this logon. However, when I try to run the Install from the
IDE (i.e. start the debugging process) I get an error message that says,

"The Windows Installer Service could not be accessed. This can occur if you
are running Windows in safe mode, or if the Windows Installer is not
correctly installed. Contact your support personnel for assistance."



I would be grateful for any thoughts as to how I can progress; really at the
proverbial Road Block with this one



Best regards
Robert Ellis
2009-12-03 16:36:01 UTC
Permalink
Intriguingly, I have resolved this problem by:-

(1) Building the full solution;
(2) Not launching the debug session from the IDE, but instead, browsing to
the Build directory, right-clicking on Setup.exe, choosing "Run As...",
specifying my own User Account, and unchecking the box that reads: "Protect
my computer ...activity."

Why exactly launching the MSI from the IDE would cause it to run within a
different security context is a question that, for me, remains, but can wait
for another day.

thanks
Post by Robert Ellis
Good afternoon,
I have a Setup Project within a Visual Studio 2008 Solution, and within
the same Solution a DLL Assembly containing an Installer class.
The Setup Project incorporates the Primary Output of the DLL and uses the
Installer class for an "AfterInstall" Custom Action.
Here is a code snippet from the AfterInstall event of the DLL Installer
' This is the target Path
Dim tarPath As String = Me.Context.Parameters.Item("TARDIR").ToString
tarPath = System.IO.Path.Combine(tarPath, "Data\Gbr.001")
' Get Source path
Dim sorPath As String = Me.Context.Parameters.Item("SORDIR").ToString
If Right(sorPath, 1) <> "\" Then sorPath += "\"
Dim sorExist As Boolean = False
Dim fls() As System.IO.FileInfo = Nothing
Try
'Dim x As String =
Threading.Thread.CurrentPrincipal.Identity.Name.ToString
Dim dInfo As System.IO.DirectoryInfo = New
System.IO.DirectoryInfo(sorPath)
fls = dInfo.GetFiles()
sorExist = True
Catch ex As Exception
sorExist = False
End Try
The dInfo DirectoryInfo class is constructed using a UNC path as the
argument, in this case of the format \\Servername\Share\Folder. The UNC
path points to a remote server on the same LAN as my development PC.
I debug the project by right-clicking on the Setup project and choosing to
Install. When the MSI Setup Installer requests that I choose a debugger, I
choose my VS2008 IDE and I can hit a breakpoint immediately after dInfo
has been instantiated.
At this point, the situation is always the same: dInfo reports that
"Access is Denied" to the UNC path.
The UNC path is definitely good in the sense that I can browse to it; and
moreover, permissions have been configured such that EVERYONE has Full
Control of the Share, and Everyone has full control of the underlying NTFS
folders.
So taken at face value the issue would appear possibly to be that the
process does not have sufficient permission to access Network Resources
from the local PC? I have noticed that the Windows Installer Service runs
under the Local System Account, which presumably cannot access network
resources. Will I need to revise my strategy to avoid trying to access
network resources from an MSI Installer?
As a temporary workaround, I have tried modifying the Log On properties of
the Windows Service to utilise a Domain Admin account. The service will
start okay using this logon. However, when I try to run the Install from
the IDE (i.e. start the debugging process) I get an error message that
says,
"The Windows Installer Service could not be accessed. This can occur if
you are running Windows in safe mode, or if the Windows Installer is not
correctly installed. Contact your support personnel for assistance."
I would be grateful for any thoughts as to how I can progress; really at
the proverbial Road Block with this one
Best regards
Wilson, Phil
2009-12-03 18:47:22 UTC
Permalink
If you launch the raw MSI as an administrator, VS-generated custom actions
run with the SYSTEM account. So yes, you typically won't have network access
privileges. This is connected to UAC. What OS is this?
--
Phil Wilson
The Definitive Guide to Windows Installer
http://www.apress.com/book/view/1590592972
Post by Robert Ellis
Intriguingly, I have resolved this problem by:-
(1) Building the full solution;
(2) Not launching the debug session from the IDE, but instead, browsing to
the Build directory, right-clicking on Setup.exe, choosing "Run As...",
"Protect my computer ...activity."
Why exactly launching the MSI from the IDE would cause it to run within a
different security context is a question that, for me, remains, but can
wait for another day.
thanks
Post by Robert Ellis
Good afternoon,
I have a Setup Project within a Visual Studio 2008 Solution, and within
the same Solution a DLL Assembly containing an Installer class.
The Setup Project incorporates the Primary Output of the DLL and uses the
Installer class for an "AfterInstall" Custom Action.
Here is a code snippet from the AfterInstall event of the DLL Installer
' This is the target Path
Dim tarPath As String = Me.Context.Parameters.Item("TARDIR").ToString
tarPath = System.IO.Path.Combine(tarPath, "Data\Gbr.001")
' Get Source path
Dim sorPath As String = Me.Context.Parameters.Item("SORDIR").ToString
If Right(sorPath, 1) <> "\" Then sorPath += "\"
Dim sorExist As Boolean = False
Dim fls() As System.IO.FileInfo = Nothing
Try
'Dim x As String =
Threading.Thread.CurrentPrincipal.Identity.Name.ToString
Dim dInfo As System.IO.DirectoryInfo = New
System.IO.DirectoryInfo(sorPath)
fls = dInfo.GetFiles()
sorExist = True
Catch ex As Exception
sorExist = False
End Try
The dInfo DirectoryInfo class is constructed using a UNC path as the
argument, in this case of the format \\Servername\Share\Folder. The UNC
path points to a remote server on the same LAN as my development PC.
I debug the project by right-clicking on the Setup project and choosing
to Install. When the MSI Setup Installer requests that I choose a
debugger, I choose my VS2008 IDE and I can hit a breakpoint immediately
after dInfo has been instantiated.
At this point, the situation is always the same: dInfo reports that
"Access is Denied" to the UNC path.
The UNC path is definitely good in the sense that I can browse to it; and
moreover, permissions have been configured such that EVERYONE has Full
Control of the Share, and Everyone has full control of the underlying
NTFS folders.
So taken at face value the issue would appear possibly to be that the
process does not have sufficient permission to access Network Resources
from the local PC? I have noticed that the Windows Installer Service runs
under the Local System Account, which presumably cannot access network
resources. Will I need to revise my strategy to avoid trying to access
network resources from an MSI Installer?
As a temporary workaround, I have tried modifying the Log On properties
of the Windows Service to utilise a Domain Admin account. The service
will start okay using this logon. However, when I try to run the Install
from the IDE (i.e. start the debugging process) I get an error message
that says,
"The Windows Installer Service could not be accessed. This can occur if
you are running Windows in safe mode, or if the Windows Installer is not
correctly installed. Contact your support personnel for assistance."
I would be grateful for any thoughts as to how I can progress; really at
the proverbial Road Block with this one
Best regards
Robert Ellis
2009-12-03 19:11:53 UTC
Permalink
The O/S is Windows XP Professional SP3
Post by Wilson, Phil
If you launch the raw MSI as an administrator, VS-generated custom actions
run with the SYSTEM account. So yes, you typically won't have network
access privileges. This is connected to UAC. What OS is this?
--
Phil Wilson
The Definitive Guide to Windows Installer
http://www.apress.com/book/view/1590592972
Post by Robert Ellis
Intriguingly, I have resolved this problem by:-
(1) Building the full solution;
(2) Not launching the debug session from the IDE, but instead, browsing
to the Build directory, right-clicking on Setup.exe, choosing "Run
As...", specifying my own User Account, and unchecking the box that
reads: "Protect my computer ...activity."
Why exactly launching the MSI from the IDE would cause it to run within a
different security context is a question that, for me, remains, but can
wait for another day.
thanks
Post by Robert Ellis
Good afternoon,
I have a Setup Project within a Visual Studio 2008 Solution, and within
the same Solution a DLL Assembly containing an Installer class.
The Setup Project incorporates the Primary Output of the DLL and uses
the Installer class for an "AfterInstall" Custom Action.
Here is a code snippet from the AfterInstall event of the DLL Installer
' This is the target Path
Dim tarPath As String = Me.Context.Parameters.Item("TARDIR").ToString
tarPath = System.IO.Path.Combine(tarPath, "Data\Gbr.001")
' Get Source path
Dim sorPath As String = Me.Context.Parameters.Item("SORDIR").ToString
If Right(sorPath, 1) <> "\" Then sorPath += "\"
Dim sorExist As Boolean = False
Dim fls() As System.IO.FileInfo = Nothing
Try
'Dim x As String =
Threading.Thread.CurrentPrincipal.Identity.Name.ToString
Dim dInfo As System.IO.DirectoryInfo = New
System.IO.DirectoryInfo(sorPath)
fls = dInfo.GetFiles()
sorExist = True
Catch ex As Exception
sorExist = False
End Try
The dInfo DirectoryInfo class is constructed using a UNC path as the
argument, in this case of the format \\Servername\Share\Folder. The UNC
path points to a remote server on the same LAN as my development PC.
I debug the project by right-clicking on the Setup project and choosing
to Install. When the MSI Setup Installer requests that I choose a
debugger, I choose my VS2008 IDE and I can hit a breakpoint immediately
after dInfo has been instantiated.
At this point, the situation is always the same: dInfo reports that
"Access is Denied" to the UNC path.
The UNC path is definitely good in the sense that I can browse to it;
and moreover, permissions have been configured such that EVERYONE has
Full Control of the Share, and Everyone has full control of the
underlying NTFS folders.
So taken at face value the issue would appear possibly to be that the
process does not have sufficient permission to access Network Resources
from the local PC? I have noticed that the Windows Installer Service
runs under the Local System Account, which presumably cannot access
network resources. Will I need to revise my strategy to avoid trying to
access network resources from an MSI Installer?
As a temporary workaround, I have tried modifying the Log On properties
of the Windows Service to utilise a Domain Admin account. The service
will start okay using this logon. However, when I try to run the Install
from the IDE (i.e. start the debugging process) I get an error message
that says,
"The Windows Installer Service could not be accessed. This can occur if
you are running Windows in safe mode, or if the Windows Installer is not
correctly installed. Contact your support personnel for assistance."
I would be grateful for any thoughts as to how I can progress; really at
the proverbial Road Block with this one
Best regards
Loading...