Caml Light Posted September 16, 2012 Share Posted September 16, 2012 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 Link to comment Share on other sites More sharing options...
bphlpt Posted September 17, 2012 Share Posted September 17, 2012 Can you list your batch for us?Cheers and Regards Link to comment Share on other sites More sharing options...
Caml Light Posted September 17, 2012 Author Share Posted September 17, 2012 (edited) My batch is based on a old cmd script written by Yzöwl: @ECHO OFFECHO=_%~1|FINDSTR/X "_-123456 _/123456">NUL 2>&1||GOTO ErrorSETLOCAL ENABLEEXTENSIONSSET "_="PUSHD %~dp0FOR /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 ErrorECHO=ECHO= == Press any key to restart. ==>NUL PAUSESHUTDOWN.EXE /r /t 0GOTO :EOF:ErrorECHO= Error.ECHO=ECHO= Press any key to exit...>NUL PAUSEMy 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 September 17, 2012 by Caml Light Link to comment Share on other sites More sharing options...
bphlpt Posted September 17, 2012 Share Posted September 17, 2012 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 Link to comment Share on other sites More sharing options...
Caml Light Posted September 17, 2012 Author Share Posted September 17, 2012 (edited) 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 September 17, 2012 by Caml Light Link to comment Share on other sites More sharing options...
bphlpt Posted September 17, 2012 Share Posted September 17, 2012 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 Link to comment Share on other sites More sharing options...
MrJinje Posted September 17, 2012 Share Posted September 17, 2012 (edited) 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}}" & PAUSEOn 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 September 17, 2012 by MrJinje Link to comment Share on other sites More sharing options...
allen2 Posted September 17, 2012 Share Posted September 17, 2012 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) Link to comment Share on other sites More sharing options...
Caml Light Posted September 17, 2012 Author Share Posted September 17, 2012 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}}" & PAUSEOn 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. Link to comment Share on other sites More sharing options...
allen2 Posted September 17, 2012 Share Posted September 17, 2012 Then you need to use the mmb manual to create a mmb script. Link to comment Share on other sites More sharing options...
Caml Light Posted September 17, 2012 Author Share Posted September 17, 2012 (edited) 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. EDIT: You've a PM Edited September 17, 2012 by Caml Light Link to comment Share on other sites More sharing options...
jaclaz Posted September 17, 2012 Share Posted September 17, 2012 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.phpjaclaz Link to comment Share on other sites More sharing options...
Yzöwl Posted September 17, 2012 Share Posted September 17, 2012 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'! Link to comment Share on other sites More sharing options...
Caml Light Posted September 18, 2012 Author Share Posted September 18, 2012 (edited) 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. Anyway, for a UNskillful person, the %TEMP% folder is easy to get. Edited September 18, 2012 by Caml Light Link to comment Share on other sites More sharing options...
bphlpt Posted September 19, 2012 Share Posted September 19, 2012 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. 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 Link to comment Share on other sites More sharing options...
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