Login script on Window 7

Posted on 2012-09-11
Last Modified: 2012-09-12
There is a  Window 7 (in workgroup) that need to access our file services and network printer.
Is it possible to write login script on the desktop that will ask for user authentication and then mount the file server and printer ? For some reason, this Window 7 will not join the window domain.

Question by:AXISHK
    LVL 12

    Accepted Solution

    Here is one I use for mapping drives:
    ' Script Name:	MapDrives.vbs
    '      Author:	Seaton007
    '     Created:	September 2012
    ' Description:	Asks the user for their domain credentials and then maps
    '				a network drive.
    ' Set the domain name
    Const conDomain = "DOMAIN_NAME"
    ' Get the user name and password
    strDomainUser = InputBox("Please enter your user name:" & vbCrLf & vbCrLf & "Example: JSmith", "User Name")
    	If VarType(strDomainUser) = 0 Then WScript.Quit	' If the "Cancel" button is pressed then quit
    strPassword = InputBox("Please enter your password:" & vbCrLf & vbCrLf & "NOTE: Your password will be visible below, so please make sure nobody is watching as you type it.", "Password")
    	If VarType(strPassword) = 0 Then WScript.Quit	' If the "Cancel" button is pressed then quit
    ' Map new network drives
    strUser = conDomain & "\" & strDomainUser
    Set objNetwork = CreateObject("WScript.Network")
    	objNetwork.MapNetworkDrive "DRIVE_LETTER:", "\\SERVER_NAME\SHARE_NAME", True, strUser, strPassword
    MsgBox "Finished mapping drives.", vbOKOnly+vbInformation+VbMsgBoxSetForeground, "Finished"

    Open in new window

    There is a built-in script in Windows 7 that you can use to manage printers.  You should be able to call it from within the above script to add the printer(s).  Here is the information on how to use it: Prnmngr.vbs
    LVL 21

    Expert Comment

    by:Joseph Moody
    I think the best solution will be to figure out why it won't join the domain. What error are you getting?

    Author Comment

    This is a senior management's laptop but only occaonially need to access to company network. He refuses his personal laptop to join the domain.
    LVL 21

    Assisted Solution

    by:Joseph Moody
    Sucks... any particular reason? I know we had a lot like that that were XP. Offline files never worked that great.

    Windows 7 is a completely different story though.

    But if you still can't do it, I would place a script (like those mentioned above) and place them in the Common Startup folder for the computer.

    c:\Programdata\Microsoft\Windows\Start Menu\Programs\StartUp

    Author Closing Comment

    LVL 12

    Expert Comment

    You probably already figured this out, but I forgot to mention... in the above script code, just replace DOMAIN_NAME with your domain name, replace DRIVE_LETTER with the drive letter you want to map, and replace \\SERVER_NAME\SHARE_NAME with the path you want to map it to.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Wish Marketing would stop bothering you?

    Is your marketing department constantly asking for new email signature updates? Are they requesting a different design for every department? Do they need yet another banner added? Don’t let it get you down! There is an easy way to manage all of these requests...

    With the higher take up rate of SAN’s, virtualisation etc, windows devices with more than one network interface are becoming more common.  As a general rule when a service that is installed on a Windows operating system is running, it only listens o…
    Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
    This tutorial will show how to push an installation of Backup Exec to an additional server in both 2012 and 2014 versions of the software. Click on the Backup Exec button in the upper left corner. From here, select Installation and Licensing, then I…
    This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

    737 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

    20 Experts available now in Live!

    Get 1:1 Help Now