Jump to content

How to Close a Text File


Recommended Posts

I prepared the following to run a batch file on a Windows 2000 PC. The batch file ends by pulling up a txt file. My understanding is that by using RunWait that the 2 send commands that follow will NOT be executed until RunWait is completed. Yet, the txt file does NOT close.

I would like help with 2 issues: how might I change the following to close the txt file without using Sleep; and, what is another way to do this if I simply use Run to execute a none-batch file (say for a js, java script, file). Thanks for the help.

; Define the Path and batch file

Dim $PathToYourShortCut = "C:\Ftrade\example.bat"

; Path to the Folder where your shortcut resigns

Dim $DirToYourShortCut = StringLeft($PathToYourShortCut, StringInStr($PathToYourShortCut, "\", 0, -1))

; FileName of the shortcut

Dim $ShortCutName = StringRight($PathToYourShortCut, StringLen($PathToYourShortCut)-StringInStr($PathToYourShortCut, "\", 0, -1))

; Run CommandPrompt (telling it to run ShortCut file, but RunWait tells cmd.exe ( @ComSpec ) to start in the shortcut's folder.

RunWait(@ComSpec & " /c " & $ShortCutName, $DirToYourShortCut, @SW_MINIMIZE)

; Quit via Alt-f and then x (File menu -> Exit)

Send("!f")

Send("x")

......

Link to comment
Share on other sites

If I want to run a program and wait for it to close but also continue with checking other things I use something like

$process = Run ("the program.exe")

While ProcessExists($process)

;check some stuff or do some stuff
;etc
;etc

Wend
Link to comment
Share on other sites

Don't need to or want to hang as have other AutoIt work to do. Would like AutoIt to preceed with next step as soon as possible. So, I still do not know how to tell AutoIt to wait until done with the nth step prior to processing the nth + 1 step.

Maybe you or others have know how and will post.

Thanks ..

Link to comment
Share on other sites

Then his routine will allow you to go to the next step(s) immediately.

$FirstStep = Run ("the first Step")

do the second step

do the nth step

While ProcessExists($FirstStep )

Wend

Edited by dingo
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...