configureEnvironmentVariables.cpp
1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#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;
}