Script to edit "Network and Dial-up Connections" remotely

We have a Windows 2000/2003 AD domain, with roaming profiles, and a lot of group policies.  We also use a single image for every PC we setup.  So, the desktop is very standard.  Problem is, when first created, the image had about 9 entries in "Network and Dial-up Connections", as we used several different RAS servers around the world to get to the WAN.  Howerver, we now use mostly VPN to get back in, and are down to only 1 RAS server.  We only want the 1 active entry listed in there, and remove the other 8.  We have several thousand PCs out there, with the full list.  Trying to write a script to fix this, but I can't find where these settings are kept.  I've searched the Registry for the entries used, but can't find them.  I've searched the local HD, and the user folder on the server for any files containing the text.  All I found was this file: "C:\Documents and Settings\All Users\Application Data\Microsoft\Network\Connections\Pbk\rasphone.pbk"  This file has all the entries in it, in the clear, editable with Notepad.  I thought I was good-to-go.  I edited this file, and removed all the extranious entries (after backing up, of course).  File is now exactly the same name, with only one entry.  However, when I go into "Network and Dial-up Connections", it still shows the original 9 entries.  Even after reboot, it still shows all.

Any idea how to get this to use the new list?   Oh BTW, if a user tries to delete any entries manually, they get an error: "The connection you selected cannot be deleted".
3dNOVAAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mcsweenSr. Network AdministratorCommented:
Can an Administrator delete these connections manually?
3dNOVAAuthor Commented:
Yes, a domain admin, that is in the local Admin group as well can delete.  But, a regular domain user, that is in the local Admin group cannot.
3dNOVAAuthor Commented:
OK, I'm upping this to 500 points.  But, I really need a complete answer that gets the script built.  Or the GP changed, if it ends up being there.
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

3dNOVAAuthor Commented:
I have discovered that the file I was looking at before, "C:\Documents and Settings\All Users\Application Data\Microsoft\Network\Connections\Pbk\rasphone.pbk", is the file that needs changed to make this work.  However, just changing or replacing it does not update the entries you see.  Rebooting doesn't even do it.  So far, the only way I can make it work is to open up
"Network and Dial-up Connections" and hit F5.  This immedietely makes it reread that file, and everything looks great.  Now I have 2 problems writing a script for this (VBS).  I don't know how to make "Network and Dial-up Connections" refresh from a script, after replacing the file.  And, I can't get the VBS commands to recognize the long filename path.  Any suggestions?

If I don't get a response, I will end this question, and rewrite it over in the VB area.
mcsweenSr. Network AdministratorCommented:
For the long path issue you can either put it in triple quotes

"""C:\Documents and Settings\All Users\Application Data\Microsoft\Network\Connections\Pbk\rasphone.pbk"""

or you can use the short path

C:\Docume~1\AllUse~1\Applic~1\Micros~1\networ~1\connec~1\raspho~1.pbk

I will look into the VB refresh on the network properties page for you
3dNOVAAuthor Commented:
I have tried the triple quotes thing, it doesn't work.  Here's the pertinent part of my script:

On Error Resume Next
Set wshshell = WScript.CreateObject("wscript.shell")
Set fs = CreateObject ("Scripting.FileSystemObject")

Set FileInfo = fs.GetFile("""C:\Documents And Settings\All Users\Application Data\Microsoft\Network\Connections\rasphone.pbk""")
WScript.Echo "Size = " & FileInfo.Size

This works perfectly well with ...("c:\temp\rasphone.pbk") as a test.  As soon as I put in the long path, with single quotes, double, triple, quad, chr(34), anything I've tried, not only does it not print the filesize, it won't even echo the "Size = " part anymore.
mcsweenSr. Network AdministratorCommented:
C:\Documents And Settings\All Users\Application Data\Microsoft\Network\Connections\rasphone.pbk

This is the wrong path...correct path is

C:\Documents and Settings\All Users\Application Data\Microsoft\Network\Connections\Pbk\rasphone.pbk
mcsweenSr. Network AdministratorCommented:
This code works...I just tested it

Set fs = CreateObject ("Scripting.FileSystemObject")

Set FileInfo = fs.GetFile _
("C:\Documents And Settings\All Users\Application Data\Microsoft\Network\Connections\pbk\rasphone.pbk")
WScript.Echo "Size = " & FileInfo.Size
3dNOVAAuthor Commented:
Doh!  You're right!    Path was just wrong.   You know, you look at someting a hundred times....

Yes, works fine now.  Not only that, but it also works the way I really wanted it to work:

LocPath = "C:\Documents And Settings\All Users\Application Data\Microsoft\Network\Connections\pbk\rasphone.pbk"
Set FileInfo = fs.GetFile(LocPath)
If FileInfo.Size > 0 Then
    WScript.Echo "Size is " & FileInfo.Size      
End If

So, all I need now is a way to get the setting to refresh.
3dNOVAAuthor Commented:
If nobody can find out a way to refresh the network properties in the script, then I will have to close out this call.  I suppose I will have to recreate it over in the VB scripting area.  I hate to close it, when we're so close to an answer.
mcsweenSr. Network AdministratorCommented:
Post in the community support forum asking to have the question moved to the VB forum.
ddepastinoCommented:
I guess RasPhone.....

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows 2000

From novice to tech pro — start learning today.