• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1341
  • Last Modified:

executing a program using wshshell.run command

What i am trying to do here is this... i want to be able to run a script .. using wshshell.run

I need it to go to C:\Program Files\Microsoft Office\OFFICE11\WINWORD.exe
and open that file .. there word will come up

at that point i need it to pause for 10 seconds and then send keys to the screen.


i made this

set wshShell = WScript.CreateObject("WScript.Shell")

wshShell.Run "C:\Program Files\Microsoft Office\OFFICE11\WINWORD.exe", 1, False

winexist = false

do while winexist = false

winexist = wshShell.AppActivate("Document1 - Microsoft Word")

loop

WScript.sleep 10000

wshShell.sendkeys
"{TAB}{TAB}{TAB}test{TAB}{ENTER}"


what am i doing wrong it keeps giving me errors and telling me that wshshell.run is not a valid blah blah.. or it just dosent do anything can anyone help?


0
hartnessjr
Asked:
hartnessjr
  • 2
1 Solution
 
ColosseoCommented:
Hi

just tried your program and it worked fine... the only thing that needed to be changed was this line

wshShell.Run "C:\Program Files\Microsoft Office\OFFICE11\WINWORD.exe",1, False

which I changed to

wshShell.Run """C:\Program Files\Microsoft Office\OFFICE11\WINWORD.exe""",1, False

note the additional " marks... this is to get around the spaces in the folder names, apart from that it opened word, waited 10 seconds and then sent the keys properly.

the code which ran:::

set wshShell = WScript.CreateObject("WScript.Shell")

wshShell.Run """C:\Program Files\Microsoft Office\OFFICE11\WINWORD.exe""",1, False

winexist = false

do while winexist = false

winexist = wshShell.AppActivate("Document1 - Microsoft Word")

loop

WScript.sleep 10000

wshShell.sendkeys "{TAB}{TAB}{TAB}test{TAB}{ENTER}"

HTH

Scott
0
 
hartnessjrAuthor Commented:
LOL i forgot the double quotes .. sigh .. well thats why there is this board.. no one is here other than me to look at stuff like this and sometimes you just need another set of eyes.. thanks a lot
0
 
ColosseoCommented:
lol yeah I know what you mean... I only picked up on it cause I had to change office11 to office10 on my machine to get it to work and that made me think about the double quotes.

Glad your sorted though and thanks for the grade.

Cheers

Scott
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now