PDA

View Full Version : MS DOS Bat files


webdreamer
11-08-2001, 12:31 PM
Does anyone know how to edit a files using commands in a batch file, so i can run the file and let it do all the work
Thanks

coolsights2000
11-08-2001, 01:58 PM
you can use notepad to edit a batch file just rght click and pick edit or open with

give the room some more info what are you trying to change or do cause there is all kinds of batch files

Thanks
Mac!!!

This Is just my opinion
So if it stinks wait for another one
Cause I'm no expert

webdreamer
11-08-2001, 02:10 PM
I want to edit the autoexec.bat from a batch file without having to open it with the command edit
thanks

coolsights2000
11-08-2001, 02:16 PM
one way that I know of is you could use VB to read the file in then work on it and resave the new file and leave a backup behind

It gets kind of involved cause you have to code in stuff to take into account for all kinds of stuff....
errors included........

Do you have VB

P.S Dos commands are more for moving and working with files on the drives... you will have to move up to do what you want



Thanks
Mac!!!

This Is just my opinion
So if it stinks wait for another one
Cause I'm no expert<P ID="edit"><FONT class="small">Edited by coolsights2000 on 11/08/01 08:24.</FONT></P>

webdreamer
11-08-2001, 02:26 PM
yes I have VB but dont know any programming

coolsights2000
11-08-2001, 02:35 PM
That is what it is going to take to do what you want I guess it is time for a tangent unless somebody has a better idea

This is one sub of what I wrote to chop some mail up that I save in access.........

This has allot of areas to figure out
Once you understand what is going on here you will be ready!!!!!!!!!!!!

Please don't take wrong room this is just an example of!!!!!! and it didn't save my indents tab
it looks pretty with the idents

