View Full Version : OS_Shell characters limit
TheInsider
13-02-2025, 00:04
Is the OS_Shell() function limited to using a command string of 255 characters or less? I am trying to send it a longer length command and it gets truncated at 255.
I am writing to a batch file as a workaround. But was wondering if there was a way around the limitation?
ErosOlmi
17-02-2025, 23:29
Ciao,
I do not limit input command string.
There must be a sub limitation somewhere in the calling chain.
What version of thinBasic and what operating system are you using?
Have you tried also Shell command from thinBasic Core engine to see if it makes any difference?
https://help.thinbasic.com/index.html?shell.htm
Eros
TheInsider
19-02-2025, 00:13
thinBasic_1.13.0.0.zip
running on:
Edition Windows 11 Pro
Version 23H2
Installed on 6/5/2024
OS build 22631.4460
Experience Windows Feature Experience Pack 1000.22700.1047.0
OK I put together a quick testing program, trying on two similar system, and got the same result. Basically, the OS_Shell function limits the length of the command to 255 characters, but the Shell core version does not. Am I doing something wrong here? Thank you Eros!
Uses "Console", "File", "OS"
dim temp$ as string
temp$ = REPEAT$(250, "1")
temp$ &= REPEAT$(250, "2")
PrintL "OS_Shell..."
OS_Shell("cmd.exe /c echo " & temp$, ,%OS_SHELL_SYNC)
Printl
PrintL "Shell core engine..."
Shell("cmd.exe", "/c echo " & temp$)
waitkey(60)
Stop
ErosOlmi
19-02-2025, 20:09
mmmm strange results here
Thanks for the example.
I've to test on different systems and try understand why here it's giving different results when the internal command is the same.
Limit should be around 32K for command line
Will let you know.
ErosOlmi
20-02-2025, 00:55
Please find attached a new thinBasic_OS.dll module
Please unzip in the same folder of your script so thinBasic Core Engine will load local local version of the module instead of the one in \thinBasic\Lib\
I've completely recoded OS_Shell function using the same WIN32 API used in Core Shell function: CreateProcessA (https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessasusera)
Let me know
Ciao
Eros
TheInsider
21-02-2025, 23:31
Thank you so much. I finished the script I was working on, and it is working great with the new .dll
The reason that my command line string is so long is because it is for the FFmpeg.exe audio processor. The arguments plus the pathnames end up at a ridiculous length, like 350 chrs. :cry: