MichaelPracht Posted November 5, 2010 Author Posted November 5, 2010 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.
MichaelPracht Posted November 5, 2010 Author Posted November 5, 2010 And with that post, I have achieved "Member" status. Where's my cake?
JoHanatCent Posted November 5, 2010 Posted November 5, 2010 And with that post, I have achieved "Member" status. Where's my cake?Congrats!My post #19 is working don't know what OS are you in?
Richard Robertson Posted November 5, 2010 Posted November 5, 2010 (edited) Remove #RequireAdmin. Also, the Au3Wrapper codes only work if you have the full SciTE installation. Did you install this? http://www.autoitscript.com/autoit3/scite/downloads.shtml Edited November 5, 2010 by Richard Robertson
MichaelPracht Posted November 5, 2010 Author Posted November 5, 2010 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.
willichan Posted November 5, 2010 Posted November 5, 2010 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 scriptGFL.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 ExitMy generic config fileconfig.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 ;==>_MutexExistsand the installer (be sure to compile GFL.au3 before running this one)Install.au3FileInstall(".\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.) My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator, Enigma, CornedBeef Hash
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now