hi...
could you tell me how to write to autoexec.bat with VB/java/c ....
please... i really want to know.... :P
thanks for your help guys..
~6~
* if you like you can send the source code on how to do it to may email: [email protected]
Printable View
hi...
could you tell me how to write to autoexec.bat with VB/java/c ....
please... i really want to know.... :P
thanks for your help guys..
~6~
* if you like you can send the source code on how to do it to may email: [email protected]
In VB you would use the FileSystemObject.
<dry coded>
Dim objFSO As Scripting.FileSystemObject
Dim objFSO As File 'Or something...
Set objFSO = New Scripting.FileSystemObject
Set objFile = objFSO.OpenTextFile("c:\autoexec.bat",ForWriting)' There should be another param here. Check the overloads in your documentation.
objFile.Write("yadayada")
objFIle.Close()
Set objFile = Nothing
Set objFSO = Nothing
</dry coded>
In Java I guess you'd use a streamwriter but I'm not sure. Check google or the documentation on VB for more info. Writing to files is very straightforward.
Cheers,
Mankan > You don't need to open the FileSystemObject if you know The autoexec.bat are located on C:\ on every pc.......
FileSystemObject is god to use if you shall find the % systemroot % or som thing like that!
Autoexec.bat isn't always located on C:\. On Windows XP, it's down in the Windows folder, and, by default, it still gets parsed at logon, so, if you want to use your program on Windows XP (or 2000 for that matter), you would have to use the FileSystemObject.
AJ
using c++ you could do like this
#include<fstream.h>
#include<dir.h>
int main()
{
ofstream fout;
chdir("\\");
fout.open("AUTOEXEC.BAT");
fout<<"CLS\nDIR";
fout.close();
return 0;
}
this will write CLS in the 1st line and DIR in the 2nd line but it'll clean the contents first, use ios::app if you want to append in the end.