April 3rd, 2002, 11:02 AM
write in file
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..
* if you like you can send the source code on how to do it to may email: firstname.lastname@example.org
I am newbie who want to be programmer (~6~)
April 3rd, 2002, 11:15 AM
In VB you would use the FileSystemObject.
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.
Set objFile = Nothing
Set objFSO = Nothing
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.
\"The purpose of abstraction is not to be vague, but to create a new semantic level in which one can be absolutely precise.\"
- Edsger Dijkstra
April 4th, 2002, 06:59 PM
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!
April 4th, 2002, 07:46 PM
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.
April 5th, 2002, 04:08 PM
using c++ you could do like this
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.