2014-06-27 70 views
0

我在贏得7企業環境中的批處理,遠程重新創建用戶配置文件。我知道代碼可能更有效,但除了用戶計算機上的註冊表條目需要刪除的情況之外,它都可以工作。我不知道如何找到他們的具體條目,然後刪除它。你們可以看看嗎?此外,歡迎任何代碼改進。我仍然在頂部的整個「RWM」圖形存在問題,但現在並不重要。你會看到你是否打開批處理。創建批處理以遠程重新創建用戶win 7配置文件

@echo off 
MODE 75,30 

::Notes 
::Remote Workstation Manager BETA unreleased 
:: 
:: 

:start 
cls 
TITLE Remote Workstation Manager BETA unreleased 

::Declarations 
setLocal EnableDelayedExpansion 
set date=%date:~4,2%%date:~7,2%%date:~10,4%% 
color 0a 

echo.&echo.&echo.&echo.&echo.&echo. 
SET /P ".=     "<nul &Call :Color 0E " ######  #  #  #  # " end&echo. 
SET /P ".=     "<nul &Call :Color 0E " #  #  # # #  ## ## " end&echo. 
SET /P ".=     "<nul &Call :Color 0E " #  #  # # #  # # # # " end&echo. 
SET /P ".=     "<nul &Call :Color 0E " ######  # # #  # # # " end&echo. 
SET /P ".=     "<nul &Call :Color 0E " # # ### # # # ### #  # " end&echo. 
SET /P ".=     "<nul &Call :Color 0E " # # ### # # # ### #  # " end&echo. 
SET /P ".=     "<nul &Call :Color 0E " #  # ### ## ## ### #  # " end&echo. 
echo. 
SET /P ".=     "<nul &Call :Color 09 "=================================" end&echo. 
SET /P ".=     "<nul &Call :Color 09 "=" &Call :Color 0C " R" &Call :Color 0f "emote" &Call :Color 0C " W" &Call :Color 0f "orkstation" &Call :Color 0C " M" &Call :Color 0f "anager v1" &Call :Color 09 " =" end&echo. 
SET /P ".=     "<nul &Call :Color 09 "=================================" end&echo.&echo.&echo. 

echo 1. - Recreate Windows User Profile 
::Restarts Users Laptop and when at Login Screen 

echo.0. - Exits 

set /p input=Choose a number and press enter: 
if %input%==1 goto :1 
if %input%==0 goto :0 

:1 
cls 
@echo off 
TITLE Recreating Windows Profile 

set /p ip= Enter the computers IP or Workstation Name: 
echo The ip is %ip% 

set /p username= Enter the users EUID: 
echo The username is %USERNAME% 

cls 
echo Press enter to restart the users machine. 
echo. 
pause 

xcopy "\\utils\h$\Utilities\Restore.bat" "\\%ip%\c$\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup" /i /y 

cls 
echo Restarting users PC . . . 

@echo off 

shutdown -r -f -t 1 -m \\%ip% 

@echo off 

:loop 
Timeout /t 15 
ping -n 1 %ip% >null 
if %ERRORLEVEL% EQU 0 goto :loop 
if %ERRORLEVEL% EQU 1 goto :continue2 

:continue2 
cls 
@echo off 
echo Waiting for Startup . . . 
:retry 
Timeout /t 2 
IF NOT EXIST "\\%ip%\c$\Users\%USERNAME%\" goto :retry 
IF EXIST "\\%ip%\c$\Users\%USERNAME%\" goto :continue3 

:continue3 
Timeout /t 10 
cls 
echo Refreshing profile . . . 

rmdir "\\%ip%\c$\Users\Temp" /s /q 

rmdir "\\%ip%\c$\Users\Temp.COF" /s /q 

rename "\\%ip%\c$\Users\%USERNAME%" %USERNAME%.%date% 

echo. 
echo Complete. 

Timeout /t 10 
cls 

echo Waiting for the User to log in . . . 

:retry2 
sleep 2 
IF NOT EXIST "\\%ip%\c$\Users\%USERNAME%\" goto :retry2 
IF EXIST "\\%ip%\c$\Users\%USERNAME%\" goto :continue4 

:continue4 

cls 
echo Completed. Wait for new profile to be created and verify the users data has been restored. 

echo. 
pause 
goto :start 

0: 
exit 
+1

請編輯您的代碼,並刪除所有是不相關的問題,不必要的噪音。 –

回答

0

您可以使用專門爲這項任務設計的工具(刪除用戶資料乾淨,無論是從文件夾視圖和註冊表視圖)Delprof http://www.microsoft.com/en-us/download/details.aspx?id=5405&751be11f-ede8-5a0c-058c-2ee190a24fa6=True做這個任務。你也可以看看到名爲Delprof 2(http://www.edugeek.net/forums/windows-7/75098-delprof2-unofficial-successor-microsoft-s-delprof-user-profile-deletion-tool.html

一個新的(非官方)工具

你可以解釋一下你所說的「重建」用戶配置文件是什麼,你只是意味着擦拭的用戶配置文件,並讓Windows重新它並添加一個批處理啓動文件夾,將做一些定製?

+0

正確。因此,使用該實用程序,我不需要設置類似psexec的東西,以便我可以遠程執行它?另外,像這樣永久刪除它會讓我有點緊張。如果用戶數據在備份方面不成功,並且刪除它,則其所有數據都將消失。 – Sandfrog

+0

我希望Win 7就像XP一樣,我們可以重命名用戶配置文件文件夾:( – Sandfrog

+0

確實,首先將delprof.exe複製到\\%IP%\ Admin $(共享%WINDIR%文件夾),然後使用psexec運行它與遠程計算機的本地管理員組的帳戶成員 – rebrec

0

在PowerShell中,你可以使用:

gci "HKLM:\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\ProfileList" -rec -ea SilentlyContinue | % { if((get-itemproperty -Path $_.PsPath) -match "techid") { $_.PsPath} } | Remove-Item