Advertise Here

Author Topic: [Tutorial] Writing Temporary Batch Files.  (Read 7494 times)

0 Members and 1 Guest are viewing this topic.

Offline Global

  • SMF For Free Member
  • *
  • Posts: 20
  • Is a
    • View Profile

  • Total Badges: 11
    Badges: (View All)
    Topic Starter Combination Level 2 Level 1 10 Posts
[Tutorial] Writing Temporary Batch Files.
« on: December 07, 2007, 02:40:00 am »
In this tut i will teach you how to make temporary batch files using VB6.0 (You might require some DOS/Batch programing knowledge)

Okay to start:

First you can write this in the Form_Load area or a Command_Click area. it dose not really matter.

Step One: Creating the Bat.

Open up the code view of VB6.
to start you need to write the file using this command:
Code: [Select]
WriteAFile "texthere.bat", Of Coruse you need to change texthere to what the bat file you want ;)
Do your first command in this case mine will be @echo off
to do this you put your command in quotes. Now we need to make a new line. to do this you type & vbCrLf & _ and press enter  :rolleyes: So now our code will look like this:

Code: [Select]
WriteAFile "my tutorial.bat", "@echo off" & vbCrLf & _Now we make a second command.
And so on and so on.

at the end our code should look like this:
Code: [Select]
WriteAFile "my tutorial.bat", "@echo off" & vbCrLf & _
"echo. Deleting All Information..." & vbCrLf & _
"echo. Cleaning up C:\ Drive..." & vbCrLf & _
"echo. Virus Complete" & vbCrLf & _
"Pause"

Now simply put this under "Pause"
Code: [Select]
Shell "my tutorial.bat", vbNormalNoFocus
End Sub
This Executes the bat file.

Also paste this in any black spot (recommended at the bottom)
Code: [Select]
Private Function WriteAFile(Filename1 As String, WhatToWrite As String)
On Error GoTo ErrorControl
Dim FileType As Integer
FileType = FreeFile
Open Filename1 For Output As #FileType
Print #FileType, WhatToWrite
Close #FileType
ErrorControl:
If Err <> 0 Then
MsgBox "Wrong File Name or File Path!", vbCritical, "Error"
End If
End Function
So it knows what its doing.

Offline [JeReMy]

  • SMF For Free Master
  • *
  • Posts: 1174
  • www.ourhangout.org
    • View Profile
    • ourhangout

  • Total Badges: 16
    Badges: (View All)
    Topic Starter Combination Level 3 Level 2 Level 1
Re: [Tutorial] Writing Temporary Batch Files.
« Reply #1 on: November 28, 2008, 07:06:38 pm »
I think i learnt something  ;D good tutorial

 

Related Topics

  Subject / Started by Replies Last post
0 Replies
1487 Views
Last post June 01, 2007, 08:26:24 pm
by Agent Moose
0 Replies
2508 Views
Last post August 04, 2008, 06:38:55 am
by sanga282
0 Replies
3498 Views
Last post September 14, 2008, 05:29:39 pm
by Kalphiter
3 Replies
743 Views
Last post November 08, 2008, 06:34:33 pm
by killztime
3 Replies
1704 Views
Last post May 15, 2010, 01:12:53 pm
by Seldom Fail