?
Solved

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

Posted on 2006-04-06
12
Medium Priority
?
201 Views
Last Modified: 2007-12-19
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".
0
Comment
Question by:3dNOVA
  • 6
  • 5
12 Comments
 
LVL 22

Expert Comment

by:mcsween
ID: 16400823
Can an Administrator delete these connections manually?
0
 

Author Comment

by:3dNOVA
ID: 16401856
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
 

Author Comment

by:3dNOVA
ID: 16426043
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
Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

 

Author Comment

by:3dNOVA
ID: 16496904
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
 
LVL 22

Expert Comment

by:mcsween
ID: 16497676
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
 

Author Comment

by:3dNOVA
ID: 16497899
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
 
LVL 22

Assisted Solution

by:mcsween
mcsween earned 300 total points
ID: 16497931
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
 
LVL 22

Expert Comment

by:mcsween
ID: 16497965
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
 

Author Comment

by:3dNOVA
ID: 16499283
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
 

Author Comment

by:3dNOVA
ID: 16556200
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
 
LVL 22

Expert Comment

by:mcsween
ID: 16556480
Post in the community support forum asking to have the question moved to the VB forum.
0
 
LVL 3

Accepted Solution

by:
ddepastino earned 1200 total points
ID: 16580375
I guess RasPhone.....
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Tech giants such as Amazon and Google have sold Alexa and Echo to such an extent that they have become household names. And soon they are expected to be used by commoners in their homes, ordering takeout, picking out a song, answering trivia questio…
Integration Management Part 2
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

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