We have an app that uses a sqlexpress db. We need our customers to be able to swap the database for this app out for another sqlexpress db fairly easily. So we came up with a small launcher app that allows them to choose the db they want from a drop down list. It then detaches the current db and attaches the db that they chose and launches the program.
I tried to automate the set up of the multiple databases. Our process is to install the initial db and then detach and rename the .mdf and .ldf files. We then run our software and it gets a fresh copy of the db. So I added a new db button that when clicked does exactly that. In windows xp this works without problem. However in windows vista and 7 I get an exception that folder access is denied for renaming the .ldf file. The .mdf file renames without issue. I tried manually renaming the two files to see if it was a permissions issue with the DATA folder in sqlserver. With this test I found that I can simply right click and rename the .mdf file, but the .ldf causes the UAC prompt to come up so that I can grant it permission to be renamed.
I'm assuming that the UAC prompt is my problem but when I try to rename the file programmatically I do not get the prompt, just an exception.
What is the best way to deal with the UAC?