Need to copy a file into common folder location path for each user in one go - command-line

I have a file (named test.txt) that is currently only located on the Windows desktop for my user account. I need to copy this file to the same directory in each user account on this computer, such as:
C:\Users\MR.A\AppData\Roaming\Settings\test.txt
C:\Users\MR.B\AppData\Roaming\Settings\test.txt
C:\Users\MR.C\AppData\Roaming\Settings\test.txt
Within each user account, the path to the new location would be the same. How would I do this using the command line?

Related

Script to clone a template folder retaing permissions and prompt for new folder name

May I please get your insight?
I have a user group in AD call Contract Admin. I like would this user group to be able to run a script that clones a template folder (retaining permissions) to a new folder and prompt for a new client name.
The folder structure would be as follows:
Clients
New Folder (template folder) (Permissions: Admins, Contract Admin, Financial Admin)
Statements Folder (Permissions: Financial Admin)
End result after script:
Clients
ABC Company (Permissions: Admins, Contract Admin, Financial Admin)
Statements Folder (Permissions: Financial Admin)
Above is an example of the folder structure where New Folder is the template folder which also has a folder inside of it as well. I'd like to have the folders cloned with permissions retained.
I hope this is clear, I apologize if it is not. Thank you so much for your help.
The code I currently have for copying the permissions are as folows:
robocopy /e /copy:DATS "X:\Template" "X:\New Folder Name"
attrib -h "Template"
This is what I have for cloning the folders but I am lost from here.
Thank you
Solution:
#echo off
set "src=C:\Users\XXX\Desktop\template folder"
set /p "dest=Name of Client?: "
robocopy /e /copy:DATS %src% %dest%
the source can simply be the folder/file name without the full path if both the script and the folder/file to be copied is in the same directory.
/copy: Specifies the file properties to be copied. The following are the valid values for this option:
D Data A Attributes
T Time stamps S NTFS access control list (ACL)
O Owner information
U Auditing information
The default value for
CopyFlags is DAT (data, attributes, and time stamps).
But this is not a script. It's a robocopy command.
There are many switches robocopy, see its help file for them.
Specifically the mirror (/MIR) a folder tree to a new location.
As for prompting users, there are a few ways to do this. The most direct is Read-Host cmdlet provides. You simply capture that in a variable and pass that as the folder.
$FolderPath = Read-Host 'Enter a folder path.'

Robocopy file to random named folder

I'm creating a script to automatically copy and paste bookmarks to x amount of computers.
Robocopy the Mozilla Bookmarks which are stored in a file called places.sqlite on a drive. To the destination
Appdata\Roaming\Mozilla\Firefox\Profiles\\*RANDOM PROFILE NAME\places.sqlite
I can't find a solution to copy this file to the destination due to every windows profile and computer gets a random profile name created. I tried with a star * as you can see in the code because I thought a star choices the newest folder (last changed).
The code is:
$env:homeshare
$env:username
Robocopy "$env:homeshare\ComputerChange\" "C:\Users\$env:username\AppData\Roaming\Mozilla\Firefox\Profiles\*\" "places.sqlite" /COPY:DAT
How do I edit the code so it chooses the random named folder? Is it possible to copy the places.sqlite to ALL folder in the Profiles\ folder?
Appreciate the help

I have two users on Ubuntu system. for 1 user ~./profile file wrong command How to change?

I have two users on Ubuntu system. By mistake i have changed for a user his ~./profile file. I kept wrong command in this file. As a result when I login to this user it is going for loop. How can I modify the content of this file?
The ~ refers to the home folder of the current user. You can access directly the file in the user home folder :
/home/user1/.profile
/home/user2/.profile

save or write the files of directory in sandbox file system to user selected directory in chrome app

Summary:
Is there any way to save all files of sandbox file system directory to user local directory? I need user prompt only for directory not for each files.
Yes, it should be possible if you declare "directory" sub-permission in your manifest:
"permissions": [
{"fileSystem": ["write", "directory"]}
]
Then, you can request access to a directory with chrome.fileSystem.chooseEntry using type: "directory", convert the result to a writable entry using chrome.fileSystem.getWritableEntry (see comments) and then write the files you need.

Remote desktop sessions - Track/get the current location of user

I have been playing around with PSTermninalServices for a while, and I was wondering if it's possible to track, or get, the current location of the user that is holding, working directory, a remote desktop sessoin? E.g what folders are open and what files are opened by the user. Is this possible to achieve with scripting like PowerShell?
OS: Windows Server 2008 R2
Best regards.
DA.
i don't know how to do it with PS, but you can use psfile (part of the excellent pstools suite from Mark Russinovich )
psfile.exe [\\RemoteComputer [-u Username [-p Password]]] [[Id | path] [-c]]
-u Specifies optional user name for login to
remote computer.
-p Specifies password for user name.
Id Id of file to print information for or close.
Path Full or partial path of files to match.
-c Closes file identified by file Id.
Omitting a file identifier has PsFile list all files opened remotely.