Jump to content

Recommended Posts

Posted

If you change your program to accept command line arguments, you can run it from a batch file placed anywhere in your system's path, such as the Windows\System32. In your batch file that you use to run your program, add the command line argument %CD% and that will be translated to the current folder that you are running the batch file from.

Example batch file:

dir "%cd%"

This will give you a directory listing of all files in the current directory.

This would probably work, but my goal is to hand one compiled executable over to users.
Posted

Alas, that seems to be the solution! Thanks Richard.

I implemented the script in VB since I wasn't able to get this to work. I may convert it back to AutoIt when I have some time.

My thanks to all who tried to, and especially to those who eventually were able to help.

Posted

One of my clients needed something similar. This is what I made for her.

It allows you to right click on any folder (mapped, url, or shortcut to), and have a text file generated on the desktop for it.

with only slight modification, you can have it create the file in the folder instead.

The main script

GFL.au3

#include <config.au3>
#include <file.au3>

Dim $Outfile, $files, $i
$Outfile = @DesktopDir & "\filelist.txt"

If $CmdLine[0] = 0 Then Exit
If FileExists($Outfile) Then FileDelete($Outfile)

FileWriteLine($Outfile, 'Contents of "' & $CmdLine[1] & '"')
FileWriteLine($Outfile, "")
FileWriteLine($Outfile, "******** Subfolders List ********")
;output folders list here
Local $folders = _FileListToArray($CmdLine[1], "*", 2)
If IsArray($folders) Then
    For $i = 1 To $folders[0]
        FileWriteLine($Outfile, $folders[$i])
    Next
EndIf
FileWriteLine($Outfile, "")
FileWriteLine($Outfile, "")
FileWriteLine($Outfile, "******** File List ********")
;output files list here
Local $files = _FileListToArray($CmdLine[1], "*", 1)
If IsArray($files) Then
    For $i = 1 To $files[0]
        FileWriteLine($Outfile, $files[$i])
    Next
EndIf
Exit

My generic config file

config.au3

#include-once

Opt("MustDeclareVars", 1)        ;0=no, 1=require pre-declare
Opt("TrayAutoPause",   0)        ;0=no pause, 1=Pause
Opt("TrayMenuMode",    0)        ;0=append, 1=no default menu, 2=no automatic check, 4=menuitemID  not return
Opt("TrayIconHide",    0)        ;0=show, 1=hide tray icon

Global Const $MyName=StringLeft(@ScriptName, StringInStr(@ScriptName,".", 0, -1)-1) ;get just the name portion of the script/exe name
Global Const $MyMutex=$MyName & "-E9DEA1A0322622B9" ;name the mutex for this app
If _MutexExists($MyMutex) Then Exit ;exit if another instance of this app is running

_ConfigInitialize()

Func _ConfigInitialize()
    OnAutoItExitRegister("_ConfigDestroy")
    ;initializers here for script startup
EndFunc  ;==>_ConfigInitialize

Func _ConfigDestroy()
    ;destructors here for script shutdown/cleanup
EndFunc  ;==>_ConfigDestroy

Func _MutexExists($sOccurenceName)
    ;Credit goes to martin for this function
    Local $ERROR_ALREADY_EXISTS = 183, $handle, $lastError
    $sOccurenceName = StringReplace($sOccurenceName, "\", "")
    $handle = DllCall("kernel32.dll", "int", "CreateMutex", "int", 0, "long", 1, "str", $sOccurenceName)
    $lastError = DllCall("kernel32.dll", "int", "GetLastError")
    Return $lastError[0] = $ERROR_ALREADY_EXISTS
EndFunc  ;==>_MutexExists

and the installer (be sure to compile GFL.au3 before running this one)

Install.au3

FileInstall(".\GFL.EXE", @WindowsDir & "\GFL.exe", 1)
RegWrite("HKEY_CLASSES_ROOT\Directory\shell\cmd1")
RegWrite("HKEY_CLASSES_ROOT\Directory\shell\cmd1", "", "REG_SZ", "Get folder contents")
RegWrite("HKEY_CLASSES_ROOT\Directory\shell\cmd1\command")
RegWrite("HKEY_CLASSES_ROOT\Directory\shell\cmd1\command", "", "REG_SZ", 'GFL.exe "%L"')

Its may be overly simplistic, but it was exactly what she was asking for. Hopefully it will be of help to you too. (Posted here with her permission, of course. Seeing as she paid for it.)

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...