Sign in to follow this  
Followers 0
james3mg

$CmdLine limits?

17 posts in this topic

I wrote a script which I compiled and stuck in my Windows XP user SendTo folder. I run it by highlighting a group of (usually .jpg) files, then right-clicking on them and choosing to Send To -> my script. The script takes the files' paths which it is passed, doubles the folder slashes (c:\this becomes c:\\this) and stores one path per line in a text file where I choose (via FileOpen(FileSaveDialog()) commands within the script, then FileWriteLine 'ing each element from within a for-next loop).

I have found that I get a message informing me that "Windows cannot access the specified device, path or file. You may not have appropriate permissions to access the item" if I select more than 26 files at a time. The paths of the 26 files come to a total of 2,056 characters, and are naturally called within the script via the $CmdLine[] array, which must have 27 elements, with [0] containing the number 26 - the number of files passed.

I can't find a reason for this error - I assumed that there was a limit in AutoIt that I was reaching, but it's not an array limit, string limit, variable limit, or anything that I can find. And it's not a permission issue - when I select fewer files, it runs fine.

Any ideas?

Thanks


"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I wrote a script which I compiled and stuck in my Windows XP user SendTo folder. I run it by highlighting a group of (usually .jpg) files, then right-clicking on them and choosing to Send To -> my script. The script takes the files' paths which it is passed, doubles the folder slashes (c:\this becomes c:\\this) and stores one path per line in a text file where I choose (via FileOpen(FileSaveDialog()) commands within the script, then FileWriteLine 'ing each element from within a for-next loop).

I have found that I get a message informing me that "Windows cannot access the specified device, path or file. You may not have appropriate permissions to access the item" if I select more than 26 files at a time. The paths of the 26 files come to a total of 2,056 characters, and are naturally called within the script via the $CmdLine[] array, which must have 27 elements, with [0] containing the number 26 - the number of files passed.

I can't find a reason for this error - I assumed that there was a limit in AutoIt that I was reaching, but it's not an array limit, string limit, variable limit, or anything that I can find. And it's not a permission issue - when I select fewer files, it runs fine.

Any ideas?

Thanks

rather than using the send to, why not have the script open a FileOpenDialog() and then select the files there?

rather than using 'send to' you can set a key in your registry (i'll look up which and let you know in a min) so that when you right click on a file or folder, you can add your own right click commands. so then you could just right click on a folder and choose 'my script' then have your script called with the path of the selected file, and open up a fileopendialog for that directory. Would that be an acceptable work around to the issue?

***edit*** if you want to add a right click option for when you click on a folder, add this to registry (this is the key location in my xp registry, may vary with your OS)

HKEY_CLASSES_ROOT\Folder\shell\My Script\Command

the 'My Scrypt' is what shows on the right click, and the value for Command would be :

%SystemRoot%\Path To Script\script.exe <argument>

Edited by cameronsdad

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Yes, it's possible to do it that way, ** edit: The first way you mentioned: choosing the files from within the script /edit** but then I'd have to have a shortcut on my quick launch or start menu for launching the script, and it's just one additional window to go through. I like launching from explorer because I can easily see the pictures I want in thumbnail view. I know I can change the view manually from within the Open dialog, but that's just more steps again. **edit: I can't put in the folder context menu because I need to pick-and-choose the files I want, and I don't want to put it in the .jpg context menu because it's more than just .jpgs I need to be able to do this with...I don't even know all the files I may need it for eventually /edit**

I'd perfer knowing what limit I was running into before I completely re-think the script's process. Or if I knew what limit I'm running over, I could just check for that within the script so it gives a helpful error message and/or launches another instance of itself with the remainder...I just can't find any limit I'm running over that I could check for.

BTW, it would have been helpful to put this out there at first, but I'm using beta .68. Not the latest yet as I haven't checked all my scripts with the new betas yet...there was a time sometime in the late .70s or early .80s that my scripts were breaking, so I haven't upgraded yet. Seems like .100 is working better, but I want to be sure before I upgrade once and for all.

Thanks.

**Another edit:

I moved some pictures from my desktop (as you know, XP desktop is c:\documents and settings\username\desktop ... a long path) into a folder right on my c:\ root to make each of the files' paths shorter. When I did that I found I could get as many as 55 files to sucessfully "Send To" my script. That means it's not an array length limit, it's actually a string limit of what's getting sent. When I check the length of the string now, it's still around 2000 (word reports 1956 characters, but I realized that number is after the double slashes are substituted, so it's actually more like right at 1900, if you take out 2 extra characters per line and put back in one space per line seperating each of the parameters). So that's a pretty similar length at which it starts breaking. Is there a XP commandline length limit?

