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

 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.
Kevin LarkinAsked:
Who is Participating?
Shift-3Connect With a Mentor Commented:
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

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.
Kevin LarkinAuthor Commented:
I don't want the password to be viewable in the startup script...  Even if it is encrypted...
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Kevin LarkinAuthor Commented:
I did not want to use the %ALLUSERSPROFILE% because the users don't have access to it.
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.
Kevin LarkinAuthor Commented:
Great Thanks...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.