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?
 
ddepastinoCommented:
I guess RasPhone.....
0
 
mcsweenSr. Network AdministratorCommented:
Can an Administrator delete these connections manually?
0
 
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.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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.
0
 
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.
0
 
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
0
 
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.
0
 
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
0
 
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
0
 
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.
0
 
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.
0
 
mcsweenSr. Network AdministratorCommented:
Post in the community support forum asking to have the question moved to the VB forum.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.