auto login

User avatar
Steve_in_Kent
4StarLounger
Posts: 415
Joined: 04 Feb 2010, 11:46

auto login

Post by Steve_in_Kent »

operating system is win xp.. (soon to be win 7).

i have excel running, ive written some vba code to shell out to another program and perform some actions.. that all works fine.

my problem, is that its a company pc, (no admin rights), which auto locks after x minutes.

at that point, i don't think xls has the focus.

in excel when there is an ontimer event, that fires the vba at a certain time. lets say the pc is locked. if i log in, after the event time. the code will then run fine.

what i need to do, (and i suspect without admin access this might be troublesome), is to WAKE the pc at a certain time each day, auto log in.
so that the excel VBA can do its thing.

the pc will be left overnight, and at 06:15, i want it to unlock, then run the code.

is this possible?
----------------------------------------------------------------------------------------
Owing at LEAST 34 beers to other helpful forum members. Especially HansV!

User avatar
HansV
Administrator
Posts: 78235
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: auto login

Post by HansV »

Does the PC get locked, or arr you automatically logged out after x minutes, or does the PC go into sleep/hibernation?
If the PC is merely locked, programs should continue running normally as long as they don't require user interaction.
Best wishes,
Hans

User avatar
Steve_in_Kent
4StarLounger
Posts: 415
Joined: 04 Feb 2010, 11:46

Re: auto login

Post by Steve_in_Kent »

its just locked after x minutes..

I tried using sendkeys to do a CNTRL-ALT-DELETE to unlock, but it didn't work.
SendKeys I & "{^}{%}{DELETE}", True
was what i tried.
----------------------------------------------------------------------------------------
Owing at LEAST 34 beers to other helpful forum members. Especially HansV!

User avatar
HansV
Administrator
Posts: 78235
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: auto login

Post by HansV »

Why do you need the PC to be unlocked? On my PC, programs continue running when it is locked, so for example an Excel macro started with Appplication.OnTime will still be executed. I tested it just now to be sure: I scheduled a macro that emits a beep to be run every minute. Excel cheerfully kept on beeping after I locked my PC...
Best wishes,
Hans

User avatar
Steve_in_Kent
4StarLounger
Posts: 415
Joined: 04 Feb 2010, 11:46

Re: auto login

Post by Steve_in_Kent »

i (think) its because i'm using sendkeys.

this is the code that i have (that works 100% fine)

I think, its something to do with security.. ie: not allowing it.

If the below code, fires at 13:02, and i unlock the pc at 13:10.. the code then runs...

hence, why i was looking for a solution to unlock the pc. i have not researched any other method of controlling the external program...other than sendkeys

Code: Select all

Private Sub Workbook_Open()
Application.OnTime TimeValue("13:02:00"), "Macro1"
End Sub

Code: Select all

Sub Macro1()
Dim ReturnValue, I
Dim DtrString As String
Dim Temp As String

'Set Shell = CreateObject("Wscript.Shell")
CreateObject("Wscript.Shell").SendKeys "^+{ESC}"

'SendKeys I & "{^}{%}{DELETE}", True
PauseApp 1
SendKeys I & ("mypassword"), 1

ReturnValue = Shell("C:\Documents and Settings\E99999\Desktop\New Pview\PView.exe", 1)
AppActivate ReturnValue

SendKeys I & "usernameforapp", True
PauseApp 1
SendKeys I & "{TAB}", True
PauseApp 1
SendKeys I & ("mypasswordforapp"), 1
PauseApp 1
SendKeys I & ("%{o}"), 1
PauseApp 1
SendKeys I & ("%{f}"), 1
PauseApp 1
SendKeys I & ("e"), 1
PauseApp 1
SendKeys I & ("All_Daily.QBX"), 1
PauseApp 1
SendKeys I & ("%{o}"), 1
SendKeys I & "{TAB}", True
PauseApp 1
SendKeys I & "{TAB}", True
PauseApp 1
SendKeys I & "{TAB}", True
PauseApp 1
SendKeys I & "{TAB}", True
PauseApp 1
Sheets("Main").Range("C12").Value = Now - 1
Temp = Sheets("Main").Range("C12").Value

DtrString = Left(Temp, 2) & Mid(Temp, 4, 2) & Mid(Temp, 9, 2)
SendKeys I & DtrString, 1
PauseApp 1
SendKeys I & ("%{x}"), 1
PauseApp 1


End Sub
----------------------------------------------------------------------------------------
Owing at LEAST 34 beers to other helpful forum members. Especially HansV!

User avatar
HansV
Administrator
Posts: 78235
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: auto login

Post by HansV »

SendKeys mimics user input, and that is disabled when the PC is locked.

You're going to have a problem when you upgrade to Windows 7. SendKeys is flaky under Windows 7, you can't depend on it.
Is there a way to script this PView application without using SendKeys?
Best wishes,
Hans

User avatar
Steve_in_Kent
4StarLounger
Posts: 415
Joined: 04 Feb 2010, 11:46

Re: auto login

Post by Steve_in_Kent »

I've asked the developers if i can pipe commands into the pview.exe program.

otherwise, i think i need excel to place the commands, without using sendkeys.
----------------------------------------------------------------------------------------
Owing at LEAST 34 beers to other helpful forum members. Especially HansV!

User avatar
Steve_in_Kent
4StarLounger
Posts: 415
Joined: 04 Feb 2010, 11:46

Re: auto login

Post by Steve_in_Kent »

for anyone else reading this in the future.

Micro$oft don't allow programs to open up the cntrl-alt-delete combination. only relatively few programs (VNC), and other remote log ins, can do it. and they are not saying how.

To automate and run other programs, a common theme on the net is to use a free third party app, called AUTOIT.

unfortunately, i can't use it, because it required admin access to install. but it looks as though its made for exactly this problem.

Thanks for you suggestion hans.
----------------------------------------------------------------------------------------
Owing at LEAST 34 beers to other helpful forum members. Especially HansV!

User avatar
jonwallace
5StarLounger
Posts: 1118
Joined: 26 Jan 2010, 11:32
Location: "What a mighty long bridge to such a mighty little old town"

Re: auto login

Post by jonwallace »

Autoit may need admin access to install, but it's possible to compile an autoit script into an exe file, write the script on another pc, compile and copy the exe to your pc of choice, job done. (debugging your script might be hard though, without all the gubbins on the target PC)

Also have a look at http://softwarespot.wordpress.com/code/autoit-portable/" onclick="window.open(this.href);return false;
John

“Always trust a microbiologist because they have the best chance of predicting when the world will end”
― Teddie O. Rahube