Solved

Logon Script?

Posted on 2004-10-11
6
373 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
  • 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
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…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now