Windows Scripting
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsSystem AdministrationWindows Scripting

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 15th, 2008, 06:37 PM
zambrtp zambrtp is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2008
Posts: 15 zambrtp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 57 m 6 sec
Reputation Power: 0
Unhappy VBScript - SendKey to Application in APPActivcate

I am trying to get focus on the lsnrctl window so I can use the sendkeys to that exe. But even though I see the focus the sendkeys is not able to inject anything...
Does anyone know why..I tried Sleep...

objShell.Run("D:\Infrastructure\10.1.2\bin\lsnrctl.exe CHANGE_PASSWORD"),1,True


objShell.AppActivate("D:\Infrastructure\10.1.2\bin\lsnrctl.exe")
objShell.SendKeys "{ENTER}"
objShell.SendKeys "password"

Reply With Quote
  #2  
Old October 16th, 2008, 12:14 AM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 1,254 Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 6 Days 10 h 25 m 34 sec
Reputation Power: 667
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
Facebook MySpace Orkut
Quote:
Originally Posted by zambrtp
I am trying to get focus on the lsnrctl window so I can use the sendkeys to that exe. But even though I see the focus the sendkeys is not able to inject anything...
Does anyone know why..I tried Sleep...

objShell.Run("D:\Infrastructure\10.1.2\bin\lsnrctl.exe CHANGE_PASSWORD"),1,True


objShell.AppActivate("D:\Infrastructure\10.1.2\bin\lsnrctl.exe")
objShell.SendKeys "{ENTER}"
objShell.SendKeys "password"
Is it truly focusing? The AppActivate method accepts a parameter that is the TITLE bar of the window. And you should be doing some error-handling as well.
vb Code:
Original - vb Code
  1. objShell.Run("D:\Infrastructure\10.1.2\bin\lsnrctl.exe CHANGE_PASSWORD"),1,True
  2. WScript.Sleep 1000
  3.  
  4. If objShell.AppActivate("D:\Infrastructure\10.1.2\bin\lsnrctl.exe") Then
  5.     objShell.SendKeys "{ENTER}"
  6.     objShell.AppActivate("D:\Infrastructure\10.1.2\bin\lsnrctl.exe")
  7.     objShell.SendKeys "password"
  8. End If
__________________
Click the image if at any point you don't like my decision.

Scripting problems? Windows questions? Ask the Windows Guru!


Reply With Quote
  #3  
Old October 16th, 2008, 07:45 AM
zambrtp zambrtp is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2008
Posts: 15 zambrtp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 57 m 6 sec
Reputation Power: 0
Nilpo

I assumed it was in focus because I see the cmd window that I called the script from gray out and the title bar of D:\Infrastructure\10.1.2\bin\lsnrctl.exe come forward and appear blue. But using your code the result is the same. The lsnrctl command window waits for user input. I am very new to Windows Scripting I will attempt to add error checking...thanks

Reply With Quote
  #4  
Old October 16th, 2008, 10:57 AM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 1,254 Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 6 Days 10 h 25 m 34 sec
Reputation Power: 667
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
Facebook MySpace Orkut
Ok. The best way to handle command windows is by passing text to the StdIn stream...I'll post back with the code.

Reply With Quote
  #5  
Old October 16th, 2008, 05:38 PM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 1,254 Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 6 Days 10 h 25 m 34 sec
Reputation Power: 667
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
Facebook MySpace Orkut
I apologize. I didn't have time to write the code earlier. Here's what you need to use the StdIn and StdOut streams to read and write to a CMD window. Cheers!
vb Code:
Original - vb Code
  1. Const WshRunning = 0
  2. Const WshFinished = 1
  3. Const WshFailed = 2
  4. strCommand = "D:\Infrastructure\10.1.2\bin\lsnrctl.exe CHANGE_PASSWORD"
  5.  
  6. Set WshShell = CreateObject("WScript.Shell")
  7. Set WshShellExec = WshShell.Exec(strCommand)
  8.  
  9. Select Case WshShellExec.Status
  10.     Case WshRunning
  11.         WshShellExec.StdIn.WriteLine("") 'Simulate pressing Enter
  12.         WshShellExec.StdIn.WriteLine("password") 'password followed by Enter
  13.     Case WshFinished
  14.         strResponse = WshShellExec.StdOut.ReadAll
  15.     Case WshFailed
  16.         strError = WshShellExec.StdErr.ReadAll
  17. End Select

Reply With Quote
  #6  
Old October 20th, 2008, 08:13 AM
zambrtp zambrtp is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2008
Posts: 15 zambrtp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 57 m 6 sec
Reputation Power: 0
NO luck :(

Thanks for the code...I tried it this morning.....the code spawns the second window but it dissappears in a sec and isnt setting it...Im VERY new to windows scripting how can I slow it down to see errors?
Thanks again for your help

Reply With Quote
  #7  
Old October 20th, 2008, 04:17 PM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 1,254 Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 6 Days 10 h 25 m 34 sec
Reputation Power: 667
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
Facebook MySpace Orkut
You should be able to just echo strError.

Reply With Quote
  #8  
Old October 22nd, 2008, 11:50 AM
zambrtp zambrtp is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2008
Posts: 15 zambrtp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 57 m 6 sec
Reputation Power: 0
Unhappy

I added some ECHO commands...I added one right after te strCommand = "D..........CHANGE_PASSWORD"
that one I get back from screen ..then I added another one after the line below along with a strError=WshShellExec.stdErr.ReadALL
Set WshShellExec=WshShell.Exec(strCommand)
but i dont get the echo and at that point it waits for a few seconds and terminates...when I check to see if the change was made it was not...I should see my original listener.ora file with a new time stamp...
I must be doing soemthing wrong..

Reply With Quote
  #9  
Old October 22nd, 2008, 12:57 PM
zambrtp zambrtp is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2008
Posts: 15 zambrtp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 57 m 6 sec
Reputation Power: 0
if the Exec command supresses the command window of the lsrnctl is there a way to allow it to come up so I can see if the stream in is actually writing?

Reply With Quote
  #10  
Old October 22nd, 2008, 03:48 PM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 1,254 Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 6 Days 10 h 25 m 34 sec
Reputation Power: 667
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
Facebook MySpace Orkut
Quote:
Originally Posted by zambrtp
if the Exec command supresses the command window of the lsrnctl is there a way to allow it to come up so I can see if the stream in is actually writing?
Unfortunately, you can only access Standard Input and Output streams in VBS when using the Exec method. Try this variation instead.
vb Code:
Original - vb Code
  1. Const WshRunning = 0
  2. Const WshFinished = 1
  3. Const WshFailed = 2