Sign in to follow this  
Followers 0
Caml Light

CMD: Filename or extension is too long

24 posts in this topic

Hi! My batch file must run on a single line, so i've added the '&' char after every command. Now my batch has not carriage returns. The only problem is that cmd.exe give me the error as from title. Have you suggestions?

Thanks

0

Share this post


Link to post
Share on other sites

Can you list your batch for us?

Cheers and Regards

0

Share this post


Link to post
Share on other sites

My batch is based on a old cmd script written by Yzöwl:

@ECHO OFF
ECHO=_%~1|FINDSTR/X "_-123456 _/123456">NUL 2>&1||GOTO Error
SETLOCAL ENABLEEXTENSIONS
SET "_="
PUSHD %~dp0
FOR /R %%A IN (Windows*-KB*.EXE) DO (
SET _=T
ECHO= Installation of %%~nA...
>NUL PING -n 4 127.0.0.1
"%%A" /quiet /norestart)
IF NOT DEFINED _ GOTO Error
ECHO=
ECHO= == Press any key to restart. ==
>NUL PAUSE
SHUTDOWN.EXE /r /t 0
GOTO :EOF
:Error
ECHO= Error.
ECHO=
ECHO= Press any key to exit...
>NUL PAUSE

My batch repeats the central part several times to install other software:

FOR /R %%A IN (Windows*-KB*.EXE) DO (
SET _=T
ECHO= Installation of %%~nA...
>NUL PING -n 4 127.0.0.1
"%%A" /quiet /norestart)

Converting it into a single line batch, results too long to execute for CMD.exe. Is there a solution to this limitation?

Thank you

Edited by Caml Light
0

Share this post


Link to post
Share on other sites

So why "must" your batch run on a single line? Maybe we can offer an alternative solution if we better understood the circumstances. ie instead of fixing the batch to work in a single line, we could come up with a solution so that you could run the batch in its original proven form.

Cheers and Regards

0

Share this post


Link to post
Share on other sites

Thank you for your support. Mainly the batch must be read (its content) by a authoring software. Once read, it is saved as variable by the authoring program, than executed as parameter of "CMD.exe". This method works if batch are not too long, because the batch become the parameter of CMD. Is there an alternative way to protect the batch, hiding its content? I also can host the batch on my website, in case of a valid "online protection". I've already bought a specific professional compiler, but during the execution of the compiled EXE, the batch is extracted into the %TEMP% folder, so it is useless.

Thank you

Edited by Caml Light
0

Share this post


Link to post
Share on other sites

Sorry, but I've never had to deal with hiding the batch in that way. Hopefully another member can offer some advice. Might it help if we knew the name of the authoring program or why you wanted to hide the batch's content?

Cheers and Regards

0

Share this post


Link to post
Share on other sites

I'm using powershell started from cmd.exe via a single line (registry shell extension). How many characters in yours, this one is 498 characters and does not throw me any error.

@ECHO OFF & cmd /k start /b powershell -command "clear-host;[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic');$INDEX = [Microsoft.VisualBasic.Interaction]::InputBox('Enter Image #', 'Which image to mount', '1');$PROMPT = [Microsoft.VisualBasic.Interaction]::MsgBox('Ready to mount image ?', 'OKCancel,Question', 'Last Chance to Cancel');switch ($PROMPT) {'OK'{Dism /mount-wim /wimfile:D:\sources\boot.wim /index:$INDEX /mountdir:C:\zMountDir}'Cancel'{exit}}" & PAUSE

On second thought, your script looks short but that %%A variable expands at runtime, the problem could be the expanded 'path' length being more than 256 characters, why not convert the %%A variable to 8.3 short naming before it loops.

Alternatively try encrypting your batch as an exe. Plenty of free-wares offer that agility.

Edited by MrJinje
0

Share this post


Link to post
Share on other sites

Most authoring language uses their own scripting language so maybe you should use it instead of using it to launch batch code.

