Batch Command to Copy Group Policy User Files to Sub-Folder with Unknown Name - windows

I'm working on a project where I need to sysprep a windows 7 image. I need to create a batch script to delete the existing files and sub folders inside another folder with an unknowable name located within the windows/system32/GroupPolicyUsers folder and then copy the needed user policies back into the windows/system32/GroupPolicyUsers/unkownFolderName folder and finally run gpupdate /force.
There is only a single sub folder in the /windows/system32/GroupPolicyUsers folder, but the name of that folder changes to the SID of the user after sysprep which is why I cannot know the exact name of the folder.
Inside this folder having the unknown name there is one sub folder and one file that needs to be deleted and replaced with my own folder and file.
Is this possible using a batch script?
Thanks in advance for your replies...

Related

basic mkdir command not working. What am I doing wrong?

So I'm trying to create basic directory and push it out across our end users. I've got the basic .cmd to work but it breaks when I have a folder with multiple spaces.
cmd /c mkdir "C:\ProgramData\Example\This Folder Has Four Spaces\Example"
the plan is to set this to run automatically on machines.. If I remove the path with the long folder name, it works perfectly fine. Is there a way for me to place a file in the directory that has a long folder name with spaces? I wasn't sure if there was any sort of bypass to this. I initially thought it was because I was trying to copy a file to the program data folder but I've tested this with other folder names and it works fine. Just seems to be this specific folder it doesn't work with so I'm led to believe it's because of how long the folder name is.

Temporary tmp files created by Inno Setup in destination directory while installing

One of my customers reported that my app installer creates a temp file like is-XXXXX.tmp in the {app} directory, which are identified by anti-virus app as malware. The temp file would only live for a very short time, so I can't make a copy of it. My customer ask me to send him a copy of the temp file to make sure there is no harmful code inside it. Is there any method to copy this temp file out on installation? Thanks!
When Inno Setup is extracting files to their destination folders, it always does that first by storing them to the file names like is-XXXXX.tmp. Only then, it renames them to their actual file names.
So all those files are actually the files that your customer has in the destination folder once the installation completes.

CMD move files without knowing folder name

I'm using Windows CMD via an ANT Build file to move files from a sub-folder into a parent folder that is three levels up. The structure looks like this:
containingFolder
-tempFolder
-unkownNamedFolder
-contents.xyz
Using linux I can do this with the command mv */*.* .. with the current working directory being the temp folder. I don't know what the unknownNamedFolder will be called, but I do know that it will always be the only folder within the temp folder and that whatever content is within it needs to be extracted out to the containingFolder so that temp can be deleted and only the files will remain.
I've tried a command such as /c move *\*.* .. 2>NUL but this doesn't work.

Script which copies original files from shortcut paths

I have a folder that has subfolders with some files that are shortcuts to their original file in a different location outside these main folder. I need to write a script (Windows preferably) that parses through each subfolder and goes to each folder from the shortcuts target path and copies the original file into a specific folder.
In the end I want a folder with a copy of all the original files that were shortcuts from my subfolders.
Is this possible? Thank you so much!

Writing and integrating a batch file to create directory listing

I'm trying to modify the Windows 7 "Print Directory Listing" option to allow me to create a simple text list of the files located in the folder, saved to that folder. A couple of hours of Googling only found "Print Directory Listing" directions.
I've tried a few attempts at modifying the PRINTDIR.BAT file, but I'm pretty sure my output directory selection is wrong.
Here's my current effort, pared down to the bare metal.
#echo off
dir %1 > ".\_Listing.txt"
exit
The batch file is saved into the C:\Windows\ folder, and I suspect it's attempting to create the file in and of that folder, instead of the desired target folder.

Resources