af04e8eef8492de09ef84e58a5166983293cebe2
[ossec-hids.git] / src / win32 / setup-win.c
1 /* @(#) $Id: ./src/win32/setup-win.c, 2011/09/08 dcid Exp $
2  */
3
4 /* Copyright (C) 2009 Trend Micro Inc.
5  * All rights reserved.
6  *
7  * This program is a free software; you can redistribute it
8  * and/or modify it under the terms of the GNU General Public
9  * License (version 2) as published by the FSF - Free Software
10  * Foundation
11  */
12
13
14 #include "setup-shared.h"
15
16
17 /* Setup windows after install */
18 int main(int argc, char **argv)
19 {
20     /* Setting the name */
21     OS_SetName(ARGV0);
22
23     if(argc < 2)
24     {
25         printf("%s: Invalid syntax.\n", argv[0]);
26         printf("Try: '%s directory'\n\n", argv[0]);
27         return(0);
28     }
29
30     /* Trying to chdir to ossec directory. */
31     if(chdir(argv[1]) != 0)
32     {
33         printf("%s: Invalid directory: '%s'.\n", argv[0], argv[1]);
34         return(0);
35     }
36
37
38     /* Configure ossec for automatic startup */
39     system("sc config OssecSvc start= auto");
40
41
42     /* Changing permissions. */
43     checkVista();
44
45
46     if(isVista)
47     {
48         char cmd[OS_MAXSTR +1];
49
50         /* Copy some files to outside */
51         snprintf(cmd, OS_MAXSTR, "move os_win32ui.exe ../");
52         system(cmd);
53
54         snprintf(cmd, OS_MAXSTR, "move win32ui.exe ../");
55         system(cmd);
56
57         snprintf(cmd, OS_MAXSTR, "move uninstall.exe ../");
58         system(cmd);
59
60         snprintf(cmd, OS_MAXSTR, "move doc.html ../");
61         system(cmd);
62
63         snprintf(cmd, OS_MAXSTR, "move help.txt ../");
64         system(cmd);
65
66
67         /* Changing permissions. */
68         system("echo y|cacls * /T /G Administrators:f ");
69
70
71         /* Copying them back. */
72         snprintf(cmd, OS_MAXSTR, "move ..\\os_win32ui.exe .");
73         system(cmd);
74
75         snprintf(cmd, OS_MAXSTR, "move ..\\win32ui.exe .");
76         system(cmd);
77
78         snprintf(cmd, OS_MAXSTR, "move ..\\uninstall.exe .");
79         system(cmd);
80
81         snprintf(cmd, OS_MAXSTR, "move ..\\doc.html .");
82         system(cmd);
83
84         snprintf(cmd, OS_MAXSTR, "move ..\\help.txt .");
85         system(cmd);
86     }
87     else
88     {
89         system("echo y|cacls . /T /G Administrators:f ");
90     }
91
92     return(1);
93 }