This project is read-only.

Can't move program to other PC's

Sep 3, 2009 at 11:05 AM


I've created a small program utilizing the DotRas components, that creates a VPN connection, opens it and then starts a remote desktop connection. Everything works perfectly when I run it from my developer PC, but when I try moving the program to another PC it won't work (both are windows XP machines with .net 3.5 installed).

I've also tried taking the Example project CreateAndDialVpnEntry and hardcoded the vpn ip and user info into the code. But that also crashes when I move it to another PC. It crashes when the program tries to create the rasphonebook (there are no vpn connections on the pc at runtime).

Any ideas would be greatly appreciated.

Best regards

Rasmus G Palludan

Sep 3, 2009 at 1:38 PM

Well, it could be a couple things...

A) Windows security restrictions aren't allowing the application access to the path where you're trying to create the phone book.

B) The application is being transported in a way that is lessening the security context the application is running under.

If you were using the example project it should have been using the WIN2K build which should run under any operating system supported by this project. I can't narrow down exactly what the problem is unless you can get the exception information to me. Without that, I'm basically blind trying to find the problem. It sounds to me like it's a security problem, but I can't be certain.

    // Wrap all of the code in the button's event handler here.
catch (Exception ex)
    this.StatusTextBox.Text = ex.ToString();

With the example project, wrap the event handler for the button which is causing the application to crash on you. That should let you figure out which exception is causing it to break. I need the information that should get displayed in the status textbox.

Sep 8, 2009 at 12:03 PM

It was indeed a windows security issue. I logged in as admin on the 2nd PC and it ran smoothly. 

Is admin priviledges required to create the phone book? As far as I can gather it saves the phone book under /Documents and settings/<user>/Application data/Microsoft/Network/Connections/Pbk, which you should have access to when logged in as a normal user.

Thank you for the ultra fast reply. Im not at all used to getting a reply after only 2½ hours. 

Sep 8, 2009 at 2:41 PM

Glad to hear it's working again.

No administrator privileges aren't required to create a phonebook, however you do need read/write permissions on the phonebook file. A standard user or guest might require elevated privileges to allow read or write access at the all users phonebook if folder security restrictions are changed. The path of the phone book changes for each machine, that's the correct path on a Windows XP machine but incorrect on Vista. If you need to know the path of an All Users or Local User phone book, check out the static GetPhoneBookPath method on the RasPhoneBook class.

Sep 15, 2009 at 9:55 AM

I'm still having a few problems I hope you can help me with.

What I'm trying to do is make a program that's on a server. The client machines then run the program from a network drive with the purpose of making a VPN to a remote location.

The problem is that when i try it on a new client machine it cant create the rasphone.pbk file, under the logged in user. The error I get is: "The folder C:\Documents and Settings\<user>\Application Data\Microsoft\Network\Connections\Pbk is invalid". (I replaced the actual username with: <user>). I've narrowed myself to only using the logged in user phonebook, which I thought would remove the security restrictions. Can it be because we're using domain users, instead of local users? I'm really hoping to create a solution that doesn't rely on adding security rights to the users.

I'm starting to look into creating the folder manually, before I call the Phonebook.Open(true). If anyone has another good idea, I'd appreciate the help.


On another note, Ive also created a small program that creates a VPN connection and then opens a remote desktop afterwards. It works great and has really made the job of logging onto different servers alot easier. So thank you Jeff, for a great component.

Sep 15, 2009 at 2:39 PM

It's probably the fact you're trying to run an application from a network drive. I'm assuming that's why you can't access the phone books. Applications which are excecuted in that context in .NET have lesser rights than those executed when installed on a machine. You can change the .NET security permissions on each machine that needs to run it, but it would be smarter to rethink your deployment strategy.

You can test this theory by running the application from the machine directly rather than from the network drive.   Keep in mind when you copy an executable from a network drive and attempt to run it you may still run into problems with the runtime security.

Sep 21, 2009 at 11:32 AM

Some times it's the low tech solutions that works. 

I spent alot of time on security permissions and finally I thought I'd try creating the folder manually and see if that helped. It did.

string phoneDir = @"C:\Documents and Settings\" + Environment.UserName.ToString() + 
                    @"\Application Data\Microsoft\Network\Connections\Pbk";
                if (!Directory.Exists(phoneDir))

With these few lines the program ran wihtout a hitch when I was logged on with only User priviledges.


That ofc only works when it's on a XP machine. Is there any way of getting the default path for the phonebooks (current user and all users) without opening it first?


Sep 21, 2009 at 3:01 PM

There sure is. The RasPhoneBook.GetPhoneBookPath(...) static method will give you the full path including filename of a phonebook of your choice. It follows the SDK guidelines where the phonebook is located at, so it will work on any Win2k or higher machine.

I'll get that bit of code added to the RasPhoneBook class for the next release.

Sep 21, 2009 at 3:03 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.