I have this C++ program that checks if certain files exist, and then it installs them if they arent. The problem is it only works on NT/2000/XP systems
on other systems it works to the point that it doesnt find the files, installs them all, and then finishes correctly, but the next time its run, it does the same thing.
Well i read the post on posting, so ill put it in code tags instead:
Code:
#include <sys/stat.h>
#include <stdio.h>
#include <conio.h>
#include <process.h>
bool fileExists (char * fileName)
{
struct stat buf;
int i = stat ( fileName, &buf );
if ( i == 0 )
{
return true;
}
return false;
}
void Launch(char * FileName)
{
system(FileName);
}
int askDir(void)
{
char answer;
answer='0';
while ((answer != '1') && (answer != '2'))
{
printf("Both WinNT and Windows directory exist!\n");
printf("Please choose which directory Windows is installed in.\n");
printf("\n");
printf("1) Windows\n");
printf("2) WinNt\n");
printf("\n");
answer=(char)getch();
if (answer=='1')
{
return(1);
}
else if (answer=='2')
{
return(2);
}
else
{
Launch("cls");
printf("Invalid Response\n\n");
}
}
return(0);
}
int determineDir(void){
if (fileExists("C:/Windows") & fileExists("C:/Winnt"))
{
//printf("Both WINNT and WINDOWS directory exist");
return(3);
}
else if(fileExists("C:/Windows"))
{
//printf("Windows Directory Only");
return(1);
}
else if(fileExists("C:/Winnt"))
{
//printf("Winnt Directory Only");
return(2);
}
return(0);
}
bool LookFiles(void)
{
int i=determineDir();
bool install;
install=false;
if (i==3)
{
i=askDir();
}
if (i==1)
{
if (fileExists("C:/Windows/msvbvm60.dll") || fileExists("C:/Windows/system32/msvbvm60.dll"))
{
printf("Visual Basic Runtimes Found, Skipping Installation\n");
}
else
{
Launch("vbrun60sp5.exe");
printf("Visual Basic Runtimes Installed\n");
install=true;
}
if (fileExists("C:/Windows/mscomctl.ocx") || fileExists("C:/Windows/system32/mscomctl.ocx"))
{
printf("Microsoft Common Controls Found, Skipping Installation\n");
}
else
{
Launch("missingfilesetup.exe");
printf("Common Controls Installed\n");
install=true;
}
if (fileExists("C:/Windows/talctl32.ocx") || fileExists("C:/Windows/system32/tabctl32.ocx"))
{
printf("Microsoft Tab Control Found, Skipping Installation\n");
}
else
{
Launch("tabinstall.exe /silent");
printf("Tab Control Installed\n");
install=true;
}
}
if (i==2)
{
if (fileExists("C:/WinNT/msvbvm60.dll") || fileExists("C:/WinNT/system32/msvbvm60.dll"))
{
printf("Visual Basic Runtimes Found, Skipping Installation\n");
}
else
{
Launch("vbrun60sp5.exe");
printf("Visual Basic Runtimes Installed\n");
install=true;
}
if (fileExists("C:/WinNT/mscomctl.ocx") || fileExists("C:/WinNT/system32/mscomctl.ocx"))
{
printf("Microsoft Common Controls Found, Skipping Installation\n");
}
else
{
Launch("missingfilesetup.exe");
printf("Common Controls Installed\n");
install=true;
}
if (fileExists("C:/WinNT/talctl32.ocx") || fileExists("C:/WinNT/system32/tabctl32.ocx"))
{
printf("Microsoft Tab Control Found, Skipping Installation\n");
}
else
{
Launch("tabinstall.exe /silent");
printf("Tab Control Installed\n");
install=true;
}
}
return(install);
}
int main(void) {
bool Install;
Launch("cls");
Install=LookFiles();
printf("\n\n");
if (Install)
{
printf("Files Have Finished Installing. Press Any Key To Continue");
getch();
}
else
{
printf("No Files Were Installed, Ending Application");
}
execl("utilities","utilities",(char *)0);
return (0);
}