Jump to content

Execute command and then pause in shell window


Recommended Posts

Whats the trick to do something like this in AutoIt without using a batch file? I would like to run a command line and then pause so that I (or another user) can see the result of the previous command and then the "pause" would allow me to press any key to close the window. Right now, if I run a command, the shell window closes before I get a chance to see whether the command was successful or not. For example, if I wanted to run the command "net use Z: \\server\share" and then "pause", is it possible to do that using either ShellExecute or just the simple Run (@ComSpec...)? I know with a batch file, I could do it by doing something like this:

*test.bat*

net use Z: \\server\share

pause

exit

I am wondering if its possible to do this all in one line though so that I do not have to use a batch file and can use the built in AutoIt Run or ShellExecute functions to accomplish this.

Hope I'm explaining myself correctly. Thanks for your feedback.

Link to comment
Share on other sites

Well, have a play with Run, changing the "/c" with "/k" (hope it's correct) to leave the window open after the command runs. Then wait a few seconds and close the window.

Something like this:

Opt("WinTitleMatchMode", 2)
Run(@ComSpec & " /k " & 'net use Z: \\server\share', "", @SW_SHOW)
Sleep(2000)
WinClose("cmd.exe")

You will need to find a more accurate string in window's title to make sure you won't be closing the wrong window.

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...