RyanMyGeek Posted July 26, 2013 Share Posted July 26, 2013 Hello everyone, I am making a script that opens the command prompt and starts a program, (Disk2VHD). Making a backup of my hard drive . then compresses the file after completing using 7zip. I have tested each part of the script, and each part works individually, but when I put them all together the program hangs up after closing Disk2VHD. I am open to any advice, and would be grateful for any help in solving this issue. Thanks, Ryan Run("cmd.exe") ; opens command prompt WinWaitActive("Administrator: C:\Windows\System32\cmd.exe") ;wait for command prompt to become active window Sleep (2000) ; wait before sending text to command prompt Send("cd c:""program files (x86)""disk2vhd && start disk2vhd.exe c: c:VHDBackup.vhd{ENTER}") ;start disk2vhd making a copy of C: drive and store it in the VHD subfolder WinSetState ( "Administrator: C:\Windows\System32\cmd.exe", "" , @SW_HIDE ) ;hide command prompt while Disk2VHD is working WinWaitActive("Disk2vhd - Sysinternals: www.sysinternals.com", "Disk export to VHD completed successfully.") ;wait for Disk2VHD to finish making VHD Sleep(2000) ;wait after Disk2VHD has finished fully before closing ProcessClose("disk2vhd.exe") ;end disk2vhd process ProcessClose("disk2vhd-tmp.exe") ;close disk2vhd Sleep(1000) ;wait after closing disk2vhd WinSetState("Administrator: C:\Windows\System32\cmd.exe", "" , @SW_SHOW) ;show command prompt WinActivate("Administrator: C:\Windows\System32\cmd.exe") ;make command prompt the active window WinWaitActive("Administrator: C:\Windows\System32\cmd.exe") ;wait until command prompt is the active window Send("cd c:""program files (x86)""7-zip && 7z a c:vhdbackup.zip c:vhdbackup.VHD && exit {enter}") ;compress the vhd file using 7zip in the VHD subfolder Exit ; end the script Link to comment Share on other sites More sharing options...
JohnOne Posted July 26, 2013 Share Posted July 26, 2013 Have you tried using WinClose instread of ProcessClose AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
RyanMyGeek Posted July 26, 2013 Author Share Posted July 26, 2013 I have used both, and both result in the same problem. I feel like the problem is in the WinWaitActive("Disk2vhd - Sysinternals: www.sysinternals.com", "Disk export to VHD completed successfully.") ;wait for Disk2VHD to finish making VHD line of code, as this is where it usually stops working, it will not pass this point and start up 7zip. it does however make the backup of the drive successfully, and will close the Disk2vhd after it finishes the backup, just nothing after. Link to comment Share on other sites More sharing options...
JohnOne Posted July 27, 2013 Share Posted July 27, 2013 It might be fighting to active status and losing the battle. Try with winwait instead, and of course make sure title and text are correct. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
RyanMyGeek Posted July 29, 2013 Author Share Posted July 29, 2013 Just tried winwait instead of winwaitactive and still not moving past the closing of Disk2vhd. This code is really kicking my butt, haha. I am trying now with a more lenient sleep time to make sure that its getting fully closed before trying to move on and hanging up. Any other Ideas? Once again, Thanks for all the help. Ryan Link to comment Share on other sites More sharing options...
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