Help - Search - Members - Calendar
Full Version: AutoIT help please?
MSFN Forums > Unattended Windows Discussion & Support > Application Installs

   


Google Internet Forums Unattended CD/DVD Guide
Mekrel
Hi, im trying to make a global command file launcher using AutoIT, I want it to just search for files and then pass them into the run command which hides the command files from launching.

I've got it working on a test setup, kinda. It the command files have not got a space in their name then they will get executed and run, but if they have they won't. I'm sure it is just to do with the run command and the placing of quotes so that the run command ends up having speech marks enclosing the command.

CODE
$search = FileFindFirstFile("*.cmd")  

While 1
    $file = FileFindNextFile($search)
    If @error Then ExitLoop
    
    Run("cmd.exe /c '" & $file & "'", "", @SW_HIDE)
WEnd

; Close the search handle
FileClose($search)


Any help will be appreciated!
MHz
You may have better luck with this
CODE
$search = FileFindFirstFile('*.cmd')  
If $search <> -1 Then
    While 1
        $file = FileFindNextFile($search)
        If @error Then ExitLoop
        RunWait(@ComSpec & ' /c "' & $file & '"', '', @SW_HIDE)
    WEnd
    FileClose($search); Close the search handle
EndIf

ComSpec likes double quotes, not singles, so using single quotes by default and use double quotes as needed within the string works well.

smile.gif

Also while I'm here, some other variations.

For au3 files (use AutoIt v3.2.0.1 or later)
CODE
$search = FileFindFirstFile('*.au3')  
If $search <> -1 Then
    While 1
        $file = FileFindNextFile($search)
        If @error Then ExitLoop
        If $file = @ScriptName Then ContinueLoop
        RunWait(@AutoItExe & ' /AutoIt3ExecuteScript "' & $file & '"')
    WEnd
    FileClose($search); Close the search handle
EndIf

or a Multi-FileType
CODE
$search = FileFindFirstFile('*.*')  
If $search <> -1 Then
    While 1
        $file = FileFindNextFile($search)
        If @error Then ExitLoop
        If $file = @ScriptName Then ContinueLoop
        Switch StringRight($file, 4)
            Case '.cmd'
                RunWait(@ComSpec & ' /c "' & $file & '"', '', @SW_HIDE)
            Case '.au3'
                RunWait(@AutoItExe & ' /AutoIt3ExecuteScript "' & $file & '"')
            Case '.vbs'
                RunWait(@SystemDir & '\WScript.exe "' & $file & '"')
        EndSwitch
    WEnd
    FileClose($search); Close the search handle
EndIf
Mekrel
Thanks very much, they work great smile.gif

Knew either you or Nologic would come to my rescue sooner or later.

I'm doing this so that I just add the compiled script to cmdlines.txt and then throw any batch files into said directory and I won't have to update anything.




Google Internet Forums Unattended CD/DVD Guide

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.