Copy Files to every local users startmenu via computer startup script (Not ALLUSERS)

Posted on 2009-12-16
Last Modified: 2012-05-08
 Because a computer startup script is not user aware I can't use the typical %username% or %userprofile% to copy a file from a network share to the users start menu.  I can't use a logon script because the user does not have access to write to their start menu.  In my network users don't see  'ALLUSERS' items, so I can't use that.

 Can I create a batch that determines all the local users and copies this file to each of them? In other words, How can I get this file into the users start menu when they don't have permissions to save.  I don't want to use runas and/or and encryption type of third party software using the administrator account in the batch file.
Question by:Kevin Larkin
    LVL 1

    Expert Comment

    You can write the script to run with different credentials, so it can write to the start menu, but just make sure the users have read and execute rights to whatever file you are putting there.

    Author Comment

    by:Kevin Larkin
    I don't want the password to be viewable in the startup script...  Even if it is encrypted...
    LVL 38

    Accepted Solution

    Paste the script below into a text file with a .cmd extension.  Customize the value of the file variable on line 4 with the location of the file to copy.  Ensure that computers' AD accounts have Read permission to the share containing the file.

    Running the script will copy the file to the Start Menu folder of each user on the machine.

    @echo off
    set file=\\server\share\filename.txt
    set exclude=/C:"All Users" /C:"localservice" /C:"networkservice"
    for /F "tokens=*" %%G in ('dir "%allusersprofile%\.." /A:D /B^| findstr /I /V %exclude%') do (
     xcopy "%file%" "%allusersprofile%\..\%%G\Start Menu\" /C /H /R /Y

    Open in new window


    Author Comment

    by:Kevin Larkin
    I did not want to use the %ALLUSERSPROFILE% because the users don't have access to it.
    LVL 38

    Expert Comment

    My script does not use the All Users Profile.  It takes the %allusersprofile% variable and goes up one level (with the \..) to locate the directory where user profiles are stored.  It then copies the file to each user profile directory, excluding All Users, localservice, and networkservice.

    Author Closing Comment

    by:Kevin Larkin
    Great Thanks...

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT ( The crux of this batch f…
    This article was inspired by a question here at Experts Exchange ( The requirements stated in that question are (1) reduce the file size of a large number of…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    754 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