Link to home
Start Free TrialLog in
Avatar of bsharath
bsharathFlag for India

asked on

Script that creates a flag after installation. Need it to check the path. if not there then install else skip.

Hi,

Script that creates a flag after installation. Need it to check the path. if not there then install else skip.
Instead of the inf file creating and checked i want the program files folder path checked. If there skip. else install.

regards
Sharath
@echo off 
setlocal 
set SourceFolder=\\in1\NETLOGON\Msi
set LogFolder=C:\Temp1
if exist %windir%\installflag211.inf goto END 
if not exist "%LogFolder%" md "%LogFolder%" 
  
set LogFile=%ComputerName%-%~n0.log 
>"%LogFolder%\%LogFile%" echo Source folder directory listing: 
dir "%SourceFolder%" >>"%LogFolder%\%LogFile%" 2>&1 
if errorlevel 1 ( 
  >>"%LogFolder%\%LogFile%" echo No access to source folder, leaving script. 
  goto :eof 
) 
  
set LogFile=%ComputerName%-snapclient.log 
msiexec /i "%SourceFolder%\snapclient.msi" /qn /Lv* "%LogFolder%\%LogFile%" 
set EL_CT=%errorlevel% 
  
  
>>"%LogFolder%\%ComputerName%-Results.log" echo %Date% %Time% Errorlevel snapclient:  %EL_CT% 
>>"%SourceFolder%\Logs\%ComputerName%-Results.log" echo %Date% %Time% Errorlevel snapclient:  %EL_CT% 
 
set /a EL = EL_CT + EL_WST 
if %EL%==0 ( 
  echo "Snap App is installed" > %windir%\installflag211.inf 
  cacls "C:\Program Files\Snap Communications Client" /t /c /e /g users:F 
  del "%LogFolder%\%ComputerName%-snapclient.log" 
  del "%LogFolder%\%ComputerName%-Results.log" 
)
  
:END

Open in new window

Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

u can check if it's already installed by 2 ways:
1. registry - under HKLM\software\microsoft\windows\currentversion\uninstall
2. run msiexec and if %errorlevel% is 1638, that means already installed
Avatar of bsharath

ASKER

1. Can it check the registry
That would be better

I will have situation as.
there is a new Msi built. At that times i need it reinstalled. in such case what can be done.?
u might install it under HKEY_CURRENT_USER\Software\Microsoft\Installer\Products
depends of the installation type (User Only/Everyone)
Everyone on the machines will have access and can use
>>here is a new Msi built. At that times i need it reinstalled. in such case what can be done.?

it depends if reinstallation is possible.
u might need to uninstall it first and then try reinstall it.

to check if entry exists in registry use the following:

reg query HKEY_CURRENT_USER\Software\Microsoft\Installer\Products /v INSTALLER_NAME || echo Does not Exist!!!!
Can we have the program files folder as the check point instead of the flag that creates not nor the registry.
if folder exists then do nothing else install
u can't be sure that the installer created a folder under program files, it's not a good reference for installation.
the registry is must more reliable.
If you change the script to check the registry value then will it install and upgrade msi when needed. Or will it skip when found a version already exists.?
if it is the same version it will skip the installation and move to the next one, but again it depends what u trying to achieve.
u can check in the registry if the version is older than the installer and in that case u might want to uninstall current version and then install the new one.
Oik can i get the registry check update in the script
what would u want to check in the registry?
Oops you told that we could check in registry if the Application is installed. if installed do nothing else install. As i use this in a Login script
can u check in the registry where the installation information is located.
is it under HKLM\software\microsoft\windows\currentversion\uninstall?
Yes i have it
{31EC18FB-53CF-11DD-8F86-0016D4EF12CC}

MsiExec.exe /X{31EC18FB-53CF-11DD-8F86-0016D4EF12CC}

ASKER CERTIFIED SOLUTION
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial