Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Bash / Shell Scripting (http://www.programmingforums.org/forum26.html)
-   -   enter key (http://www.programmingforums.org/showthread.php?t=12370)

NightShade01 Jan 14th, 2007 10:03 AM

enter key
 
Hey everyone i'm trying to write an automated install batch file for spybot, so far i have it installing the program updating running and autofixing problems. The issue though is that internet needs to be connected and this isn't the case where i want to use it (work). The three updates though are .exe files but they have no parameters built in. I can use my batch file to launch the update manually but it prompts the user where to install it (all you have to do is hit enter). How do i simulate the pressing of an enter key in my batch file so i don't have any user interaction...thanks

mackenga Mar 22nd, 2007 5:40 PM

As far as I know you can't do this with a batch file, but you can do it with VBScript or JScript running in WSH (the WIndows Scripting Host). I'm a little pressed for time right now but some snippets that might help are:

:

Dim objSH

Set objSH = WScript.CreateObject("WScript.Shell")
objSH.SendKeys("{ENTER}")


You need to activate the installer first; that's done with another method of WScript.Shell called ActivateApp or ActivateWindow or something along those lines; you'll find it in any tutorial or documentation on SendKeys since the two go hand in hand.

I know it may seem awkward to learn VBScript or JScript if you don't already know it, but I don't think a batch file is going to solve your problem and either of these is quick enough to pick up. If you've got any JavaScript experience or experience with a C-like language you'll get up and running with JScript pretty quickly.

Just do some searches for introductory material on WSH and SendKeys. That should get you going.

Hope this helps.


All times are GMT -5. The time now is 9:13 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC