configureEnvironmentVariables.cpp 1.79 KB

#include <string>
#include <stdio.h>
/*
	Seta as variáveis de ambitentes necessarias
	Autor: ezequie silva
	Email: eseveriano@gmail.com
*/

using namespace std;


int main(int argc, char *argv[]){ 

	char str[4096];
	str[0]=0;
	FILE *fp = _popen("echo %PATH%","r");
	char buf[1024];


	while (fgets(buf, 1024, fp)) {
	  strcat(str,buf);
	}



	string path="";
	
  char * pch;
  char item[1024];

  pch = strtok (str,";");
  while (pch != NULL)
  {
    strcpy(item,pch);
	if(!strstr(path.c_str(),item))
	{	if(!(strstr(item,"vlibras") || strstr(item,"VLibras") || strstr(item,"PYTHONPATH") || strstr(item,"Python27")))
		{
		
			path.append(pch);
			path.append(";");
		}
			
	}
	
    pch = strtok (NULL, ";");
  }
system("C:\\Windows\\System32\\SETX PATH_VLIBRAS %HOMEDRIVE%\\VLibras /M");
system("C:\\Windows\\System32\\SETX AELIUS_DATA %PATH_VLIBRAS%\\aelius_data /M");
system("C:\\Windows\\System32\\SETX NLTK_DATA %PATH_VLIBRAS%\\nltk_data /M");
system("C:\\Windows\\System32\\SETX HUNPOS_TAGGER %PATH_VLIBRAS%\\bin\\hunpos-tag.exe /M");
system("C:\\Windows\\System32\\SETX TRANSLATE_DATA %PATH_VLIBRAS%\\translate\\data /M");
system("C:\\Windows\\System32\\SETX PYTHONPATH %HOMEDRIVE%\\Python27;%HOMEDRIVE%\\Python27\\Scripts;%HOMEDRIVE%\\Python27\\Lib\\site-packages;%PATH_VLIBRAS%;%PATH_VLIBRAS%\\bin;%PATH_VLIBRAS%\\translate\\src;%PATH_VLIBRAS%\\Clipboard;%PATH_VLIBRAS%\\update;%PATH_VLIBRAS%\\nltk_data;%PATH_VLIBRAS%\\Aelius /M");



string pathFinal="C:\\Windows\\System32\\SETX PATH \"";
pathFinal.append("%\"PYTHONPATH\"%;");
pathFinal.append(path);
pathFinal.append("\" /M");
system(pathFinal.c_str());


pathFinal="C:\\Windows\\System32\\SETX \"PATH\" \"";
pathFinal.append("%\"PYTHONPATH\"%;");
pathFinal.append(path);
pathFinal.append("\"");
system(pathFinal.c_str());

fclose(fp);

   
    return 0; 
}