bat file

Posted on 2011-10-28
Last Modified: 2012-05-12
i have window 2008 with AD.
I would like to create a .bat file for users.

How can i do the best way and how?
Question by:orkinos
    LVL 3

    Expert Comment

    What do you want to do with the BAT file?

    Author Comment

    network drive E:  and BGinfo.cmd deploy for all users
    LVL 14

    Expert Comment

    by:Rob Miners
    orkinos, there are far newer alternatives like VB Scripts cmpared to using batch files to add users and grant permissions but I will give you an example of what I used to use:

    I always create a Folder on D:\  to put the Users Home Directories, Profiles and ClientApps. I like to keep the Profiles folder seperate from the Home Directory as it is a lot easier to manage. I normally have the Profiles Folder with a hidden Share EG: Profiles$. You could run XCACLs and give the Administrator and Users Full control of their Profiles Folder.

    Adding Single or Bulk Users
    save the file to the root directory of the Server.
    Create a Batch file and name it MKUser.bat
    Copy and Paste between ======== to the new file modifying the contents to reflect your setup.

    @echo on
    net user %1 %2 /add /fullname:"%3 %4" /comment:"User" /homedir:%LOGONSERVER%\%1$ /profilepath:%LOGONSERVER%\Profiles$\%1 /scriptpath:Logon.bat

    net group "Staff" %1 /add /Domain

    md %LOGONSERVER%\profiles$\%1

    echo y| xcacls %LOGONSERVER%\profiles$\%1 /T /G "Administrators":F %1:F

    md D:\minero\users\%1

    echo y| xcacls D:\minero\users\%1 /T /G "Administrators":F %1:F

    net share %1$=D:\minero\users\%1 /y


    %1 = username
    %2 = password
    %3 = Firstname
    %4 = Lastname
    %1$ = Hides the folder. Creates a Hidden Share

    To add Multiple Users another Batch file can be created that Calls  the MKUser.bat

    Example: AddUser.bat
    Call c:\MKUser.cmd Jack password Jack Jones
    Call c:\MKUser.cmd Jill password Jill Jones

    Author Comment

    thank for script but its very difficult for me now.i just want to learn basic how to.
    LVL 14

    Expert Comment

    by:Rob Miners
    Thats cool, we all had to start at the beginning but its always best to use a test environment and not a live system to do your testing.
    LVL 22

    Accepted Solution

    use notepad and make a file called logon.bat

    put the logon.bat and bginfo files in your netlogon share location.  normally like:  c:\windows\sysvol\domain\domain\scripts

    in the AD users account set the logon script setting to:  logon.bat

    for a basic file, in the logon.bat file put

    net use E: \\yourserver\sharename
    \\yourserver\netlogon\bginfo.exe \\yourserver\netlogon\bginfo.bgi /timer:0 /silent
    LVL 77

    Assisted Solution

    by:David Johnson, CD, MVP

    net use e: \\servername\sharename
    if NOT EXIST "c:\programdata\microsoft\windows\start menu\Programs\startup" xcopy e:\bginfo.cmd "c:\programdata\microsoft\windows\start menu\Programs\startup\"

    --- start
    \\servername\sharename\bginfo.exe /options
    -- end

    LVL 12

    Assisted Solution

    You seem like you might need to look into the basics first.

    You can learn the simple commands by starting here

    There is a simple demonstration of writing batch files in this tutorial

    I hope this helps
    LVL 12

    Expert Comment

    Check out the links I posted above.  You will get a really nice explanation and understanding of batch files.  
    LVL 59

    Expert Comment

    This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    I had a question today where the user wanted to know how to delete an SSL Certificate, so I thought that I would quickly add this How to! Article for your reference. WHY WOULD YOU WANT TO DELETE A CERTIFICATE? 1. If an incorrect certificate was …
    Article by: Lee
    Windows 7 Ultimate and Enterprise (and 2008 R2) introduced a new feature you may not be aware of - Boot from VHD.   Boot from VHD (or what Microsoft refers to asNative Boot allows you to install Windows to a VHD (Virtual Hard Disk) file that is t…
    This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
    The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

    759 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

    10 Experts available now in Live!

    Get 1:1 Help Now