Welcome to MSFN

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.


Sign in to follow this  
Followers 0
clivebuckwheat

Need help with Autoit running cmd files

5 posts in this topic

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

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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?

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.

0

Share this post


Link to post
Share on other sites

chr(34) = "

It a way of using double "" in the code.

0

Share this post


Link to post
Share on other sites

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

chr(34) = "

It a way of using double "" in the code.

0

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

  • Recently Browsing   0 members

    No registered users viewing this page.