Solved

Expert Qlemo or others Expert How do I move C:\Windows\$NtUninstall to another folder using a batch file?

Posted on 2011-09-15
2
421 Views
Last Modified: 2012-05-12
I have this batch file without the /MOVE option, I would like to include it in order to move the target folder, and their contain files

In order words
I need a code WHICH
MOVE WITH the criteria to "all folders C:\Windows\$*, but not $hf_mig$" AND their contents of each folders TO C:\Backup\NtUninstall\
IF all folders FROM C:\Windows\$*, but not $hf_mig$" AND their contents (are) MOVE TO C:\Backup\NtUninstall\ I will NOT have to have at C:\Windows\ any folder that start WITH "$" except the folder $hf_mig$ and the folder's contains of the MOVEd TO C:\Backup\NtUninstall\

@ECHO OFF
pushd %SystemRoot%
for /F "tokens=*" %%D in ('dir $* /b /a:d ^| find /v "$hf_mig$" ') do (
   md C:\Backup\NTUninstall\%%~nxD 2>nul
   robocopy "%%~D\" "C:\Backup\NtUninstall\%%~nxD" /MOVE
   rd "%%~D" 2>nul
) 

Open in new window

0
Comment
Question by:rebelscum0000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 69

Accepted Solution

by:
Qlemo earned 500 total points
ID: 36550477
After some minor corrections, the script runs as expected:
@ECHO OFF
pushd %SystemRoot%
for /F "tokens=*" %%D in ('dir $* /b /a:d ^| find /v "$hf_mig$" ') do (
   md C:\Backup\NTUninstall\%%~nxD 2>nul
   robocopy "%%~D" "C:\Backup\NtUninstall\%%~nxD" /MOVE /E
   rd "%%~D" 2>nul
) 
popd

Open in new window

The corrections are:
* removed backslash from robocopy source folder name (you took the wrong code, it's already corrected in the other question)
* added /E to robocopy options
* added popd at the end of file
That's all what has been needed.
0
 

Author Closing Comment

by:rebelscum0000
ID: 36564913
Excellent!!, That is what I want, the batch file MOVES all the folders and their contents FROM C:\Windows\$*, but not $hf_mig$ to another location in this case C:\Backup\NTUninstall\

Thank you very much
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this post we will learn different types of Android Layout and some basics of an Android App.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question