Announcement

Collapse
No announcement yet.

How can I put a text file in local user profiles at login?

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

  • How can I put a text file in local user profiles at login?

    HI,

    I haven't posted for a while, so please forgive me if I get anything wrong

    I have a text file I'd like to put in a group of users local profiles on Win XP Pro clients. The login script reads in part:

    "if exist z:\ net use z: /d
    net use z: "%LOGONSERVER%\NETLOGON"

    z:\ifmember SSCA_Students
    if errorlevel 1 goto ssca_student_map

    rem --------------------------------------------------------------
    :ssca_student_map
    net use /persistent:no
    if exist h:\ net use h: /d
    set USERDIR=\\sscacur01\studentusers$\%username%
    if exist "%USERDIR%" net use h: "%USERDIR%"
    if exist n:\ net use n: /d
    net use n: \\sscacur01\StudentCommon$"

    My question is, how can I add a line that will allow users in a group to have the text file placed in the "C:\Documents and Settings\<username>" file so that a piece of software will run?


    Thanks in advance, any help is greatly appreciated

  • #2
    Re: How can I put a text file in local user profiles at login?

    Is it a pre-existing text file that needs to be copied from a central location, or do you only need to generate an empty or populated text file on the fly in the location you specified?

    I assume the text file will be needed if the user is a member of the group SSCA_Students ?
    VCDX3 #34, VCDX4, VCDX5, VCAP4-DCA #14, VCAP4-DCD #35, VCAP5-DCD, VCPx4, vEXPERTx4, MCSEx3, MCSAx2, MCP, CCAx2, A+
    boche.net - VMware Virtualization Evangelist
    My advice has no warranties. Follow at your own risk.

    Comment


    • #3
      Re: How can I put a text file in local user profiles at login?

      HI, Thanks for replying. Yes I'd like to have a pre-existing text file copied from a central location. I can put it anywhere on a network share. I was going to make users a member of another group as well as SSCA_Students. They'll actually be members of "SSCA_Yr12_IPT". This is a smaller group of students needing access to an application.

      Thanks

      Comment


      • #4
        Re: How can I put a text file in local user profiles at login?

        Originally posted by VillaGorilla View Post
        "if exist z:\ net use z: /d
        net use z: "%LOGONSERVER%\NETLOGON"

        z:\ifmember SSCA_Students
        if errorlevel 1 goto ssca_student_map

        rem --------------------------------------------------------------
        :ssca_student_map
        net use /persistent:no
        if exist h:\ net use h: /d
        set USERDIR=\\sscacur01\studentusers$\%username%
        if exist "%USERDIR%" net use h: "%USERDIR%"
        if exist n:\ net use n: /d
        net use n: \\sscacur01\StudentCommon$"

        My question is, how can I add a line that will allow users in a group to have the text file placed in the "C:\Documents and Settings\<username>" file so that a piece of software will run?


        Thanks in advance, any help is greatly appreciated
        So you've already got the logic and 98% of the functional script. The way I'm seeing this, all you need is a line in the :ssca_student_map branch of the script to copy the .txt file from the centralized network location to the user's C: drive during logon.


        z:\ifmember SSCA_Students
        if errorlevel 1 goto ssca_student_map

        rem --------------------------------------------------------------
        :ssca_student_map
        net use /persistent:no
        if exist h:\ net use h: /d
        set USERDIR=\\sscacur01\studentusers$\%username%
        if exist "%USERDIR%" net use h: "%USERDIR%"
        if exist n:\ net use n: /d
        net use n: \\sscacur01\StudentCommon$"
        if exist n:\pathtofile\filename.txt copy n:\pathtofile\filename.txt "C:\Documents and Settings\"%username%\
        VCDX3 #34, VCDX4, VCDX5, VCAP4-DCA #14, VCAP4-DCD #35, VCAP5-DCD, VCPx4, vEXPERTx4, MCSEx3, MCSAx2, MCP, CCAx2, A+
        boche.net - VMware Virtualization Evangelist
        My advice has no warranties. Follow at your own risk.

        Comment


        • #5
          Re: How can I put a text file in local user profiles at login?

          In this example XCOPY.exe is used with the /D /y switches to copy the file.
          With the /D switch - only newer files are being copied,
          with the /y switch - the existing file will be overwritten without asking for a confirmation.
          Code:
          @echo off
          
          :Main1
          Start /Wait /B NET.exe USE * /delete /yes
          
          SET MemberOf=SSCA_Students
           net User %username% /domain | find /i "%MemberOf%" >nul
           :: set MemberOf=N&&If Not errorlevel 1 set MemberOf=Y
           set MemberOf=Y&&If errorlevel 1 Set MemberOf=N
          
          IF /i %MemberOf%==Y, GoTo StudentMappings
          IF /i %MemberOf%==N, GoTo TeacherMappings
          
          :Main2
          rem continue 2nd part of the logonscript...
          
          :End
          
          
          REM ***** sub routines *****
          echo on
          @Exit
          ::_ _ _ _ _ _ _ _ _ *
           :StudentMappings
          net use h: "\\sscacur01\studentUsers$\%username%" /persistent:no
          net use n: "\\sscacur01\StudentCommon$" /persistent:no
          SET MemberOf=SSCA_Yr12_IPT
           net User %username% /domain | find /i "%MemberOf%" >nul
          If Not errorlevel 1 XCOPY.exe /D /y "\\server\share\file.txt" "%USERPROFILE%"
          GoTo Main2
          ::_ _ _ _ _ _ _ _ _ *
           :TeacherMappings
          net use h: "\\sscacur01\teacherUsers$\%username%" /persistent:no
          net use n: "\\sscacur01\teacherCommon$" /persistent:no
          net use z: "%LOGONSERVER%\NETLOGON" /persistent:no
          GoTo Main2
          ::_ _ _ _ _ _ _ _ _ *
          \Rems


          EDIT - nb. In this example I did not use a utility like IfMember.exe OR MemberOf.exe, but instead I used a combination of Net User currentuser <- with a search for the specified group if it is in the list. I don't know the pros and cons of each method, I just used this one here as an example.
          But note that the method in this example has a reversed errorlevel:
          where 1 = Not_Found_the_ADGroup_in the_user's_list

          extra note - You cannot check if the user might be a member of a nested group in the specified ADGroup!
          Last edited by Rems; 18th April 2007, 21:47.

          This posting is provided "AS IS" with no warranties, and confers no rights.

          __________________

          ** Remember to give credit where credit's due **
          and leave Reputation Points for meaningful posts

          Comment


          • #6
            Re: How can I put a text file in local user profiles at login?

            HI Guys,

            Thanks for the advice, I have a couple of bigger issues here at present but will try to look at this today.
            Could I use the following line to denote which clients to install on? In the following line the printer maps according to the computer name:
            if /i "%COMPUTERNAME:~0,8%" == "SSCA_318" z:\con2prt /cd \\sscacur01\ssca_prn_318new

            so is it possible to copy the text file only to PC's with SSCA_318 in the name?

            Thanks in advance, (again)

            Comment


            • #7
              Re: How can I put a text file in local user profiles at login?

              Code:
              :: "Conditional printermapping"
              echo %computername% | find/i "SSCA_318" &&^
              z:\con2prt /cd \\sscacur01\ssca_prn_318new
              :: "Done printermapping"
              OR...
              Code:
              @echo off
              
              echo %computername% | find/i "SSCA_318" &&SET $result=Y||SET $result=N
              IF /i %$result%==Y z:\con2prt /cd \\sscacur01\ssca_prn_318new
              IF /i %$result%==Y XCOPY.exe /D /y "\\server\share\file.txt" "%USERPROFILE%"
              \Rems
              Last edited by Rems; 19th April 2007, 10:38.

              This posting is provided "AS IS" with no warranties, and confers no rights.

              __________________

              ** Remember to give credit where credit's due **
              and leave Reputation Points for meaningful posts

              Comment


              • #8
                Re: How can I put a text file in local user profiles at login?

                Thanks Rems,

                I'm testing that now. Will let you know how it goes. Its the end of the week, so I may not get back to you till Monday morning at this stage.

                Regards.

                Comment


                • #9
                  Re: How can I put a text file in local user profiles at login?

                  Rems,

                  Thanks so much for that! I really appreciate it! I used your 2nd block of code in the login script, tested it with two users and it works really well. I'm still coming to grips with scripting, which is why I get confused!

                  Thanks again, I'll have a beer for you tonight!

                  Have a great weekend!

                  Regards

                  VillaGorilla

                  Comment

                  Working...
                  X