Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Logon Script?

Posted on 2004-10-11
6
Medium Priority
?
379 Views
Last Modified: 2010-04-10
I want to write a simple .wsh logon script to map a network drive, connect a printer, set the user default folder locations (start menu, favourites etc) and also set the proxy address for internet connection through the LAN.

Can anyone help?
0
Comment
Question by:ltarrant
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 57

Expert Comment

by:Pete Long
ID: 12279315
Mapping Drives and Printers From Command

*****Drives*****

These command can be executed from either command line, Batch File OR Login Scripts

This command maps a drive "Z:\" to a shared directory on a server called "Server1"

net use z: \\server1\sharename\

If you need permissions to use this network resource toy can also enter the username and password. (See Security Below)

net use z: \\server1\sharename\ /user:username password

The above commands will work until a user logs out or the machine is rebooted, to make the mapping permanent you need to use a "Persistent switch"

net use z: \\server1\sharename\ /user:username password /Y

*****Printers*****

The Syntax is the same but this time you are mapping an "lpt" port (Line Printer Terminal) All the rules above apply so the full command is,

net use lpt1 \\machinename\sharename\ /user:username password /Y

or

RUNDLL32 PRINTUI.DLL,PrintUIEntry /dn /n\\COMPUTERNAME\PRINTERNAME      // removes printer    
RUNDLL32 PRINTUI.DLL,PrintUIEntry /in /n\\COMPUTERNAME\PRINTERNAME       // adds printer

Zero Administration Kit
http://www.microsoft.com/ntworkstation/downloads/Recommended/Featured/NTZAK.asp

How to Use Con2prt.exe to Connect to a Network Printer
http://support.microsoft.com/?kbid=181663


*****Security*****

If you do need to use  username and password, this has obvious security implications, Consider using NSIS
http://nsis.sourceforge.net/site/Download.6.0.html

For instructions on its use see http://www.experts-exchange.com/Operating_Systems/Win2000/Q_20710867.html
0
 

Author Comment

by:ltarrant
ID: 12279636
Thanks for the repsonse but we are looking at using WSH Logon Scripts rather than normal command line login scripts
0
 

Author Comment

by:ltarrant
ID: 12279721
The main problem we're looking to solve is to set the proxy address at logon in the login script!
0
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
LVL 12

Accepted Solution

by:
Mazaraat earned 750 total points
ID: 12280564
Basic logon script:

Option Explicit
on error resume next
Dim objNetwork, WshShell
Set objNetwork = CreateObject("WScript.Network")
Set WshShell = WScript.CreateObject("WScript.Shell")
objNetwork.MapNetworkDrive "q:", "\\server\sharename1"
objNetwork.MapNetworkDrive "r:", "\\server\sharename2"
objNetwork.AddWindowsPrinterConnection "\\server\printershare"

to set default printer add:
objNetwork.SetDefaultPrinter "\\server\printershare"

For assigning proxy server add something like this (no restart needed):
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\AutoConfigURL", "http://proxy";
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyOverride","<local>"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer","http://proxy";
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable",1
WshShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\Main\Start Page", "http://proxy-start-page-URL";

I would test these reg entries, I use all XP at work....

To reassign (local startup) depending on the folder it would look like this:
set sUserProfilePath = "c:\favorites"  'where_ever_you_want_it
WshShell.RegWrite "HKCU\Software\Microsoft\windows\currentversion\Explorer\user shell folders\favorites", sUserProfilePath  & "\Favorites","REG_EXPAND_SZ"

Some folders are different so it really makes a difference which ones you are trying to redirect.





0
 

Author Comment

by:ltarrant
ID: 12284930
Great! This is exactly what we were looking for! Just a couple of question about the above script. Hould would we change the drive mapping to map a location using the users usergroup and username. As on the file server users files a stored in there usergroups folder and then there individual username. I.e. \\server\<usergroup>\<username>$

We were also hoping to have a pop up msg when they logged in telling them how much there quota is for the file server and what usergroup there in.
0
 

Author Comment

by:ltarrant
ID: 12295331
I've managed to solve the 2nd part of my question anyway and as Mazaraat has already answered my original question points go to him.
0

Featured Post

Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains the fundamentals of industrial networking which ultimately is the backbone network which is providing communications for process devices like robots and other not so interesting stuff.
This month, Experts Exchange’s free Course of the Month is focused on CompTIA IT Fundamentals.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question