Private Sub Btn_GetMailFromOutlookInbox_Click()
Dim X, Y, Z As Integer
Dim oApp As Outlook.Application
Dim oNameSpace As NameSpace
Dim oFolder As MAPIFolder
Dim oMailItem As Object
Set FileSystem = CreateObject("Scripting.FileSystemObject")
Set oApp = New Outlook.Application
Set oNameSpace = oApp.GetNamespace("MAPI")
Set oFolder = oNameSpace.GetDefaultFolder(olFolderInbox)
For Each oMailItem In oFolder.Items
If oMailItem.SenderName &lt;&gt; "ExamCram.com" Then GoTo metTliamtxen
oMailItem.SaveAs SaveToMainFolder & "Temp.Tmp", 2
If FileSystem.FolderExists(SaveToMainFolder) =False Then
FileSystem.CreateFolder (SaveToMainFolder)
End If
Set File =FileSystem.GetFile(SaveToMainFolder & "Temp.Tmp")
Set TextStream =File.OpenAsTextStream(ForReading, TristateUseDefault)
DashesCounter =0 Do While TextStream.AtEndOfStream &gt;&lt;&gt; True
InputMemoText =TextStream.readline If IsNull(InputMemoText) Then GoTo MailToCheck
If Trim(InputMemoText) ="" Then GoTo MailToCheck
InputMemoTextLen =Len(InputMemoText) For X =1 To InputMemoTextLen
If Mid$(InputMemoText, X, ListUnsubscribeConstLen) =ListUnsubscribeConst Then
For Y =X + ListUnsubscribeConstLen To InputMemoTextLen
If Mid$(InputMemoText, Y, 1) ="@" Then
SaveToFilenameText =Mid$(InputMemoText, X + ListUnsubscribeConstLen, Y - (X + ListUnsubscribeConstLen))
For Z =Len(SaveToFilenameText) To 1 Step -1
If Mid$(SaveToFilenameText, Z, 1) ="-" Then
SaveToFilenameText =Mid$(SaveToFilenameText, 1, Z - 1)
Exit For
End If
Next Z
RidaSpace ="" For Z =RemoveQusetionConstLen + 1 To Len(oMailItem.Subject)
Select Case Mid$(oMailItem.Subject, Z, 1)
Case " ", Chr(13), Chr(10)
'space skip
Case Else
RidaSpace =RidaSpace + Mid$(oMailItem.Subject, Z, 1)
End Select
Next Z
SaveToFilenameText =RidaSpace & " " & SaveToFilenameText
For Z = 1 To Len(SaveToFilenameText)
Select Case Mid$(SaveToFilenameText, Z, 1)
Case "\", "/", ":", ".", "*", "?", "|", "&gt;", "&gt;&lt;", Chr(34)
SaveToFilenameText =Left$(SaveToFilenameText, Z - 1) & "_" & Right$(SaveToFilenameText, Len(SaveToFilenameText) - Z)
End Select
Next Z
SaveToFilenameText = SaveToFilenameText & SaveToFilenameTextExt
DashesCounter = 1
Exit Do
End If
Next Y
End If
Next X
MailToCheck:
Loop
TextStream.Close
If DashesCounter = 0 Then GoTo Invalid_metTliamtxen
InputMemoText = oMailItem.Body
InputMemoTextLen = Len(InputMemoText)
DashesCounter = 0
For X = 1 To InputMemoTextLen
If Mid$(InputMemoText, X, DashesConstLen) = DashesConst Then
DashesCounter = DashesCounter + 1
Select Case DashesCounter
Case 4
StartDashLine4 = X
Case 5
StartDashLine5 = X
Case 6
StartDashLine6 = X
InputMemoDate = Mid$(InputMemoText, StartDashLine4 + DashesConstLen + 2, StartDashLine5 - (StartDashLine4 + DashesConstLen + 2))
InputMemoChecker = Right$(InputMemoText, InputMemoTextLen - (StartDashLine6 + DashesConstLen))
InputMemoText = Mid$(InputMemoText, StartDashLine4 + DashesConstLen + 2, StartDashLine6 - (StartDashLine4 + DashesConstLen + 2))
Exit For
End Select
End If
Next X
If DashesCounter &lt;&gt; 6 Then GoTo Invalid_metTliamtxen
DashesCounter =0 For X =1 To Len(InputMemoText)
If (Mid$(InputMemoText, X, CorrectAnswerConstLen) =CorrectAnswerConst) And (DashesCounter =0) Then
DashesCounter =DashesCounter + 1
End If
If (Mid$(InputMemoText, X, ExplanationConstLen) =ExplanationConst) And (DashesCounter =1) Then
DashesCounter =DashesCounter + 1
End If
If (Mid$(InputMemoText, X, QIDConstLen) =QIDConst) And (DashesCounter =2) Then
DashesCounter =DashesCounter + 1
End If
Next X
If DashesCounter &gt;&lt;&gt; 3 Then GoTo Invalid_metTliamtxen
DashesCounter =0 For X =Len(InputMemoChecker) To 1 Step -1
If Mid$(InputMemoChecker, X, DashesLongConstLen) =DashesLongConst Then
DashesCounter =DashesCounter + 1
Y =X End If
Next X
If DashesCounter =2 Then
For X =1 To Y
If Mid$(Mid$(InputMemoChecker, 1, Y), X, DashesShortConstLen) =DashesShortConst Then
DashesCounter =DashesCounter + 1
End If
Next X
End If
If DashesCounter &gt;&lt;&gt; 3 Then GoTo Invalid_metTliamtxen
For X =Len(InputMemoDate) To 1 Step -1
Select Case Mid$(InputMemoDate, X, 5)
Case " Jan ", " Feb ", " Mar ", " Apr ", " May ", " Jun ", " Jul ", " Aug ", " Sep ", " Oct ", " Nov ", " Dec "
InputMemoDate =Right$(InputMemoDate, Len(InputMemoDate) - X)
On Error GoTo InputMemoDate_ERROR
InputMemoDate =Format(CDate(InputMemoDate), "yy mm dd")
DashesCounter =0 InputMemoDate_ERROR_resume:
On Error GoTo 0
Exit For
End Select
Next X
If DashesCounter &gt;&lt;&gt; 0 Then GoTo Invalid_metTliamtxen
On Error GoTo CreateFolder_ERROR
If FileSystem.FolderExists(SaveToMainFolder) =False Then
FileSystem.CreateFolder (SaveToMainFolder)
End If
If FileSystem.FolderExists(SaveToMainFolder & InputMemoDate) = False Then
FileSystem.CreateFolder (SaveToMainFolder & InputMemoDate)
End If
Response = IDYES
On Error Resume Next
FileSystem.CreateTextFile SaveToMainFolder & InputMemoDate & "\" & SaveToFilenameText, False
If Err.Number = 0 Then GoTo BYPASS1
On Error GoTo 0
Msg = "Yes -&gt; Overwrite" & Chr(10) & Chr(13)
Msg = Msg & "No -&gt; Pick a new file name" & Chr(10) & Chr(13)
Msg = Msg & "Cancel -&gt; Do not save now" & Chr(10) & Chr(13)
Msg = Msg & SaveToMainFolder & InputMemoDate & "\" & SaveToFilenameText
Title = "File Exists already do you want to overwrite!"
DgDef =MB_YESNOCANCEL + MB_ICONQUESTION + MB_DEFBUTTON2
Response =MsgBox(Msg, DgDef, Title)
BYPASS1:
Select Case Response
Case IDNO
On Error GoTo 0
Dim OFN As OpenFilename
On Error Resume Next
With OFN
.lStructSize =Len(OFN) .hwndOwner =Me.hwnd .lpstrFilter ="Text Files (*.txt)" & vbNullChar & "*.txt" & vbNullChar & _
"All Files (*.*)" & vbNullChar & "*.*" & vbNullChar & vbNullChar
.lpstrFile = SaveToFilenameText & String$(255 - Len(SaveToFilenameText) + 1, vbNullChar)
.nMaxFile = Len(.lpstrFile)
.Flags = OFNFlagsEnum.OFN_OVERWRITEPROMPT + OFNFlagsEnum.OFN_HIDEREADONLY
.lpstrInitialDir = SaveToMainFolder & InputMemoDate & "\" & SaveToFilenameText
.lpstrDefExt = "Txt"
End With
If GetSaveFileName(OFN) Then
On Error GoTo CreateFolder_ERROR2
FileSystem.CreateTextFile OFN.lpstrFile
Set File =FileSystem.GetFile(OFN.lpstrFile) On Error GoTo WriteDrive_ERROR2
Set TextStream =File.OpenAsTextStream(ForWriting, TristateUseDefault)
TextStream.Write InputMemoText
WriteDrive_ERROR_resume2:
TextStream.Close
CreateFolder_ERROR_resume2:
Else
Response =IDCANCEL Msg ="This question will not be saved you cancel so keep track of it" & Chr(10) & Chr(13)
Msg = Msg & SaveToMainFolder & InputMemoDate & "\" & SaveToFilenameText
MsgBox Msg
End If
Case IDCANCEL
On Error GoTo 0
Msg = "This question will not be saved you cancel so keep track of it" & Chr(10) & Chr(13)
Msg = Msg & SaveToMainFolder & InputMemoDate & "\" & SaveToFilenameText
MsgBox Msg
Case IDYES
On Error GoTo CreateFolder_ERROR
FileSystem.CreateTextFile SaveToMainFolder & InputMemoDate & "\" & SaveToFilenameText
Set File = FileSystem.GetFile(SaveToMainFolder & InputMemoDate & "\" & SaveToFilenameText)
On Error GoTo WriteDrive_ERROR
Set TextStream = File.OpenAsTextStream(ForWriting, TristateUseDefault)
TextStream.Write InputMemoText
WriteDrive_ERROR_resume:
TextStream.Close
CreateFolder_ERROR_resume:
On Error GoTo 0
End Select
GoTo metTliamtxen
Invalid_metTliamtxen:
MsgBox "This Email " & oMailItem.Subject & " Doesn't have standard section please check later and resubmit"
metTliamtxen:
Next oMailItem
Set oMailItem =Nothing Set oFolder =Nothing Set oNameSpace =Nothing Set oApp =Nothing Exit Sub
CreateFolder_ERROR:
MsgBox Err.Description & "1"
MsgBox "This was the Email " & oMailItem.Subject & " please check later and resubmit"
Resume CreateFolder_ERROR_resume
WriteDrive_ERROR:
MsgBox Err.Description & "2"
Resume WriteDrive_ERROR_resume
CreateFolder_ERROR2:
MsgBox Err.Description & "3"
MsgBox "This was the Email " & oMailItem.Subject & " please check later and resubmit"
Resume CreateFolder_ERROR_resume2
WriteDrive_ERROR2:
MsgBox Err.Description & "4"
Resume WriteDrive_ERROR_resume2
InputMemoDate_ERROR:
MsgBox Err.Description & "5"
Resume InputMemoDate_ERROR_resume
End Sub&gt;

Thanks
Mac!!!

This Is just my opinion
So if it stinks wait for another one
Cause I'm no expert