Hirdetés

Új hozzászólás Aktív témák

  • sztanozs
    veterán

    szeretnék egy script-et, ami végig pörget - mondjuk - egy txt fájlt és megmondja, hogy a bevitt érték megtalálható e az adott txt fájlban:

    @echo off

    set /p szam=
    findstr /c:'%szam%' szamok.txt
    if %errorlevel% equ 1 goto hamis
    echo igaz
    goto kesz
    :hamis
    echo hamis
    goto kesz
    :kesz

    pause

    stackoverflow-ról halásztam ezt, nálam valamiért mégsem akar működni....

    egyébként a legjobb az volna, ha excel-ből dolgozna, illetve a bevitel is ctrl+c > ctrl+v módon történhetne, ergó grafikus volna...ez viszont gondolom innentől már vbscript

    Az Excelből dolgozna-t hogy képzeled el?

    vbs-sel:
    If UCase( Right( WScript.FullName, 12 ) ) = "\CSCRIPT.EXE" Then
    wscript.echo "Please copy the script to the Desktop and drag a file to the script icon"
    wscript.quit -1
    End If
    if WScript.Arguments.Count() <> 1 Then
    wscript.echo "Please drag a file to the script icon"
    wscript.quit -1
    End If
    filename = WScript.Arguments(0)
    searchstring = InputBox("Search:")

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.OpenTextFile(filename)

    lineno = 1
    lines = ""
    Do Until f.AtEndOfStream
    line = f.ReadLine
    If InStr(line, searchstring) > 0 Then
    lines = lines & lineno & vbTab & line & vbCrLf
    End If
    lineno = lineno + 1
    Loop
    f.Close

    If lines <> "" Then
    wscript.echo lines
    Else
    wscript.echo searchstring & " not found"
    End If

Új hozzászólás Aktív témák