[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 539
  • Last Modified:

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.
0
Kevin Larkin
Asked:
Kevin Larkin
  • 3
  • 2
1 Solution
 
JackfooCommented:
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.
0
 
Kevin LarkinAuthor Commented:
I don't want the password to be viewable in the startup script...  Even if it is encrypted...
0
 
Shift-3Commented:
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
setlocal
 
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

0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now