Sign in to follow this  
Followers 0
hendrikhe

echo cmd

3 posts in this topic

#1 ·  Posted (edited)

Hello AutoIt community,

I would like to send several CMD commands. My script is running the commands well but looks like the echo command does not appears on screen (see attached screenshot)

 

echo.png

 

$CMD = 'echo C:\Users>ipconfig /flushdns && ' & _
       'ipconfig /flushdns && ' & _
        'echo C:\Users>net stop dnscache && ' & _
        'net stop dnscache && ' & _
        'echo C:\Users>ipconfig /flushdns && ' & _
        'ipconfig /flushdns && ' & _
        'echo C:\Users>net start dnscache && ' & _
        'net start dnscache && ' & _
        'echo C:\Users>ipconfig /flushdns && ' & _
        'ipconfig /flushdns && ' & _
        'echo C:\Users>ipconfig /all && ' & _
        'ipconfig /all && ' & _
        'echo C:\Users>hostname && ' & _
        'hostname'
        
RunWait('"' & @ComSpec & '" /k ' & $CMD, @SystemDir)

 

Is there a way to display e.g.:'echo C:\Users>ipconfig /flushdns ?
 

Best regards

Hendrik

Edited by hendrikhe

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I believe your > character is the culprit.  You are redirecting the echo output to a file called ipconfig & hostname respectively.  Try escaping the > character.
 

$CMD = 'echo C:\Users^>ipconfig /flushdns && ' & _
       'ipconfig /flushdns && ' & _
        'echo C:\Users^>net stop dnscache && ' & _
        'net stop dnscache && ' & _
        'echo C:\Users^>ipconfig /flushdns && ' & _
        'ipconfig /flushdns && ' & _
        'echo C:\Users^>net start dnscache && ' & _
        'net start dnscache && ' & _
        'echo C:\Users^>ipconfig /flushdns && ' & _
        'ipconfig /flushdns && ' & _
        'echo C:\Users^>ipconfig /all && ' & _
        'ipconfig /all && ' & _
        'echo C:\Users^>hostname && ' & _
        'hostname'
        
RunWait('"' & @ComSpec & '" /k ' & $CMD, @SystemDir)

 

...just curious...flushdns cache three times?    

Edited by spudw2k
grammar

Share this post


Link to post
Share on other sites

That worked, thank you for the fast support!

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  
Followers 0