• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

How can I redirect output from a command to another command? (using the cmd line)

Arkitech

Diamond Member
Long story short, the access control department pushed an update that broke the user profile on about 40 Windows 7 workstations. Instead of taking the time to investigate where the break is actually located, desktop support has been tasked to manually recreate the profiles. Due to the nature of the users and the apps they use this process can take anywhere from 45 minutes or longer to accomplish. I would like to automate this process as much as possible.

I have written various small scripts to handle some of the tasks, such as backing up vital portions of the user's profiles (list of mapped drives, favorites and desktop items, etc..). But I would like to write a script that will make a copy of the old user directory and delete the registry entry for that profile so that a new fresh one is created when the user logs in.

So far this is what I have come up with.


copy c:\users\homer.simpson c:\users
set /p username=Input the username:
wmic %username% get name,sid


This syntax might be a little off (what I wrote at work, gets the desired result). My question is how do I take the sid and pipe it either to a new command or to a file that a command can parse and use.

I'm very green when it comes to scripting, so the simpler the explanation the better for me. Thanks for any help.
 
You can use ">" to set where the output goes.

EX:
Code:
dir > c:\something.txt
I'm sure there's a way to store it in a variable and not pipe it to another file, but I don't know enough BAT scripting to do it.


As an aside, don't know what's wrong with your user profiles, but there is usually a registry entry for each user by SID with a ".bak" extension. The process to use it is just to boot into a PE environment (or from a local admin account or something, just not while logged into the account you are changing), rename the non-.BAK profile to something like .TMP, remove the .BAK extension from the key name, then rename the .TMP one to have .BAK at the end. Don't know if that will fix your problem, but it sounds like it might be worth a quick 5 minute try.
 
Last edited:
Back
Top