Anyway if you need the loop part, this might work:

FOR /R %A IN (Windows*-KB*.EXE) DO ( SET _=T && ECHO= Installation of %~nA... && PING -n 4 127.0.0.1 >NUL && "%A" /quiet /norestart)

0

Share this post


Link to post
Share on other sites

I'm using powershell started from cmd.exe via a single line (registry shell extension). How many characters in yours, this one is 498 characters and does not throw me any error.

@ECHO OFF & cmd /k start /b powershell -command "clear-host;[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic');$INDEX = [Microsoft.VisualBasic.Interaction]::InputBox('Enter Image #', 'Which image to mount', '1');$PROMPT = [Microsoft.VisualBasic.Interaction]::MsgBox('Ready to mount image ?', 'OKCancel,Question', 'Last Chance to Cancel');switch ($PROMPT) {'OK'{Dism /mount-wim /wimfile:D:\sources\boot.wim /index:$INDEX /mountdir:C:\zMountDir}'Cancel'{exit}}" & PAUSE

On second thought, your script looks short but that %%A variable expands at runtime, the problem could be the expanded 'path' length being more than 256 characters, why not convert the %%A variable to 8.3 short naming before it loops.

Alternatively try encrypting your batch as an exe. Plenty of free-wares offer that agility.

I've already bought (paid version) a well-known batch compiler program, but it extracts the batch into the %TEMP% folder, so it's useless.

Most authoring language uses their own scripting language so maybe you should use it instead of using it to launch batch code.

Anyway if you need the loop part, this might work:

FOR /R %A IN (Windows*-KB*.EXE) DO ( SET _=T && ECHO= Installation of %~nA... && PING -n 4 127.0.0.1 >NUL && "%A" /quiet /norestart)

Do you know Multimedia Builder? I use that program. Anyway, my batch is very long, and with MMB i must create several Run("CMD","parameter$") commands (very bad), so i've choice to do it with a single Run command unifying the whole batch into a single line. But for CMD.exe that line is too long.

0

Share this post


Link to post
Share on other sites

Then you need to use the mmb manual to create a mmb script.

i use the program from some years, but i don't know how it could be possible to convert a batch into a MMB script. :huh:

EDIT: You've a PM ;)

Edited by Caml Light
0

Share this post


Link to post
Share on other sites

I've already bought a specific professional compiler, but during the execution of the compiled EXE, the batch is extracted into the %TEMP% folder, so it is useless.

You must have missed this before buying that (whatever it is) batch "compiler":

http://www.robvanderwoude.com/scriptcompilers.php

jaclaz

0

Share this post


Link to post
Share on other sites

I'm confused as to why your non secret updates installation routine being extracted, run and deleted from a default hidden location is considered 'useless'!

0

Share this post


Link to post
Share on other sites

I'm confused as to why your non secret updates installation routine being extracted, run and deleted from a default hidden location is considered 'useless'!

Because everyone can access to that folder and get the batch. I wish to hide the batch file. The world is big, not all people are skillful as you or other members of this community. :lol:

Anyway, for a UNskillful person, the %TEMP% folder is easy to get.

Edited by Caml Light
0

Share this post


Link to post
Share on other sites

I'm confused as to why your non secret updates installation routine being extracted, run and deleted from a default hidden location is considered 'useless'!

Because everyone can access to that folder and get the batch. I wish to hide the batch file. The world is big, not all people are skillful as you or other members of this community. :lol:

Anyway, for a UNskillful person, the %TEMP% folder is easy to get.

I guess the thing we are not understanding is why is it important to hide this batch that is being used to install updates? So what if an UNskillful person can get to the %TEMP% folder? What are you afraid that they will do with this non secret information? What is the big deal? For that matter, why hide it at all?

Cheers and Regards

0

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

  • Recently Browsing   0 members

    No registered users viewing this page.