{"id":393,"date":"2010-08-04T14:24:51","date_gmt":"2010-08-04T13:24:51","guid":{"rendered":"http:\/\/www.edwardsd.co.uk\/work\/?p=393"},"modified":"2011-01-29T14:05:10","modified_gmt":"2011-01-29T14:05:10","slug":"add-network-printer-via-vbs","status":"publish","type":"post","link":"https:\/\/www.edwardsd.co.uk\/work\/2010\/08\/add-network-printer-via-vbs\/","title":{"rendered":"Add Network Printer via VBS"},"content":{"rendered":"<p>Use the script below to add a network printer, you can simply dump this into a txt file, rename to a .VBS and change the printer addresses (these need to be shared of course!)<br \/>\nThe last bit of code should stop the &#8220;Error:\u00a08007007B &#8211;\u00a0the filename, directory name, or volume label syntax is incorrect&#8221; as it will keep retrying the connection to the printer share if the network is slow and timming out etc.<\/p>\n<p>Last bit is to drop the script into the DC netlogon and add to group policy! BAMM!<\/p>\n<p><code><\/p>\n<hr \/>\n<p>Dim net<br \/>\nSet net = CreateObject(\"WScript.Network\")<br \/>\nnet.AddWindowsPrinterConnection \"\\\\server\\printer\"<br \/>\nnet.SetDefaultPrinter \"\\\\server\\printer\"<\/p>\n<p>MapPrinter \"\\\\server\\printer\"<\/p>\n<p>Sub MapPrinter(strPrinter)<br \/>\nOn Error Resume Next<br \/>\nSet objNetwork = CreateObject(\"WScript.Network\")<br \/>\nboolConnected = False<br \/>\nintAttempts = 1<br \/>\nWhile boolConnected = False And intAttempts &lt;= 5<br \/>\nErr.Clear<br \/>\nobjNetwork.AddWindowsPrinterConnection strPrinter<br \/>\nIf Err.Number &lt;&gt; 0 Then<br \/>\nintAttempts = intAttempts + 1<br \/>\nWScript.Sleep 2000<br \/>\nElse<br \/>\nboolConnected = True<br \/>\nEnd If<br \/>\nWend<br \/>\nEnd Sub<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Use the script below to add a network printer, you can simply dump this into a txt file, rename to a .VBS and change the printer addresses (these need to be shared of course!) The last bit of code should stop the &#8220;Error:\u00a08007007B &#8211;\u00a0the filename, directory name, or volume label syntax is incorrect&#8221; as it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[8,18,23],"tags":[],"class_list":["post-393","post","type-post","status-publish","format-standard","hentry","category-vbs","category-windows-server-2003","category-windows-server-2008"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pOPt8-6l","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.edwardsd.co.uk\/work\/wp-json\/wp\/v2\/posts\/393","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.edwardsd.co.uk\/work\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.edwardsd.co.uk\/work\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.edwardsd.co.uk\/work\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.edwardsd.co.uk\/work\/wp-json\/wp\/v2\/comments?post=393"}],"version-history":[{"count":0,"href":"https:\/\/www.edwardsd.co.uk\/work\/wp-json\/wp\/v2\/posts\/393\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.edwardsd.co.uk\/work\/wp-json\/wp\/v2\/media?parent=393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.edwardsd.co.uk\/work\/wp-json\/wp\/v2\/categories?post=393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.edwardsd.co.uk\/work\/wp-json\/wp\/v2\/tags?post=393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}