Solved

Logon Script?

Posted on 2004-10-11
6
377 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
Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

 
LVL 12

Accepted Solution

by:
Mazaraat earned 250 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

Percona Monitoring and Management and Grafana

Proactive monitoring is vital to a highly-available environment. We have a quick start guide on Experts Exchange for Grafana users.

Question has a verified solution.

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

When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
Make the most of your online learning experience.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses
Course of the Month11 days, 6 hours left to enroll

623 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