Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need a "super" logon script

Status
Not open for further replies.

brokenhalo

IS-IT--Management
Feb 24, 2008
169
US
Hello all,

This might be a big request, but I need a super logon vbscript. I am able to get portions of different scripts to run, but I cannot get them all in a single script. Here is what I need to accomplish... (FYI: These are Windows XP Pro domain-joined PC's. Windows Server 2008 R2, with a 2008 domain functional level)

1) Delete all items from the C:\Windows\Profiles\All Users\Desktop and repopulate with items from a shared folder on our server.
2) Map several network drives, one of which uses a %username% variable.
3) Map several network printers. The users are not members of the Power Users local group, so by default they cannot add printers. Not sure if this will be an issue (It has already caused me issues). I am not opposed to adding them to the Power Users group, so if we can add a domain group to the local Power Users group first as a portion of this script (probably step #2), then lets do that.
4) Set a default printer (this has also caused me issues for regular users)

Any help is greatly appreciated!

Brad L.
Systems Engineer
Prestige Technologies
bradlaszlo[at]prestigetech.com

"Some things Man was never meant to know. For everything else, there's Google.
 
good old DOS commands

logon.vbs
Code:
set objFSO = Wscript.CreateObject("Scripting.FileSystemObject")
set objNetwork = Wscript.CreateObject("WScript.Network")
set objShell = WScript.CreateObject("Wscript.Shell")

'1) Delete desktop items
objShell.Run "%COMSPEC% /c del /s /q ""c:\windows\profiles\all users\desktop\*.*""", 0, true
objShell.Run "net use x: ""\\server\share""", 0, true
objShell.Run "xcopy x: ""C:\windows\profiles\all users\desktop"" /e /q"

'2) Map several network drives, one of which uses a %username% variable.
objShell.Run "net use s: ""\\server\share"""
objShell.Run "net use u: ""\\homedrives\" & objShell.ExpandEnvironmentStrings("%username%") & """"

'3) Map several network printers.
objNetwork.AddWindowsPrinterConnection "\\server\printer1"
objNetwork.AddWindowsPrinterConnection "\\server\printer2"
objNetwork.AddWindowsPrinterConnection "\\server\printer3"

'4) Set a default printer
objNetwork.SetDefaultPrinter "\\server\printer1"

-Geates

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
- Martin Golding

"There are seldom good technological solutions to behavioral problems."
- Ed Crowley, Exchange guru and technology curmudgeon
 
Thanks Geates for the fast response! The first portion of the script looks as if it might be exactly what I need.

The last portion, however (Adding network printers and setting the default) is the exact same as what I currently have, and only works properly when logged in as administrator.

When a standard user logs in, sometimes it will map the printers, but it will not set the default properly. Any suggestions there? Perhaps PrintUI.dll or Con2Prt.exe? I would like to avoid those if possible. Thanks in advance.

Brad L.
Systems Engineer
Prestige Technologies
bradlaszlo[at]prestigetech.com

"Some things Man was never meant to know. For everything else, there's Google.
 
It will just be easier to add the Users group to the Power Users group.

-Geates

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
- Martin Golding

"There are seldom good technological solutions to behavioral problems."
- Ed Crowley, Exchange guru and technology curmudgeon
 
It would be easier that way, if I only had a few machines. Unfortunately, I have just over 1,000 machines that need this exact config. I have a script that will accomplish this, but might be hard to add to the script above. I will see what I can get accomplished with this tonight and post back tomorrow. Thanks for the feedback!!!

Brad L.
Systems Engineer
Prestige Technologies
bradlaszlo[at]prestigetech.com

"Some things Man was never meant to know. For everything else, there's Google.
 
Incoporating code to provide the user with enough rights is futile. A) The user won't have the rights to execute the code and B) even if the code did execute fully, the effect wouldn't apply until next logon.

Well, that's not entirely true. Point A could be accomplished using impersonation, a nifty identity modifier that eliminates the need to check user permissions on trusted resources (domain memberships are trusted). However, point B would still apply.

Perhaps you could use a a GPO, Group Policy Object, as they are executed before the user's AD logon script (which I assume what this is for).

-Geates

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
- Martin Golding

"There are seldom good technological solutions to behavioral problems."
- Ed Crowley, Exchange guru and technology curmudgeon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top