MSFN Forum: Need help with Autoit running cmd files - MSFN Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Need help with Autoit running cmd files cmd windows stay open. Rate Topic: -----

#1 User is offline   clivebuckwheat 

  • Senior Member
  • PipPipPipPip
  • Group: Members
  • Posts: 562
  • Joined: 07-November 05

Posted 06 February 2011 - 12:31 PM

Hi

I need help with an autoit script. I wrote. Basically what it does is run a view cmd files that are located in C:\Apps, resets the Administrator password via control userpasswords2

The script works but it i have to close the cmd windows before it runs the next command.

I'd like to wait until each command is done, before going on to the next, I have included start /wait in the cmd files.

lastly it opens word 2010 to check the activation status. I have tried _RUNDOS in autoit and that closes the windows but it if I put start /wait it will NOT move on to the next command,

My Auto it script

#include <Process.au3>
Run('control userpasswords2')
WinWait("User Accounts","")
Send("{SPACE}{SPACE}{TAB}{TAB}{TAB}{ENTER}")
Send("password{SHIFTDOWN}?{SHIFTUP}{TAB}password{SHIFTDOWN}?{SHIFTUP}{TAB}{ENTER}")
Send("{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}")
RunWait(@comspec & " /c start /wait resynctime.cmd","C:\Apps")
RunWait(@comspec & " /c Start /wait StartOffice2010serviceWinxp.cmd", "C:\Apps")
RunWait(@comspec & " /c (Start /wait ActivateOffice2010.cmd", "C:\Apps")
Run('C:\Program Files\Microsoft Office\Office14\Winword.exe')
WinWait("Document1 [Compatibility Mode] - Microsoft Word","")
Send("{ALTDOWN}f{ALTUP}h")


Resynctime.cmd

cmd /c w32tm /resync /nowait



StartOffice2010serviceWinxp.cmd
start /wait cscript "c:\Program Files\Microsoft Office\Office14\ospp.vbs" /osppsvcrestart 


ActivateOffice2010.cmd
cmd.exe /c start /wait cscript "%ProgramFiles%\Microsoft Office\Office14\ospp.vbs" /act



#2 User is offline   allen2 

  • Not really Newbie
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,737
  • Joined: 13-January 06

Posted 06 February 2011 - 03:56 PM

I don't really understand why you're mixing so many languages (autoit , batchs and vbs) to do this. If you only rely only on one or two it will work.
#include <Process.au3>
Run('control userpasswords2')
WinWait("User Accounts","")
Send("{SPACE}{SPACE}{TAB}{TAB}{TAB}{ENTER}")
Send("password{SHIFTDOWN}?{SHIFTUP}{TAB}password{SHIFTDOWN}?{SHIFTUP}{TAB}{ENTER}")
Send("{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}")
RunWait("w32tm /resync /nowait","C:\Apps")
RunWait("cscript " & chr(34) & "c:\Program Files\Microsoft Office\Office14\ospp.vbs" & chr(34) & " /osppsvcrestart", "C:\Apps")
RunWait("cscript.exe " & chr(34) & @ProgramFilesDir & "\Microsoft Office\Office14\ospp.vbs" & chr(34) & " /act", "C:\Apps")
Run('C:\Program Files\Microsoft Office\Office14\Winword.exe')
WinWait("Document1 [Compatibility Mode] - Microsoft Word","")
Send("{ALTDOWN}f{ALTUP}h")

Try this, it may work.

#3 User is offline   clivebuckwheat 

  • Senior Member
  • PipPipPipPip
  • Group: Members
  • Posts: 562
  • Joined: 07-November 05

Posted 06 February 2011 - 06:06 PM

Works. I am still getting the hang of autoit, so excuse the mixture of languages. I am learning and trying. What does the chr(34) do?

View Postallen2, on 06 February 2011 - 03:56 PM, said:

I don't really understand why you're mixing so many languages (autoit , batchs and vbs) to do this. If you only rely only on one or two it will work.
#include <Process.au3>
Run('control userpasswords2')
WinWait("User Accounts","")
Send("{SPACE}{SPACE}{TAB}{TAB}{TAB}{ENTER}")
Send("password{SHIFTDOWN}?{SHIFTUP}{TAB}password{SHIFTDOWN}?{SHIFTUP}{TAB}{ENTER}")
Send("{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}")
RunWait("w32tm /resync /nowait","C:\Apps")
RunWait("cscript " & chr(34) & "c:\Program Files\Microsoft Office\Office14\ospp.vbs" & chr(34) & " /osppsvcrestart", "C:\Apps")
RunWait("cscript.exe " & chr(34) & @ProgramFilesDir & "\Microsoft Office\Office14\ospp.vbs" & chr(34) & " /act", "C:\Apps")
Run('C:\Program Files\Microsoft Office\Office14\Winword.exe')
WinWait("Document1 [Compatibility Mode] - Microsoft Word","")
Send("{ALTDOWN}f{ALTUP}h")

Try this, it may work.


#4 User is offline   gunsmokingman 

  • MSFN Master
  • Group: Super Moderator
  • Posts: 2,352
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 06 February 2011 - 10:34 PM

chr(34) = "
It a way of using double "" in the code.

#5 User is offline   clivebuckwheat 

  • Senior Member
  • PipPipPipPip
  • Group: Members
  • Posts: 562
  • Joined: 07-November 05

Posted 07 February 2011 - 07:43 AM

Thank you. I think I am going to like Autoit.

View Postgunsmokingman, on 06 February 2011 - 10:34 PM, said:

chr(34) = "
It a way of using double "" in the code.


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy