trids Posted October 10, 2007 Posted October 10, 2007 I just stumbled across this sublime technique of concatenating DOS commands with &&, in order to run them on the same line. EXAMPLE -- Does all of this in ONE execution of RunWait().. set current drive to C:change path to WINNT foldercollect the list of files there into a temporary fileopen the file in your text editorRunWait( @COMSPEC & " /c C:&&cd \winnt&&dir>D:\temp\multi.txt&&D:\temp\multi.txt", "", @SW_SHOW ) Luigi 1
BrettF Posted October 10, 2007 Posted October 10, 2007 Pure awesomeness Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
lordofthestrings Posted October 10, 2007 Posted October 10, 2007 (edited) in dos what this does is the following:Command A & Command B --> execute command A, then execute command B. (no evaluation of nothing)Command A | command B --> execute command A, and redirect all it's output into the input of command B.Command A && Command B ---> means execute command A, Evaluate the errorlevel after running Command A, and if the exit code (errorlevel) is 0, only then execute command B.Command A || command B ---> execute Command A, evalutate the exit code of this command and if it's anything but 0, Only then execute command B.command A >> outputfile.txt 2>&1 ---> means execute command A, and write the STDERR Output to STDOUTexamples:dir c:\ & echo All done!help | moreor type c:\windows\system32\drivers\etc\hosts | find /I "Microsoft"dir c:\windows || echo I can't find this directory c:\windowsdir>c:\file.txt 1<&2 (explain me why you see the dir command send it's output to the dosbox, while I clearly specify that I should output it to c:\file.txt......if you want to read more about this look use command redirection operatorshttp://www.microsoft.com/resources/documen...n.mspx?mfr=true--reason edit-- More examples of all commands Edited October 10, 2007 by lordofthestrings
trids Posted October 10, 2007 Author Posted October 10, 2007 Great! Thanks, lots, it's nice to have the whole picture
drtrobridge Posted May 13, 2013 Posted May 13, 2013 I just stumbled across this sublime technique of concatenating DOS commands with &&, in order to run them on the same line. EXAMPLE -- Does all of this in ONE execution of RunWait().. set current drive to C: change path to WINNT folder collect the list of files there into a temporary file open the file in your text editor RunWait( @COMSPEC & " /c C:&&cd \winnt&&dir>D:\temp\multi.txt&&D:\temp\multi.txt", "", @SW_SHOW ) I had to create and account to let you know that this info just turned my project from a disaster to a success. Thank you for your help!! This forum is spectacular.
TheSaint Posted May 13, 2013 Posted May 13, 2013 Great find, thanks for sharing. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
spudw2k Posted May 14, 2013 Posted May 14, 2013 loves me some &&. I use it quite often Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
legend Posted June 8, 2013 Posted June 8, 2013 RunWait( @COMSPEC & " /c C:&&ipconfig /release&&ipconfig /renew", "", @SW_HIDE)
lavalampman Posted January 17, 2014 Posted January 17, 2014 I just stumbled across this sublime technique of concatenating DOS commands with &&, in order to run them on the same line. EXAMPLE -- Does all of this in ONE execution of RunWait().. set current drive to C: change path to WINNT folder collect the list of files there into a temporary file open the file in your text editor RunWait( @COMSPEC & " /c C:&&cd \winnt&&dir>D:\temp\multi.txt&&D:\temp\multi.txt", "", @SW_SHOW ) Many thanks to trids for posting this - it did the job perfectly for me in VB 2008... Dim sMyCommand As String sMyCommand = "cd test01&&dir>multi.txt Shell("cmd /c " & sMyCommand, vbHide)
lexicon Posted January 21, 2014 Posted January 21, 2014 (edited) This one works. RunWait( @COMSPEC & " /c C:&&cd \Tools&&dir>D:\temp\multi.txt&&D:\temp\multi.txt", "", @SW_SHOW ) But the below one doesn't. Can't we use ShellExecute with @COMPSPEC ? because i would like to run cmd as admin using IsAdmin() Which uses ShellExecute() ShellExecute( @COMSPEC & " /c C:&&cd \Tools&&dir>D:\temp\multi.txt&&D:\temp\multi.txt", "", @SW_SHOW ) Thanks Edited January 21, 2014 by lexicon
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