apologies, looked again, that was IP.... sorry, pretty late round here.
Main Topics
Browse All TopicsI need a vb script to delete a local printer port. Through Googling I've found lots of ways to delete TCP/IP Ports, but nothing about deleting a local port.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
last call....:
http://support.microsoft.c
I know it's 2k, but most of that old good stuff still works....
Ensuring that on the objPrinter.Delete_ Line you have the underscore at the end ie
objPrinter.Delete_
as apposed to
objPrinter.Delete
Also change the DeviceID to your device id and it should work
("Select * from Win32_Printer where DeviceID = 'hp 2000c'")
Replace hp 2000c as per above between the single quotes to what your device id is.
Ha, I just made it up! (I said the syntax was wrong...) Everything posted so far has had to do with IP Printers/Ports, and I was hoping it would help someone think of something I could use. The WMI index is hard to search/use... Even though it's a made up call, itt's the kind of script I need.
So is it possible to delete a local port?
Not sure I will have a look later although whilst your waiting you may be able to solve the issue using
http://www.microsoft.com/d
wmi code creator ( Am pretty sure its that ) will test it later.
If you check the win32_printer class and the other classes that wmi uses for deleting a tcp ip printer port you may find a specific one to delete a local port.
Have been playing around with it a little bit at work but have been busy - I have this friday off so I can have a better attempt on friday as I wont be at work.
For now I hope this helps and appologise for taking a while
I have no objections - although I am guessing it would be more of an API that you would require most likely to be able to just delete the port I am guessing as I had the same problem using WMI with regards to deleting the whole printer to delete the port or not at all so not sure if you would be interested in this
I appreciate everyone's help and input. I've done lots of testing here and it looks like leaving the port isn't going to cause any conflicts with the upgrade. I'm not familar with API's, but if you have an example readily available I would be interested in seeing it. Thanks again for the help, I really appreciate everyone's time!
http://www.sxlist.com/tech
and
http://winapi.freetechsecr
You will have to use EnumPorts to enumerate all the valid ports and use DeletePort ( this will only allow you to use a programming language not a scripting language to use the above ) to enumerate and then delete a selected port so you may be able to use vb 6 or something else to create an OCX file which you could then call from vbscript to do what you wanted ?
Looking around also reveals that before you delete it you will have to change the port so in essence
enumerate all valid ports
change the current port from local port that you want to delete to another port ( whether its local or not should not be an issue seeing as you just want it to select another port )
Then use Delete Port API to delete the port you want by selecting it and then if you want it to use another port you can use the change port again or you can select the correct port in the middle step
this website has a couple of examples that may lead you in the right direction
http://binaryworld.net/Mai
I do not have access to Visual Studio which is why I was trying to script it. As I said earlier, leaving the port ended up not causing a conflict in our environment. If you wanted to do it as a pet projection though that would be great and I'd be really interested in seeing it as I have no experience in making an ocx.
Thanks again,
Stephen
I have not had time to look into the ocx file but have found this on the randy birch site for visual basic
http://vbnet.mvps.org/inde
That should get you started with regards to using vb 6 or porting it into vb dot net ( vb dot net 2008 ) which you can get a free version for.
If I get time at some point I will look into doing an ocx or something along those lines as obviously need to research into it as I have not done that before
Business Accounts
Answer for Membership
by: DanCh99Posted on 2009-04-14 at 17:28:44ID: 24143876
http://www.vbsedit.com/scr ipts/print ing/ports/ scr_1164.a sp