?
Solved

How to copy files in C:\Program Files\.... in Windows Vista ?

Posted on 2007-10-11
13
Medium Priority
?
4,985 Views
Last Modified: 2008-01-09
I have to setup an SQL database with an installation CD for my customers.
I copy the datafiles (*.mdf) with a little VB.NET 2005 program.
In Windows XP ip works well but in Windows Vista the datafiles are not copy in C:\Program Files\Microsoft SQL Server\ ....\Data but in some local\virtualstore directory.
Already I found that UAC could be the problem but how can this solved ?

code of the program that don't work anymore in Vista:
        Dim oBronFile As New System.IO.FileInfo(pCDRomDriveLetter & "\Data\" & pNameDataFile & ".mdf")
            oBronFile.CopyTo(pNameDataDir & "\" & pNameDataFile & ".mdf")
            oBronFile = New System.IO.FileInfo(pCDRomDriveLetter & "\Data\" & pNameDataFile & ".ldf")
            oBronFile.CopyTo(pNameDataDir & "\" & pNameDataFile & ".ldf")
0
Comment
Question by:dekeyzer
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 6

Expert Comment

by:cottsak
ID: 20054766
copy the .mdf and .ldf files manually and attach them to the database manually. dont rely on ur app.
0
 

Author Comment

by:dekeyzer
ID: 20054780
The customers have to install it themselves by an automatic installation cd.
Als i use SQL express without user interface.
Installation of SQLexpress unattended works fine but I can't get the files there.
0
 
LVL 6

Expert Comment

by:cottsak
ID: 20054789
get hold of a VPN to the client site: this might enable you to send the data files and connect to the sql server via Management Studio
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:dekeyzer
ID: 20054821
Connect to the dataserver is not a problem: I use SQLDMO in vb.net.
But Vista don't allow to put files in C:\Program Files\ ....
About VPN : half of the customers computers don't have access to the internet so ...
and I don't think that you will get more rights over VPN than local on the pc.

0
 
LVL 6

Expert Comment

by:cottsak
ID: 20054835
dont store the data files in c:\program files
put them somewhere where vista will let you
0
 

Author Comment

by:dekeyzer
ID: 20054874
Thats maybe a possibility but where ?
I only got acces on the user maps but then can only this user work with the program ...
I tried the all users but again no access.
Is it not possible to overrule the UAC or use some manifest to make use of higer rights so you can copy the files in C:\Program Files\ ... ?
0
 
LVL 6

Expert Comment

by:cottsak
ID: 20054886
i've not done it but look up Impersonisation  - you may be able to use this to have your code execute with higher rights. also, a method can 'demand' certain rights with method attributes - that also may be an idea.
0
 
LVL 34

Accepted Solution

by:
sramesh2k earned 1500 total points
ID: 20056824
Right-click  on the program and choose "Run as administrator". Once the app runs in elevated privileges, this problem won't happen.

Or, recompile the application with a manifest file containing the "RequireAdministrator" tag. See:

Kate Gregory's Blog - Adding a manifest to a Vista application:
http://www.gregcons.com/KateBlog/CommentView.aspx?guid=682d4de9-572f-4a18-b822-19069e50410f
0
 
LVL 7

Expert Comment

by:photowhiz
ID: 20058968
Cottsak is right, C:\Program Files is a system folder, it is not for user data. This has been true since XP.

Put user data in %appData%. You can get this path in .Net from Application.UserAppDataPath.
0
 

Author Comment

by:dekeyzer
ID: 20063333
sramesh2k,

I think that your solution may but the good one but unfortunaly I don't have time in the next days but I surely will respond later.

photowhiz,

Application data is user dependent !
If I make a program to distrubute then it must be installed in the program files dir or I am wrong ?
It is a program with SQL database. SQL server already makes a subdir data (in the program files dir) to put in the datafile.
If not the program files dir then at least i need a user independent dir so all users can use the databank.

Thanks for your reply.
0
 
LVL 7

Expert Comment

by:photowhiz
ID: 20066903
Sorry, I thought you meant the data was user dependent. If it is shared among all accounts, use Application.CommonAppDataPath. All users can read/write there. Only admins can write to Program Files.
0
 

Author Comment

by:dekeyzer
ID: 20215464
Sorry for the delay but I was not in the office the last weeks.
The current situation is that the solution of sramesh2k is working with the manifest.
My original question is answerd but I have now some trouble to publish the program with visual studio run-once. See message below from microsoft :
ClickOnce / Vista / UAC - ClickOnce is designed to install applications in a secure, per user cache with the benefit being that you do not require administrative permissions to install the VS part of a Click Once deployed applications.  Click once applications do not attempt to elevate to admin privileges at runtime because they can expose the client to security elevation attacks.  It is by design. We do not have any work around for this as of now.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
I'm a big fan of Windows' offline folder caching and have used it on my laptops for over a decade.  One thing I don't like about it, however, is how difficult Microsoft has made it for the cache to be moved out of the Windows folder.  Here's how to …
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month15 days, 10 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question