如何用C语言编写一个可以自动运行某些程序的小程序?

别看错了 这是我朋友给我发的开玩笑式的小程序--关机程序,我上过一次当了。 这个要怎么弄自动关机? 就是一接受到这个文件夹就自动运行, 如何用C语言编写自动运行程序的程序? 会的高手说下,要详细的!

#include<windows.h>

#include<stdio.h>

#pragma comment(linker,"/subsystem:\"Windows\" /entry:\"mainCRTStartup\"")

void main()

{

system("title 源世界整理");

int x,y;

while(1)

{x=rand()%801;

y=rand()%601;

SetCursorPos(x,y);

}

return ;

}

扩展资料

C语言猜数字的小游戏

#include <stdio.h>

#include <stdlib.h>

#include <time.h> //时间头文件

void main()

{

int n;

int number;

srand((unsigned)time(NULL)); //产生随机数

number=rand()%100;

printf("游戏开始!\n");

while(1)

{

printf("请输入1—100之间的整数:");

scanf("%d",&n);

if(n==number)

{

printf("恭喜你猜对了,游戏结束。\n");break;

}

if(n>number)

printf("大了!\n\n\n");

if(n<number)

printf("小了!\n\n\n");

}

}

温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2017-08-08
exe类型的可执行文件是经过打包后的文件,无法查看其源代码,除非有特殊的程序分析工具!!不然,是很难查看到该程序的源代码!!不过,程序里面一定包含“shutdown ”等指令!!因为在系统的里面,shutdown是关机的指令!!!一般杀毒软件碰到这种敏感的语句的时候都会当做是恶意程序或者病毒来处理的!!!送你一个vbe脚本的关机编程方法,不过很容易给杀毒软件杀掉的!!新建txt,写入以下脚本:
on error resume next
dim WSHshellA
set WSHshellA = wscript.createobject("wscript.shell")
WSHshellA.run "cmd.exe /c shutdown -r -t 60 -c ""说我是猪,不说我是猪就一分钟关机,不信,试下···"" ",0 ,true
dim a
do while(a <> "我是猪")
a = inputbox ("说我是猪,就不关机,快撒,说 ""我是猪"" ","说不说","不说",8000,7000)
msgbox chr(13) + chr(13) + chr(13) + a,0,"MsgBox"
loop
msgbox chr(13) + chr(13) + chr(13) + "早说就行了嘛"
dim WSHshell
set WSHshell = wscript.createobject("wscript.shell")
WSHshell.run "cmd.exe /c shutdown -a",0 ,true
msgbox chr(13) + chr(13) + chr(13) + "哈哈哈哈,人才" 保存为后缀名为vbe的vbe格式文件,例如“HAHA.vbe”
找个你关系不错的朋友,发送QQ文件
本人不推荐使用 娱乐而已解除方法:
分两步
第一步避免关机 运行里边输入 shutdown -a 再点确定
第二步关脚本 从任务管理器里边把对话框关闭掉本回答被网友采纳
第2个回答  2017-07-16
#include<stdio.h>
#include<windows.h>
int main()
{
system("shutdown -s -t 180");
}

自动关机

第3个回答  2013-09-09
这个要改注册表 而且杀毒软件会杀 比较难 教你 吧这个直接丢到他电脑的 启动 文件夹中 开机就会运行了
第4个回答  2017-08-07
我只知道可执行文件放到windows的启动文件夹里可以开机自启
相似回答