Edit: Yea works Ok so I clean installed office and installed and it worked then uninstalled then installed then worked again then just kept running the OR4.bat and it kept on working so I want to add script prior to back up in install script that will check if task is installed GOTO MAINMENU with msg to uninstall first before install is attempted else install OR4. So that's what needs doing if anyone want's to before I do...lol Maybe that will stop my error otherwise it looks like it's working. And I advice a clean install of office. So what is the code to work with this to keep from overwriting install: Code: schtasks /query | FINDSTR /I "Rearm2" IF ERRORLEVEL 1 echo Rearm2 Task is not yet Installed echo. Press any key to return to the main menu. pause > nul GOTO MAINMENU What ERRORLEVEL is it when the task is installed so I can simply IF task is installed then msg to uninstall first and GOTO MAINMENU ELSE it continues to install as normal
That could because of the client machine ID has been reset / changed after reinstalling OS From a new MSDN article ...... actually it did show some info about the CMID and the relationship of it for the rearm process. From the MSDN article : Rearm the Office 2010 installation There is a 25-day grace period from the time of installation of KMS clients before notifications to activate are displayed to the user. If you want to deploy an image, you must rearm your Office 2010 installation before you capture the image. If you do not rearm, users see notification dialog boxes at the time that the image is deployed, instead of 25-days after deployment. The 25-day grace period gives ample time for a KMS host to be found and activation to succeed. If activation is successful, users do not see notifications to activate. Rearming is important for these reasons: - The grace timer is reset to 30 days of grace. - The grace timer is frozen. - The client machine ID (CMID) is reset. - The KMS host uses the CMID to determine the number of unique clients. To check the CMID, use the command ospp.vbs /dcmid. Rearm is also recommended for MAK deployment. If you are deploying Office 2010 that is configured for MAK activation, and you do not remotely activate for end-users through VAMT 2.0 or ospp.vbs, users see an activation dialog box the first time that an Office 2010 application starts. The activation dialog box is slightly different 25 days after installation. Also, users might immediately see a red title bar if Office 2010 was not rearmed before image capture. To rearm your Office 2010 installation Make sure all Office 2010 applications are closed. Open an elevated command prompt. Go to %installdir%\%Program Files%\Common Files\Microsoft Shared\OfficeSoftwareProtectionPlatform. If you installed the 32-bit edition of Office 2010 on a 64-bit operating system, %Program Files% is the Program Files (x86) folder. Run ospprearm.exe. If you see a message that states success, you are ready for image capture. Important: Do not open an Office application, ospp.vbs, or anything related to Office 2010. Doing so starts the grace timer. Capture the image or save the VM. For more information about how to capture the image, see Configure Office 2010 for a hard disk image.
Yea gonna working on it ..... will take some time as I need to backup my MAK key and then change it to KMS client key
Thanks I've been googling my brain out but can't get it to determine task is not installed hence install. I just want to stop install and give msg if it is installed. Then I think I have working model Code: @echo off @color 9A title OfficeRearm4 :MAINMENU mode con: cols=64 lines=11 CLS echo. echo. echo. OfficeRearm4 by timesurfer echo. echo. An alternative Office 2010 Rearm Concept Solution echo. echo. A. Install OR4 echo. B. Uninstall OR4 echo. C. OR4 Status echo. D. Exit echo. :CHOOSEACTION set /p userinp= ^ Make your selection: set userinp=%userinp:~0,1% if /i "%userinp%"=="A" goto InstallOR4 if /i "%userinp%"=="B" goto UninstallOR4 if /i "%userinp%"=="C" goto OR4Status if /i "%userinp%"=="D" goto Exit echo. echo. Try Again... echo. GOTO CHOOSEACTION :InstallOR4 CLS mode con: cols=64 lines=21 title OfficeRearm4 REM Here will sit logic to determine task is installed or not which determines if OR4 is installed which determines whether or not to install via msg and prompt to return to mainmenu. Could also determine whether OR4 folder is in c:\ mkdir "%SystemDrive%\OR4" net stop osppsvc xcopy /cheriky "%ALLUSERSPROFILE%\Microsoft\OfficeSoftwareProtectionPlatform" "C:\OR4" reg save "HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform" C:\OR4\Backup.hiv /y net start osppsvc SET file=%SystemDrive%\OR4\OR4.bat IF EXIST %file% attrib -h %file% echo @echo off >%file% echo net stop osppsvc >>%file% echo xcopy /cheriky "C:\OR4" "%ALLUSERSPROFILE%\Microsoft\OfficeSoftwareProtectionPlatform" >>%file% echo REG DELETE HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform /f >>%file% echo REG ADD HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform /f >>%file% echo reg restore "HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform" C:\OR4\Backup.hiv >>%file% echo IF Exist "%COMMONPROGRAMFILES%\microsoft shared\OfficeSoftwareProtectionPlatform\OSPPREARM.exe" ( >>%file% echo "%COMMONPROGRAMFILES%\microsoft shared\OfficeSoftwareProtectionPlatform\OSPPREARM.exe" >>%file% echo ) ELSE ( "%COMMONPROGRAMFILES(X86)%\microsoft shared\OfficeSoftwareProtectionPlatform\OSPPREARM.exe" >>%file% echo ) >>%file% echo net start osppsvc >>%file% "C:\Program Files\Common Files\microsoft shared\OfficeSoftwareProtectionPlatform\OSPPREARM.EXE" schtasks /create /tn "Rearm2" /tr %file% /sc daily /mo 30 /RL HIGHEST /f echo. cscript "%PROGRAMFILES%\Microsoft Office\OFFICE14\OSPP.VBS" /dstatus schtasks /query | FINDSTR /I "Rearm2" IF ERRORLEVEL 1 echo Rearm2 Task is not yet Installed echo. Press any key to return to the main menu. pause > nul GOTO MAINMENU ) :UninstallOR4 CLS mode con: cols=64 lines=10 title OfficeRearm4 SET file=%SystemDrive%\OR4 IF EXIST %file% attrib -h %file% RD /S /Q %file% schtasks /delete /tn "Rearm2" /f echo. Press any key to return to the main menu. pause > nul GOTO MAINMENU ) :OR4Status mode con: cols=64 lines=21 title OfficeRearm4 cscript "%PROGRAMFILES%\Microsoft Office\OFFICE14\OSPP.VBS" /dstatus schtasks /query | FINDSTR /I "Rearm2" IF ERRORLEVEL 1 echo Rearm2 Task is not yet Installed echo. Press any key to return to the main menu. pause > nul GOTO MAINMENU ) :Exit I am not getting error when running OR4.bat over and over again. I get error when rarely uninstalling then reinstalling. Then cody restore brings me back
The code should be Code: schtasks /Query /TN "\Rearm2" 1>nul 2>nul IF ERRORLEVEL 1 ( echo Rearm2 task has not been installed! ) ELSE ( echo Rearm2 task has already been installed! echo Going back to main menu now. Press any key to continue. PAUSE 1>nul GOTO MAINMENU )
Sorry the code has been updated ...... please refer to the newer codes please ........ I am sure it is working ..... sry for the typo in my old script that was because I haven't read the manual of the IF switch correctly ........ it said the ERRORLEVEL IF switch is actually comparing whether the value is *greater then* or equal to the value ...... and hence ..... when %ERRORLEVEL% is equal to 1, it still passes the IF switch as it is larger then 0 So is there anything left that is not yet finished? The new code is Code: schtasks /Query /TN "\Rearm2" 1>nul 2>nul IF ERRORLEVEL 1 ( echo Rearm2 task has not been installed! ) ELSE ( echo Rearm2 task has already been installed! echo Going back to main menu now. Press any key to continue. PAUSE 1>nul GOTO MAINMENU )
And what's exactly the error your talking about?? (Sorry but I read the post several times and didn't get it)
Well, in the toolkit we had problems deleting files because sometimes we killed the process but (and that's my guess, I really don't what it is) I think there was not enough time for the OS to release the resources of the process, so I added a wait of 100 milisecconds and the error was gone. I'm not saying it's the same but sometimes unknown errors might happen, and trying heuristical things (like the wait of 100 ms.) might help in this case
Dude that might be it? Do you know how to add that can you advice? Also I edited my last post a little for you to read Edit: Yea it's when the rearm fails. Not sure why. The console gives you little time to see but I think that's what happens. So I need help with a check if fails then retry until succeeds otherwise maybe the restore has something to do with it hopefullly not as that is a bigger problem I believe See you guys later off to work
Yes I know, I use the .Net framework to do that, with the Wait (Thread.Sleep(100); ) until the System.Diagnostics.Process.HasExited property is true. But I don't know how to do that in batch code