BMahon
(Fresh Scripter)
2003-07-24 03:51 PM
Using Sendkeys problem

Hi. I have this problem when using Sendkeys. I am using the following code to run a program with adminstrative rights. It works on about half of the machines. On the machines where it doesn't work the Runas dialog box becomes stuck on their Windows 2000 screen. It is awaiting a password entry. Would it be possible that the Sendkeys password was implemented to quickly into the Runas dialog box? See below for the code that I am using: (Please not thet this code segment is contained within an IF statement).

SETTITLE ("SENDKEYS")

run 'runas /user:domainname\username

"\\servername\Ant-virusV\AVcheck.bat"'

$SK SetFocus ("SENDKEYS")

$SK= sendkeys("password{enter}")


Les
(KiX Master)
2003-07-24 04:18 PM
Re: Using Sendkeys problem

Your line:
$SK SetFocus ("SENDKEYS")

is missing the =
$SK= SetFocus ("SENDKEYS")

but really, that is not good enough anyway. You need to put it into a wait loop.
code:
Break on
Run 'notepad'
while SetFocus('Untitled - Notepad')<>0
"."
sleep 1
$Index = $Index + 1
if $index > 20
$RC = MessageBox("NOTICE!" + Chr(13) + "Notepad did not open within a reasonable time!"
+ Chr(13) + "Please notify the HelpDesk at ext. 1234","Notepad example",48,60)
goto finish
endif
Loop

$RC=Sendkeys('Hey, it worked!')



Sealeopard
(KiX Master)
2003-07-24 05:00 PM
Re: Using Sendkeys problem

You might want to read Installing an Application as an Admin as there are more secure ways compared to what you try to do.

Les
(KiX Master)
2003-07-24 05:07 PM
Re: Using Sendkeys problem

OOPS! Forgot to give my Doom and Gloom, and Security Sins, Hellfire and Brimstone speech on using SU and RunAs. [Embarrassed]

What was I thinking... I usually just boycott these topics.


Sealeopard
(KiX Master)
2003-07-24 05:10 PM
Re: Using Sendkeys problem

Can we have that as a FAQ and then just point people to it as soon as a post contains the word RUNAS ? [Wink]

Les
(KiX Master)
2003-07-24 05:50 PM
Re: Using Sendkeys problem

Like I said, I usually just sit on my hands. Was focused more on just the SendKeys() part.

If I were Chief Information Security Officer, I would fire anyone that passed passwords through a logon script!

[ 24. July 2003, 17:51: Message edited by: LLigetfa ]


BMahon
(Fresh Scripter)
2003-07-25 11:29 AM
Re: Using Sendkeys problem

The account does not use a Domain Adminsitrator account...just an account that is added to the local adminstrators group using Windows Group Policy...Also on completion, the script will be encrypted. Still having trouble tring to implement the while using my code example. Thanks

Les
(KiX Master)
2003-07-25 02:36 PM
Re: Using Sendkeys problem

A domain account that gets me local admin access to every machine is still dangerous. With it, I could hack to every computer in the org over the network, install keyloggers and start collecting passwords!