MSFN Forum: CMD: Filename or extension is too long - MSFN Forum

Jump to content


  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

CMD: Filename or extension is too long Rate Topic: -----

#1 User is offline   Caml Light 

  • Junior
  • Pip
  • Group: Members
  • Posts: 85
  • Joined: 03-October 03

Posted 16 September 2012 - 12:23 PM

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


#2 User is offline   bphlpt 

  • MSFN Expert
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,075
  • Joined: 12-May 07

Posted 16 September 2012 - 06:37 PM

Can you list your batch for us?

Cheers and Regards

#3 User is offline   Caml Light 

  • Junior
  • Pip
  • Group: Members
  • Posts: 85
  • Joined: 03-October 03

Posted 16 September 2012 - 07:14 PM

My batch is based on a old cmd script written by Yzöwl: http://www.msfn.org/...mp/page__st__20

@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

This post has been edited by Caml Light: 16 September 2012 - 07:16 PM


#4 User is offline   bphlpt 

  • MSFN Expert
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,075
  • Joined: 12-May 07

Posted 16 September 2012 - 09:03 PM

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

#5 User is offline   Caml Light 

  • Junior
  • Pip
  • Group: Members
  • Posts: 85
  • Joined: 03-October 03

Posted 16 September 2012 - 09:45 PM

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

This post has been edited by Caml Light: 16 September 2012 - 10:00 PM


#6 User is offline   bphlpt 

  • MSFN Expert
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,075
  • Joined: 12-May 07

Posted 16 September 2012 - 10:13 PM

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

#7 User is offline   MrJinje 

  • Tool™ Developer
  • Group: Developers
  • Posts: 942
  • Joined: 14-October 09
  • OS:none specified
  • Country: Country Flag

Posted 16 September 2012 - 11:05 PM

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.

This post has been edited by MrJinje: 16 September 2012 - 11:34 PM


#8 User is offline   allen2 

  • Not really Newbie
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,734
  • Joined: 13-January 06

Posted 16 September 2012 - 11:13 PM

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)


#9 User is offline   Caml Light 

  • Junior
  • Pip
  • Group: Members
  • Posts: 85
  • Joined: 03-October 03

Posted 16 September 2012 - 11:36 PM

View PostMrJinje, on 16 September 2012 - 11:05 PM, said:

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.

View Postallen2, on 16 September 2012 - 11:13 PM, said:

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.

#10 User is offline   allen2 

  • Not really Newbie
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,734
  • Joined: 13-January 06

Posted 16 September 2012 - 11:54 PM

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

#11 User is offline   Caml Light 

  • Junior
  • Pip
  • Group: Members
  • Posts: 85
  • Joined: 03-October 03

Posted 16 September 2012 - 11:57 PM

View Postallen2, on 16 September 2012 - 11:54 PM, said:

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 ;)

This post has been edited by Caml Light: 17 September 2012 - 12:05 AM


#12 User is online   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,426
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 17 September 2012 - 03:05 AM

View PostCaml Light, on 16 September 2012 - 09:45 PM, said:

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.robvander...ptcompilers.php

jaclaz

#13 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,363
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 17 September 2012 - 02:30 PM

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'!

#14 User is offline   Caml Light 

  • Junior
  • Pip
  • Group: Members
  • Posts: 85
  • Joined: 03-October 03

Posted 18 September 2012 - 03:21 PM

View PostYzöwl, on 17 September 2012 - 02:30 PM, said:

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.

This post has been edited by Caml Light: 18 September 2012 - 03:23 PM


#15 User is offline   bphlpt 

  • MSFN Expert
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,075
  • Joined: 12-May 07

Posted 19 September 2012 - 01:38 AM

View PostCaml Light, on 18 September 2012 - 03:21 PM, said:

View PostYzöwl, on 17 September 2012 - 02:30 PM, said:

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

#16 User is offline   MrJinje 

  • Tool™ Developer
  • Group: Developers
  • Posts: 942
  • Joined: 14-October 09
  • OS:none specified
  • Country: Country Flag

Posted 19 September 2012 - 02:12 AM

How much are you charging for this script that it would be beneficial for them to steal it. Does Yzowl make a percentage ? For the right price, I will rewrite the entire thing to be encrypted and only decompile in RAM.

This post has been edited by MrJinje: 19 September 2012 - 02:23 AM


#17 User is offline   Caml Light 

  • Junior
  • Pip
  • Group: Members
  • Posts: 85
  • Joined: 03-October 03

Posted 19 September 2012 - 02:30 AM

View PostMrJinje, on 19 September 2012 - 02:12 AM, said:

How much are you charging for this script that it would be beneficial for them to steal it. Does Yzowl make a percentage ? For the right price, I will rewrite the entire thing to be encrypted and only decompile in RAM.


CMD batch or converted to a different language?

I'm enthusiast about security, and i want to learn, to learn, to learn, this is the way for me! I'm curious if exists a way to don't decompile in the the HD. I know that is possible to do what you wrote with VBScript, not with a CMD batch.

This post has been edited by Caml Light: 19 September 2012 - 02:59 AM


#18 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,363
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 19 September 2012 - 09:25 AM

It's not really a security issue though is it? You are installing updates, you are telling them you are installing updates and you are showing them which updates you are running. The only time the file could be read from the hidden location is during the updating process, whilst it's running, and even then it would only be found by someone specifically knowing what to look for and where to look for it. The file contains nothing which would benefit anyone other than someone wanting to know how to formulate a for loop; what's wrong with them wanting to learn something too?

ExeScript

Quote

Executable files produced by ExeScript are securely protected with industry-standard AES encryption, making it virtually impossible to extract the original script files from the executable. ExeScript never saves or extracts the original script files onto the hard disk during the execution. Instead, all information is securely kept in the computer's RAM, which makes it hard or impossible to obtain the source code from EXE files while they are running.

To protect your scripts against unauthorized use, ExeScript can set a password to run, making it impossible to launch a script without knowing the right password. Secure AES encryption and password-protection make converted BAT to exe, VBS to exe files secure for wide distribution.


#19 User is online   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,426
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 19 September 2012 - 10:34 AM

View PostCaml Light, on 18 September 2012 - 03:21 PM, said:

Because everyone can access to that folder and get the batch.

Wouldn't it be protected by Copyright Laws? :unsure:
In any case you could have people to which you provide the install routine to sign a NDA:
http://en.wikipedia....osure_agreement
You know, just to be on the safe side. :whistle:

jaclaz

#20 User is offline   bphlpt 

  • MSFN Expert
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,075
  • Joined: 12-May 07

Posted 19 September 2012 - 11:34 AM

The only thing I can think of is that you are using the same basic batch to not only install updates, but also install something else, and that is what you don't want people to see. If that is true, then that secrecy implies something nefarious, and if I was one of your users I would be that much more curious and would trust you less in general.

I also noted that you did not answer my previous questions. I can understand that you "want to learn, to learn, to learn", but what exactly are you wanting to learn and for what purpose?

Cheers and Regards

Share this topic:


  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy