Jump to content
Sign in to follow this  
Guest scriptdau

Get Os Command Output Into A Script

Recommended Posts

Guest scriptdau

Hi Everybody,

is it possible to get the output of a OS Command (for example DIR /S) into a MSGBOX without going over a temp. file?

In OS Batch File I' am able to send the folder/file to a batch dir %%1 - is this also possible?

Getting crazy :D to get this done

For a hints and tips many thanks.

Best regards

Carlos

Share this post


Link to post
Share on other sites
Chris_1013

Sounds like a good use for DirectTo.exe?

Share this post


Link to post
Share on other sites
scriptkitty

I couldn't find a DirectTo.exe, so I made one. Here it is uncompiled :D

If $cmdline[0]=1 Then 
    If $cmdline[1]="/?" Then MsgBox(1,"Usage","DirectTo.exe file.exe [arguments]" & @crlf&"This copies output to clipboard.")
EndIf
If $cmdline[0]=0 Then MsgBox(1,"Usage","DirectTo.exe file.exe [arguments]" & @crlf&"This copies output to clipboard.")
$out=""
For $i= 1 To $cmdline[0]
    $out=$out & " " & $cmdline[$i]
Next
tooltip("Gathering Data",0,0)
RunWait(@ComSpec & " /c " & $out & " >c:\tempme.txt",'',@SW_HIDE)
$file=fileread("c:\tempme.txt",FileGetSize("c:\tempme.txt"))
FileDelete("c:\tempme.txt")
clipput($file)

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites
scriptkitty

DOH!!

Now I remember.

Try this.

$x=getcmd("dir")


func getcmd($command)
; copies output to clipboard, and returns output
run(@comspec,"",@SW_HIDE)
winwait(@comspec)
controlsend(@comspec,'','',$command & "{enter}")
controlsend(@comspec,'','',"!{space}es{enter}")
winclose(@comspec)
$out=clipget()
return $out
endfunc

might have to adjust for time, but this might help a tad.


AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites
Guest scriptdau

Hi Everybody,

first many thanks for your replies.

What I' am fighting is to get the following batch converted into to autoit:

set drive_info=%~d1

set path_info=%~p1

set file_info=%~n1

cd \

%drive_info%

cd %path_info%

@echo Files in Folder %drive_info%%path_info%%file_info%:

@FOR /f %%a in ('DIR %drive_info%%path_info%%file_info% /s ^|FIND " File(s) " /c') do @FOR /f %%b in ('SET /a dummy^=%%a-1') do @(DIR %drive_info%%path_info%%file_info% /s/-c |FIND " File(s) "|MORE /e +%%B)

pause

Over the SendTo menu it is possible to add a shortcut of the batch-file. The org. question was, is it with autoit also possible to get a variable (for example) over the ms-explorer to process?

Thanks for any reply.

Regards Carlos

Edited by scriptdau

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.