import os, subprocess import win32api, win32con def _getProgramFilesDir(): k = r'SOFTWARE\Microsoft\Windows\CurrentVersion' h = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, k, 0, win32con.KEY_READ) return win32api.RegQueryValueEx(h, 'ProgramFilesDir')[0] def install(language): # uninstall old version uninstall = r'%s\nvu\unins000.exe' % _getProgramFilesDir() if os.path.exists(uninstall): res = subprocess.call([uninstall, '/silent']) if res < 0: return res # install new version return subprocess.call(['Nvu_En_1.0.exe', '/silent /norestart']) """ procedure InstallNvu(AExeName, AFlags : String); var Path : string; ResultCode:Integer; begin // UnInstall Old version Path := AddBackslash(ExpandConstant('{pf}'))+'Nvu\'; Exec(Path+'unins000.exe', '/silent', Path, {ShowCmd: Integer}1, {Wait}ewWaitUntilTerminated, {var ResultCode: Integer}ResultCode){: Boolean}; // Install New version Execute(AExeName, AFlags); end; """ if __name__=='__main__': install('en')