Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple script errors?

Status
Not open for further replies.

cold25

Programmer
Feb 11, 2002
41
US
Hi. I'm trying to learn vbs and get some basic things to work. I have two main questions right now concerning the script I've written, below:

1. I'm trying to write a simple script in notepad to automate the launching of an exe file (AcroRd32.exe). I've saved the file where the script is written as 1.vbs. When I launch the script, I get the error message: "The system cannot fine the file specified." I know that the exe file I'm attempting to launch is actually at the location I've put in the script. The only success I've had was launching things like Notepad.exe, Excel.exe and WinWord.exe, as listed in the FAQs of this forum. However, my goal is to be able to launch other executables as well. Can the WshShell.Run command not launch other types of exe files? If so, then how could I get the script to launch any executable file?

2. So, not getting the WshShell.Run "C:\Program Files\Adobe\Acrobat5.0\Reader\AcroRd32.exe" command to work, I commented out this line and launched AcroRd32.exe manually. Then the script seemed to be executing correctly, up until the point of the command: WshShell.Sleep 1000
I received the error message: "Object doesn't support this property or method: 'Sleep'

So, I'm not sure why these commands aren't working. Any help with these issues would be much appreciated. Thanks!
cold25

Dim WshShell
Set WshShell = CreateObject("WScript.Shell")

WshShell.Run "C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe"

WshShell.AppActivate "Acrobat Reader"
WshShell.SendKeys "%{f}"
WshShell.SendKeys "{DOWN 8}"
WshShell.SendKeys "~"
WshShell.Sleep 1000
WshShell.SendKeys "%{f}"
WshShell.SendKeys "~"
 
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run """C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe"""
WshShell.AppActivate "Acrobat Reader"
WshShell.SendKeys "%{f}"
WshShell.SendKeys "{DOWN 8}"
WshShell.SendKeys "~"
WScript.Sleep 1000
WshShell.SendKeys "%{f}"
WshShell.SendKeys "~"


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hey, thanks for your help. The WshShell.Run """C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe""" is working now. I would have never guessed that it just needed a couple extra sets of quotation marks around the path. Would you have any suggestions of any web sites and/or books I could view that have the very basics of vbs programming? I have a feeling that I'm being held up by very elementary mistakes, that I just don't any better than to make.

Also, the WScript.Sleep 1000 command causes an error still. I believe I really need it to work, because it takes the .run command a few seconds to launch the aforementioned exe file, and by that time the script has completed and the newly opened program cannot receive the sendkeys commands I wanted to send it. Any idea why it causes an error? Thanks again in advance for any help. This is a great website!
cold25
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top