How do I crerate a batch file that creates a printer port then a shared printer?

I need to create a batch file that creates a printer port of C:\WINNT\TEMP\999.prn (prints to a local file).  Then I need to created a shared printer in the batch after the port is created.  Here is what I currently have, this will create the printer to LPT1, but won't share it.  So it needs to be edited to do as I described above.

REM Run inf install:
rundll32 printui.dll,PrintUIEntry /if /b "9999" /f %windir%\inf\ntprint.inf /r "lpt1:" /m "Generic / Text Only"
Who is Participating?
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.

do you  have an Active Directory network? If so there should be a setting in group policy to publish all printers in Active Directory. As long as all users are able to 'run' that policy, all printers added to the computer should be shared.
Max10137Author Commented:
no active directory.
Hi Max10137,

no AD needed. Just use following command line(s) in your batch:

rundll32 printui.dll,PrintUIEntry /Xs /n "Your PrinterName" sharename "YourShare" attributes +Shared
'Your PrinterName' is the name as displayed in Start - Settings - Faxes and Printers (in your case it's "9999" I think),
'YourShare' is the name of the new share on this computer

unsharing it again:
rundll32 printui.dll,PrintUIEntry /Xs /n "Your PrinterName" attributes -Shared

if you like renaming the printer's name:
rundll32 printui.dll,PrintUIEntry /Xs /n "old printer name" printername "new printer name"

Mind you'll have to look at security, who's able to print on/manage this printer via remote.

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

From novice to tech pro — start learning today.