Announcement

Collapse
No announcement yet.

Creating HomeDir in LogON.

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating HomeDir in LogON.

    Hi all,
    I have IDM system, that not create users HomeDirs.
    I want do this in first user login.
    I need a script / batch or something else, that can create folder in network share and will use for this action domain admin rights.

    I have a litle script that work, but only if you have permitions on network share:

    @echo off
    if not exist "\\server\homedirs\%username%" (
    echo creating home directory...
    mkdir "\\server\homedirs\%username%"
    xcacls "\\server\homedirs\%username%" /G domain\%username%:M
    ) ELSE (
    echo home directory exists
    )

    Help please!

  • #2
    Re: Creating HomeDir in LogON.

    my script use the psexec tool
    http://technet.microsoft.com/en-us/s.../bb897553.aspx

    and try this script

    Set objfso = CreateObject("Scripting.FileSystemObject")
    Set objShell = WScript.CreateObject("WScript.Shell")
    Set objNetwork = WScript.CreateObject("WScript.Network")
    If objfso.FolderExists("\\server\share") Then
    WScript.Echo "folder exist"
    Else
    strComputer = objNetwork.ComputerName
    strAdminUser = "YourDomainAdminAccount"
    strAdminPass = "YourDomainPassword"

    strCommand = "cmd /c \\server\scripts\psexec.exe \\" & strComputer & " -u " & strAdminUser & " -p " & strAdminPass & " mkdir dirname"
    objShell.Run strCommand, 0, True
    End If
    Any advice is given in good faith and without warranty.
    Please give reputation points where appropriate.

    Comment


    • #3
      Re: Creating HomeDir in LogON.

      Code:
      @echo off
      Echo.---------------------------------------------------
      Echo.----------Logon Script-----------------------------
      Echo.---------------------------------------------------
      Echo.This Script maps all networkdrives.
      
      ::Maping user drive
      Set "Target=\\servername\Home$\%username%"
      If Not Exist "%Target%",(
         MKDIR "%Target%"
          Cacls "%Target%" /E /R "Users"
           Cacls "%Target%" /E /R "Administrators"
            Net use U: "%Target%") Else (
           Net use U: "%Target%"
           )
          )
         )
      ::Maping Department drive
      Net use K: \\servername\Department$\Engineering
      
      Echo.Drives are mapped, enjoy your stay.
      
      Echo.&Pause >Nul
      Sample batch
      [Powershell]
      Start-DayDream
      Set-Location Malibu Beach
      Get-Drink
      Lay-Back
      Start-Sleep
      ....
      Wake-Up!
      Resume-Service
      Write-Warning
      [/Powershell]

      BLOG: Therealshrimp.blogspot.com

      Comment

      Working...
      X