473,796 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Network drive not accessible within installer class

A file used by my application may be stored on a shared network drive, so
that it can be accessed by different people using the same application. I
have written some code that uses an OpenFileDialog to allow the user to
specify the location of the file (I then store the filename in the
registry). This all works fine from when the application is run normally,
but I would like to force the user to do this when the software is first
installed. To do this I created an Installer Class in my application which
calls the same code. The OpenFileDialog is displayed, but none of the mapped
network drives are available. If I browse to my network places, I get an
access denied error.
Any suggestions appreciated.
TIA
Phil.
Aug 4 '08 #1
5 3573
You might be running into Code Access Security issues. Where is the install
running from?

David
--
=============== =============== ========
David McCarter [Microsoft MVP]
www.dotNetTips.com
David McCarter''''s .NET Coding Standards available at:
http://www.cafepress.com/geekmusicart.1654787045
"Phil" wrote:
A file used by my application may be stored on a shared network drive, so
that it can be accessed by different people using the same application. I
have written some code that uses an OpenFileDialog to allow the user to
specify the location of the file (I then store the filename in the
registry). This all works fine from when the application is run normally,
but I would like to force the user to do this when the software is first
installed. To do this I created an Installer Class in my application which
calls the same code. The OpenFileDialog is displayed, but none of the mapped
network drives are available. If I browse to my network places, I get an
access denied error.
Any suggestions appreciated.
TIA
Phil.
Aug 4 '08 #2
Hi Phil,

I am not an installer expert, but I suspect this problem is caused by the
Windows security architecture. The network drive mapping is a per logon
session information, which means that if a process runs under a different
account as the interactive user, this process can not see the network drive
mapping that is setup by the interactive user. For example, Asp.net process
runs under a service account, so Asp.net can not see any network drive
mapping of interactive user. So, my suspicion is that the OpenFileDialog is
launched by the Windows installer under a different user account.

To prove my concept, I created a sample Winform project with Installer
class; in the OnBeforeInstall () method, I show a messagebox for testing
purpose. , then I created a setup project with it. During the installation
process, I see my messagebox pops up. Then I use Process Explorer's "Find a
Window's Process" feature to find the process of this messagebox(whic h
should be the same process that runs your OpenFileDialog) . The testing
shows that it is the "MsiExec.ex e" process that runs the MessageBox code.
Also it runs under the "NT AUTHORITY\SYSTE M" account instead of my
interactive domain account. This is why your OpenFileDialog can not see the
network drive mapping.

Let's analyze why the "NT AUTHORITY\SYSTE M" account will result in "Access
Deny" while accessing the network path. The SYSTEM account is a super
priviledge account in the local machine, but it can not be recognized
across machines because every machine has its own SYSTEM account. So, when
the SYSTEM account is accessing the network, it is identified as the
machine account. So it is quite possible that the network path on the
remote machine does not grant access for your machine's machine acount. So
the SYSTEM account accessing fails with "Access Deny".

To resolve this problem, we can explicitly establish the network drive
mapping programmaticall y in the Installer code, so that SYSTEM account can
see it. I provided detailed C# code in the link below:
http://groups.google.com/group/micro...curity/msg/063
d7b08b29e5642?h l=zh-CN&

You may use the C# to VB.net converter below to translate the sample code:
http://authors.aspalliance.com/aldot...translate.aspx

Hope it helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 5 '08 #3

"dotNetDave " <do********@dis cussions.micros oft.comwrote in message
news:08******** *************** ***********@mic rosoft.com...
You might be running into Code Access Security issues. Where is the
install
running from?
Thanks for your reply. At the moment I'm just running the msi from the
output folder after I build my setup project. When we ship to customers it
will likely run from CD, or we may allow them to download the msi file from
a website.
Aug 5 '08 #4
Thanks for the detailed response. I think you're right, the installer code
must be running under the SYSTEM account rather than the logged in user who
started it. I have taken a quick look at the link you provided, but in that
example they knew at design time which username and password to log on to
the network as. What I really need is to have the code running under the
user account of whoever it is who started the setup program, so that the
OpenFileDialog will behave just like it does when running a normal
application.
I think it might be easier for me to take this code out of the installer,
and instead run it when the main application is started. I am setting a
value in the registry, so I can check if this value exists, and will then
know if this is the first time it is run or not and only present the
OpenFileDialog on first time use. The reason I preferred to do it in the
installer though is that I have several different executables which may be
installed from the same setup project, so I will need to do this in all of
them (I'll perhaps create a DLL that they can each use to do this).
I would still be interested for future reference though to know if there is
a way to have the installer code run under the normal user account instead
of SYSTEM.

Thanks,
Phil.
Aug 5 '08 #5
Hi Phil,

Thank you for the feedback.

Yes, since the SYSTEM account does not have the network credential to
access the remote machine we have to explicit provide username/password
pair to establish a new security context. This is the key shortage.

I am not a setup project expert. But I have talked with my setup
specialized colleague, he told me that .Net setup project does not offer
the capability to specify the MSI Windows service running account. So I do
not think we can run the installer code under the interactive user account
using .Net setup project. However, I am not sure if Win32 MSI has this
limitation.

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== ===========
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 6 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3657
by: Robert Tarantino | last post by:
Hello, I am trying to find a way to create a scheduled task or service that will copy my local profile folders under "Documents and settings" to a network drive. This would allow me to restore my settings if my profile became tampered with or corrupt. Is there any sample code available out there? -Robert
14
2327
by: frostalicious | last post by:
Used VB.NET (on my client PC) to convert VB6 executable to .NET executable. Placed the .exe file on a network drive on my server. From client, ran .NET Wizards "Trust an Assembly" to make the .exe (on the network drive, on the server) "Full Trust." From the client, double-click on the ..exe (on the network drive, on the server) and it runs fine. So far, so good, but... On the server, where I've installed not VB.NET but .NET
2
2677
by: .Net Believer | last post by:
I using the routine below to copy file to a network drive for a regular backup process. Before calling this routine I using another function to check the presence of the LAN connection and the server where the network drive exists. Although of this check I am sometimes getting an exception (in 5% of times)saying "Could not find the U:\...\File.ext" or part of its path" Although the network dirve is available and accessible by windows...
2
5013
by: Li Pang | last post by:
Hi, I'd like to know how to easily map a network drive using vb.net. thanks
3
2102
by: Brecht Yperman | last post by:
Hi, I am running a .NET application as a Windows Service. In that application I create a FileSystemWatcher. I want it to watch a network drive which maps to an IBM iSeries IFS directory. Every time I log in, I have to retype the password to connect to that network drive, so it isn't stored and thus the service cannot connect to the network drive.
4
1632
by: Martin | last post by:
Hi all. I think that it is very discussed topic, but I still did not find a satisfying answer. Is there any way how to run an application from network drive without setting permissions for the application manually? The users often do not know anything about the .Net security, so they are unable to set the permissions. Moreover if I try to run my applications from network, they do not throw any exception, no error message appears -
10
11050
by: =?Utf-8?B?Z3JlYXRiYXJyaWVyODY=?= | last post by:
Sorry about that previous one. I pressed enter too early. How does one go about mapping a network drive in C#. i know you use MapNetworkDrive in scripting languages, but i'm not sure how to do it in C#. It doesnt seem like C$ would use MapNetworkDrive.
17
3222
by: ayush patel | last post by:
Hi all, I have created a windows service that has a file watcher and does some operation after it reads that file. i developed it in my local machine and installed the service on server. i have changed the file path and everythng according to server drives. we all in the office share some network drives in which ppl will keep pasting that file and the service on server has to pick it up. which its not doing. when i paste it in netwrok...
5
1695
by: Bob | last post by:
Hello All, I have created a vb.net app that I want to place on a network drive. Each time I try to execute it from the network, a security violation pops up and prohibits the app from running. Running from my local system everything works fine. I can't give the exact error because I'm not at work where this occurs. The error is something like "No Security Priviledges ---- zone: Intranet." I googled and found a near match, but reading...
0
9680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9528
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10230
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10174
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10012
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7548
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5442
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.