error in script

Discussion in 'Microsoft Office' started by Snuffy, Oct 27, 2016.

  1. Snuffy

    Snuffy MDL Expert

    Jan 7, 2008
    1,201
    595
    60
    #1 Snuffy, Oct 27, 2016
    Last edited: Oct 27, 2016
    if exist "%Windir%\System32\sppsvc.exe" set SysPath=%Windir%\System32
    echo ************************************************************
    echo *** Windows Status ***
    echo ************************************************************
    cscript /nologo %SysPath%\slmgr.vbs /dli

    :eek:2016x86
    reg query "HKLM\SOFTWARE\Microsoft\Office\16.0\Common\InstallRoot" >NUL 2>&1
    if %errorlevel% equ 1 goto o2016x64
    FOR /F "tokens=2*" %%a IN ('reg query "HKLM\SOFTWARE\Microsoft\Office\16.0\Common\InstallRoot" /v "Path"') do (SET office=%%b)
    echo ************************************************************
    echo *** Office 2016 x64 Status ***
    echo ************************************************************
    cd /d "%office%"
    cscript "%PROGRAMFILES%\Microsoft Office\Office16\ospp.vbs" /dstatus


    :eek:2016x64
    reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\16.0\Common\InstallRoot" >NUL 2>&1
    if %errorlevel% equ 1 goto o2016x86
    FOR /F "tokens=2*" %%a IN ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\16.0\Common\InstallRoot" /v "Path"') do (SET office=%%b)
    echo ************************************************************
    echo *** Office 2016 x86 Status ***
    echo ************************************************************
    cd /d "%office%"
    cscript "C:\Program Files (x86)\Microsoft Office\Office16\OSPP.vbs" /dstatus

    pause

    when I get it working proper in x64 I get errors in x86 or vs versa. any help appreciated
     
  2. Flipp3r

    Flipp3r MDL Expert

    Feb 11, 2009
    1,555
    664
    60
    #2 Flipp3r, Oct 28, 2016
    Last edited by a moderator: Apr 20, 2017
    Hey Snuffy,
    You should wrap your code with the CODE TAG.
    Can't you just:
    Code:
    If EXIST "C:\Program Files (x86)\Microsoft Office\Office16\OSPP.vbs" cscript "C:\Program Files (x86)\Microsoft Office\Office16\OSPP.vbs" /dstatus
    If EXIST "C:\Program Files\Microsoft Office\Office16\ospp.vbs" cscript "C:\Program Files\Microsoft Office\Office16\ospp.vbs" /dstatus
    pause
    In x86 you have "%PROGRAMFILES%...". perhaps that's your issue.
     
  3. Michaela Joy

    Michaela Joy MDL Crazy Lady

    Jul 26, 2012
    3,730
    4,065
    120
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. Snuffy

    Snuffy MDL Expert

    Jan 7, 2008
    1,201
    595
    60
    #4 Snuffy, Oct 28, 2016
    Last edited by a moderator: Apr 20, 2017
    (OP)
    I finally came up with: cause the least amount of errors.
    gives lots of info. just can not figure how to set the %error to not show,
    Code:
     @echo off
    
    color 1E
    
    if exist "%Windir%\Sysnative\sppsvc.exe" set SysPath=%Windir%\Sysnative
    if exist "%Windir%\System32\sppsvc.exe"  set SysPath=%Windir%\System32
    echo ************************************************************
    echo ***                      Windows Status                  ***
    echo ************************************************************
    cscript /nologo %SysPath%\slmgr.vbs /dli
    
    @Echo off
    
    Setlocal
    :: Get windows Version numbers
    For /f "tokens=2 delims=[]" %%G in ('ver') Do (set _version=%%G) 
    
    For /f "tokens=2,3,4 delims=. " %%G in ('echo %_version%') Do (set _major=%%G& set _minor=%%H & set _build=%%I) 
    
    Echo Major version: %_major%  Minor Version: %_minor%.%_build%
    
    @Echo off
    
    :pause
    ::SPack.cmd
    @echo off
    SETLOCAL
    :: Get the WINDOWS SERVICE PACK Level
    :: For NT or greater (XP, Win 7 etc)
    :: Requires the REG.exe utility
    
    :: The delimiters below are TAB plus Space
    
    FOR /f "tokens=2* delims= " %%G IN ('Reg.exe QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentVersion ^| find /i ^"CurrentVersion^"') DO (
    set _spack=%%H & echo Current Service Pack IS: %%H) 
    
    
    :o2016x86
    
    echo ************************************************************
    echo ***                 Office 2016 x64 Status               ***
    echo ************************************************************
    cscript "%PROGRAMFILES%\Microsoft Office\Office16\ospp.vbs" /dstatus
    
    :o2016x64 
    
    echo ************************************************************
    echo ***                 Office 2016 x86 Status               ***
    echo ************************************************************
    cscript "%PROGRAMFILES(x86)%\Microsoft Office\Office16\ospp.vbs" /dstatus