Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Logon Script?

Posted on 2004-10-11
6
Medium Priority
?
383 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Most of the applications these days are on Cloud. Cloud is ubiquitous with many service providers in the market. Since it has many benefits such as cost reduction, software updates, remote access, disaster recovery and much more.
This article is a collection of issues that people face from time to time and possible solutions to those issues. I hope you enjoy reading it.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

824 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