Edited by james3mg

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

Yes, it's possible to do it that way, but then I'd have to have a shortcut on my quick launch or start menu for launching the script, and it's just one additional window to go through. I like launching from explorer because I can easily see the pictures I want in thumbnail view. I know I can change the view manually from within the Open dialog, but that's just more steps again.

I'd perfer knowing what limit I was running into so I know that I absolutely must re-think the script process first. Or if I knew what limit I'm running over, I could just check for that within the script so it gives a helpful error message and/or launches another instance of itself with the remainder...I just can't find any limit I'm running over.

BTW, it would have been helpful to put this out there at first, but I'm using beta .68. Not the latest yet as I haven't checked all my scripts with the new betas yet...there was a time sometime in the late .70s or early .80s that my scripts were breaking, so I haven't upgraded yet. Seems like .100 is working better, but I want to be sure before I upgrade once and for all.

Thanks.

actually the registry setting is what would launch your script, like when you install scite, a registry entry is added to create a action for the autoit file association, that's why if you right click on an .au3 you can choose TIDY. and it runs the tidy script on the script you right clicked on.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

actually the registry setting is what would launch your script, like when you install scite, a registry entry is added to create a action for the autoit file association, that's why if you right click on an .au3 you can choose TIDY. and it runs the tidy script on the script you right clicked on.

Right...please see my unfortunately proliferate edits above...I don't know all the file types I may need that association added to


"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

From http://www.ss64.com/nt/cmd.html:

Under Windows NT, the command line is limited to 256 characters.

Under Windows 2000, the command line is limited to 2046 characters.

Under Windows XP, the command line is limited to 8190 characters.

...

A workaround for the limited pathname length is to prefix \\?\

for example:

\\?\C:\TEMP\Long_Directory\Long_Filename.txt

So I don't know how to prefix \\?\ to the program path unless I called it from the context menu via the registry as you suggested, I suppose I could get most of the file types if it came to that, but my script is breaking at around 2000, not 8000 as suggested is XP's capabilities...does anyone know if this number is correct? Maybe AutoIt has an undocumented Command length limit - has this been found by anyone else?


"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

Right...please see my unfortunately proliferate edits above...I don't know all the file types I may need that association added to

ah, i think i was posting when you were posting your edits. Without seeing your script, i can't give you a code solution, BUT you could still add the following keys to do use the right click solution per type...

HKEY_CLASSES_ROOT\jpegfile\shell\my script\command\Default = %SystemRoot%\yourscript.exe /jpg %1

that would call your script with the arguments /jpg (indicating it's a jpg) and the file name. that line would add the 'my script' command to the menu whenever you're right clicking on a jpg file. You could similarly do the same for the

HKEY_CLASSES_ROOT\giffile\shell\my script\command\Default, and any other file type. it would require 1 line of code per file type, or if you have a graphics program that changes associations, you may be able to just change a single key if the file associations have been changed to like 'image file' or something like that. some graphics editors will set those associations so that all of the types they can edit are changed to a single file association, so that they can allow you to right click and choose 'edit with blah'. it seems like they'd save time by adding a command for each of the file types, rather than changing the association for each and then making a single right click key for all of them, but what do i know.


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

From http://www.ss64.com/nt/cmd.html:

So I don't know how to prefix \\?\ to the program path unless I called it from the context menu via the registry as you suggested, I suppose I could get most of the file types if it came to that

if you do choose to go that way, you may want to hold off for a little while, while posting about how easy this would be, i've decided to make a udf allowing people to create right click menus for whatever files they want... i should have it done by the end of my work day.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

1100111 0000101

1101111 0001110

1101111 0001011

1100100 0000111

1110100 0011011

1110010 0010110

1111001 0011100

goodtry...what? ;) looks fun, but I'm at a loss... :lmao:

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

