Jump to content

Recommended Posts

Posted (edited)

code:

$search = FileFindFirstFile("c:\temp")

If $search = -1 Then

MsgBox(0, "Error", "No files/directories matched the search pattern")

Exit

EndIf

While 1

$file = FileFindNextFile($search)

If @error Then ExitLoop

FileChangeDir ( "C:\TEMP\"& $file )

RunWait(@COMSPEC & " /c SNACFG #com.cfg /PRINT >COM.TXT")

WEnd

FileClose($search)

it can'nt work ,how should i do ?

thanks!

Edited by kkman360
Posted

code:

$search = FileFindFirstFile("c:\temp")

If $search = -1 Then

MsgBox(0, "Error", "No files/directories matched the search pattern")

Exit

EndIf

While 1

$file = FileFindNextFile($search)

If @error Then ExitLoop

FileChangeDir ( "C:\TEMP\"& $file )

RunWait(@ComSpec & " /c " & SNACFG #com.cfg /PRINT >COM.TXT, "", @SW_HIDE)

WEnd

FileClose($search)

it can'nt work 1how should i do ?

thanks!

your findfirstfile just search for the file or directory temp.

So it is normal that the FileFindnextFile will not find anything else. :think:

Posted

your findfirstfile just search for the file or directory temp.

So it is normal that the FileFindnextFile will not find anything else. :think:

i have 1200 folders in temp

i want go to each folder and do snacfg /print >com.txt

how should i do ?

i use

RunWait(@COMSPEC & " /c SNACFG #com.cfg /PRINT >COM.TXT")

and it can work.but don't chang the path .

thank for your reply so fast !

Posted

Here is a variation to your script.

If FileChangeDir("c:\temp") Then
    $search = FileFindFirstFile("*") 
    If $search <> -1 Then
        While 1
            $file = FileFindNextFile($search) 
            If @error Then ExitLoop
            If $file = '.' Or $file = '..' Then ContinueLoop
            If FileChangeDir($file) Then
                RunWait(@ComSpec & " /c SNACFG #com.cfg /PRINT >COM.TXT", @WorkingDir, @SW_HIDE)
                FileChangeDir('..')
            EndIf
        WEnd
        FileClose($search)
    Else
        MsgBox(0, "Error", "No files/directories matched the search pattern")
        Exit
    EndIf
EndIf

The working directory is the temp directory and each file/folder found will be tested with FileChangeDir. Success will execute you Run() function and change directory up a level again. And will just keep looping until the end.

Posted

Here is a variation to your script.

If FileChangeDir("c:\temp") Then
    $search = FileFindFirstFile("*") 
    If $search <> -1 Then
        While 1
            $file = FileFindNextFile($search) 
            If @error Then ExitLoop
            If $file = '.' Or $file = '..' Then ContinueLoop
            If FileChangeDir($file) Then
                RunWait(@ComSpec & " /c SNACFG #com.cfg /PRINT >COM.TXT", @WorkingDir, @SW_HIDE)
                FileChangeDir('..')
            EndIf
        WEnd
        FileClose($search)
    Else
        MsgBox(0, "Error", "No files/directories matched the search pattern")
        Exit
    EndIf
EndIf

The working directory is the temp directory and each file/folder found will be tested with FileChangeDir. Success will execute you Run() function and change directory up a level again. And will just keep looping until the end.

thank you very much !it work fine.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...