RSS
 

VBS Scripts
by mleal

30 Mar

At my job, we are moving to all vbs scripts for our login scripts.

Here are some that map network drives:

—-begin script—-
dim wshnetwork
set wshnetwork = wscript.createobject(“wscript.network”)
ON ERROR RESUME NEXT
wshnetwork.removenetworkdrive “Z:”
netshare = “\\servername\sharename”
wshnetwork.mapnetworkdrive “Z:”,netshare
—-end script—-

Don’t forget “ON ERROR RESUME NEXT” because the script will die on any errors…like if the user doesn’t have a drive mapped called “z.”  This would prevent it actually being mapped.

Here’s another script that connects a printer and sets that printer to default.

—-begin script—-
Set objNetwork = CreateObject(“WScript.Network”)
objNetwork.AddWindowsPrinterConnection “\\printerservername\printername”
objNetwork.SetDefaultPrinter “\\printerservername\printername”
—-end script—-

Enjoy!

Mario

Related links:

 
 

Tags: , , , , ,

Leave a Reply

 
*