Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 198
  • Last Modified:

HELP! VisualBasic Logon Scripts (Mapping and Printers)

I am a system Admin for a small school, we have about 120 computers in total all running WindowsXP and all connected to a Windows2000 Server.  Previously I have written Logon scripts for connecting printers and mapping network drives as batch files but because of the need to disable students from accessing the command prompt this is now no longer possible.  I have no problem with mapping network resources but am in need of help when it comes to connecting to network printers (running of printservers and shared on computers) depending on the location.  Is there any way that this can be done in the policy?  I have very little knowledge of using VB scripts.
0
CliftonAdmin
Asked:
CliftonAdmin
  • 2
2 Solutions
 
bonzaiCommented:
Hi

with this little vbscript, you can connect to printers


'-------------printers.vbs---------------
dim oNet, sPrintPath
Set oNet = CreateObject("WScript.Network")
sPrintPath = "\\server\printer"
oNet.AddWindowsPrinterConnection sPrintPath
oNet.SetDefaultPrinter sPrintPath
'----------------------------------------

greets
bonzai
0
 
CliftonAdminAuthor Commented:
That is sort of what I need but I need some kind of "if" statment. i.e if computer name = \\PrimLab then connect to \\Printserver\PrimPrinter.  Location Dependant connections.
0
 
bonzaiCommented:
this should work for you...


'----------------------------------------------
dim oNet, sPrintPath
Set oNet = CreateObject("WScript.Network")

Select Case oNet.ComputerName
  Case "computer1"
      sPrintPath = "\\server\printer1"
  Case "computer2"
      sPrintPath = "\\server\printer2"
   Case Else
      sPrintPath = "\\server\printer3"
End Select

oNet.AddWindowsPrinterConnection sPrintPath
oNet.SetDefaultPrinter sPrintPath
'----------------------------------------------
0
 
cempashaCommented:
This question is still open and getting old. If any of the comment(s) above helped you please accept it as an answer or split the points who ever helped you in this question. Your attention in finalising this question is very much appreciated. Thanks in advance,

****** PLEASE DO NOT ACCEPT THIS AS AN ANSWER ********

- If you would like to close this question and have your points refunded, please post a question in community support area on http://www.experts-exchange.com/Community_Support/ giving the address of this question. Thank you      

Pasha

Cleanup Volunteer


0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now