goodtry...what? ;) looks fun, but I'm at a loss... :lmao:

goodtry means you didn't get it

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

goodtry means you didn't get it

no kidding :lmao:

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

You could try using Fast Explorer <http://thesoftpro.tripod.com/downloads/fe/>.

It is a shell extension for displaying context menu items with extra features like submenus and icons, I was able to pass a command line of at least 200 files to an autoit3 script from it.

When using it's gui configuration program make sure to click the "Submenu Items" tab and select "Enable Dynamic Items" as putting items on the "Static Items" tab will just use the standard Explorer context menu that appears to only support 1 file at a time.

I use this program with my Picture Resizing script.

Justin

Share this post


Link to post
Share on other sites

AutoIt's limits on the command line internally enforced are no more than 64 elements and each element is allowed to be no longer than 4096 characters. So that means the total AutoIt supported length is 64 * 4096. However, Windows has a limit, too. I don't know what Window's limitations are but I'm sure that's what you are running into.

Share this post


Link to post
Share on other sites

That post was pretty informative, at least that it's not my script, and come to think of it, the error is a windows error, not an AutoIt error, so there's no way to code for it since the program hasn't even launched. I tried what the suggested and compiled the following code:

; this does nothing

and dragged the files to the resulting .exe file - same error. So there you go, I guess I'll have to have a 'select files' dialog once the program is launched. I'm sure I can think of some creative way to do that and still be happy with the result :lmao:


"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

That post was pretty informative, at least that it's not my script, and come to think of it, the error is a windows error, not an AutoIt error, so there's no way to code for it since the program hasn't even launched. I tried what the suggested and compiled the following code:

; this does nothing

and dragged the files to the resulting .exe file - same error. So there you go, I guess I'll have to have a 'select files' dialog once the program is launched. I'm sure I can think of some creative way to do that and still be happy with the result :lmao:

I just tested using sendto to launch an autoit3 script and I think the limit being reached here isn't the windows command line limit but rather a limit with the builtin sendto shell extension as I was able to pass a max of 299 files with the Fast Explorer shell extension I mentioned above and only 18 using the builtin sendto shell extension.

Justin

Edit:

I used the following windows and program versions when testing the above:

OS: Windows XP SP2

AutoIt3: 3.1.1.99

Fast Explorer: 2.1.7

Edited by JD2066

Share this post


Link to post
Share on other sites

if you do choose to go that way, you may want to hold off for a little while, while posting about how easy this would be, i've decided to make a udf allowing people to create right click menus for whatever files they want... i should have it done by the end of my work day.

Ok, here's the script to just add a quick right click item to any file type. I'm making a better one (gui, more features) for scripts and scraps, but this one is just a real quick script to show what i mean. (it does work though)

#include<file.au3>
$file = FileOpenDialog("Select a file to set an association for that type","c:\","All Files(*.*)")
Dim $szDir,$szDrive,$szFName,$szExt
$TestPath = _PathSplit($file, $szDrive, $szDir, $szFName, $szExt)
$i = 1
while 1
$var = RegEnumKey("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\",$i)
If $var = "" Then ExitLoop
If $var = $szExt Then
$var2 = RegEnumVal("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & $var & "\OpenWithProgids",1)
EndIf
$i = $i +1
WEnd
$Command = InputBox("Command","Enter command that you would like displayed on the right click menu."  )
$todo = InputBox("To do","Enter the command that you would like executed when your menu option is selected.",Chr(34) & "notepad.exe" & Chr(34) & " " & Chr(34) & "%1" & Chr(34))
RegWrite("HKEY_CLASSES_ROOT\" & $var2 & "\Shell\" & $Command & "\Command\",'',"REG_SZ",$todo)

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0