Solved

Logon Script?

Posted on 2004-10-11
6
372 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Join & Write a Comment

Article by: IanTh
Hi Guys After a whole weekend getting wake on lan over the internet working, I thought I would share the experience. Your firewall has to have a port forward for port 9 udp to your local broadcast x.x.x.255 but if that doesnt work, do it to a …
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 …
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

706 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

12 Experts available now in Live!

Get 1:1 Help Now