matthewdowney20 Posted August 13, 2012 Posted August 13, 2012 Hey everyone, I am currently writing a command line application, and am having trouble with making it print back to the command line. Here is what I tried initially: myprogram.au3 $MyCommand = 'dir' Run(@ComSpec & " /c " & $MyCommand, @SystemDir, @SW_Show) Run(@ComSpec & " /c @echo off && echo Command completed successfully. && @echo on", @SystemDir, @SW_Show) Then I compiled it and ran it via the command line: (each code box represents a command line) C:\Users\Matthew>myprogram.au3 C:\Users\Matthew> Opens new shell ↓ Volume in drive C has no label. Volume Serial Number is 0287-990C Directory of C:\Users\Matthew 08/06/2012 07:37 PM <DIR> . 08/06/2012 07:37 PM <DIR> .. 07/15/2012 09:20 AM <DIR> .idlerc 08/12/2012 05:13 PM <DIR> .VirtualBox 09/10/2011 04:00 PM 2,050,902,016 BT5-GNOME-32.iso 07/12/2012 10:17 AM <DIR> Contacts 08/13/2012 03:39 PM <DIR> Desktop 08/13/2012 01:40 PM <DIR> Documents 08/12/2012 05:12 PM <DIR> Downloads 07/12/2012 10:17 AM <DIR> Favorites 07/13/2012 06:22 PM <DIR> Links 07/25/2012 11:51 PM <DIR> Music 08/11/2012 02:17 AM 442 openvpn-connect.json 08/13/2012 12:33 PM 12,655 ovpntray.log 05/25/2012 03:51 AM 4,167,214,806 People In Motion.mp4 07/12/2012 10:17 AM <DIR> Pictures 07/12/2012 10:17 AM <DIR> Saved Games 08/12/2012 05:16 PM 899 SciTE.session 07/12/2012 10:17 AM <DIR> Searches 07/14/2012 05:42 PM 728,150,016 ubuntu-10.04.4-desktop-i386.iso 07/15/2012 10:18 AM <DIR> Videos 08/11/2012 06:16 PM <DIR> VirtualBox VMs 6 File(s) 6,946,280,834 bytes 16 Dir(s) 1,814,325,567,488 bytes free Once finished listing files in my directory that exits and Opens new shell ↓ The command completed successfully. and that window closes immediated (I made sure it was saying that by appending '&& pause' to the end of the echo commands). The output I am looking for is the same thing, but in one window, like this: C:\Users\Matthew>myprogram *output of dir command* The command completed successfully C:\Users\Matthew>
Bert Posted August 14, 2012 Posted August 14, 2012 why in the world do you need to do this? I'm asking out of simple curiosity. One could make a GUI that does what you are doing so I'm trying to understand your motive. If anything I may learn something. Thanks. The Vollatran project My blog: http://www.vollysinterestingshit.com/
daxle Posted August 14, 2012 Posted August 14, 2012 why in the world do you need to do this? I'm asking out of simple curiosity. One could make a GUI that does what you are doing so I'm trying to understand your motive. If anything I may learn something. Thanks.I was actually also looking for a way to do this recently, I've been getting tired of using the RunAs command to run things as admin in the windows command prompt so I was thinking of making a little application that could be called from the command line and would perform the specified command as administrator, and I wanted it to do this so that it would execute in the same shell. I'm sure there are tons of other uses for this too. Now I'm intrigued Any ideas guys?
water Posted August 14, 2012 Posted August 14, 2012 Please do not double-post. You already have a thread with the same title My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
matthewdowney20 Posted August 14, 2012 Author Posted August 14, 2012 (edited) Please do not double-post. You already have a thread with the same title I'm sorry! Could you delete the other post? I tried but I don't have permission to. The other one was a half finished version of this that I accidentally posted and then could not delete. Edited August 14, 2012 by matthewdowney20
water Posted August 14, 2012 Posted August 14, 2012 You can't delete a thread. Just ignore it for now. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
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