WSH and Locked Workstation

B

Billy

My computer is on 24x7, has no screensaver nor does it use
power management. However, I do need to keep it locked
(Ctrl-Alt-Del, Lock Computer) when I am absent.

I have a WSH script that uses Notepad to open an ASCII
file, activate Notepad, and then issue a bunch of Sendkey
statements to manipulate the contents of the file before
saving and exiting.

The script works flawlessly when the computer is not
locked but never when it is locked - it starts Notepad,
opens the file but appears to fail to activate Notepad.

Am I correct in assuming that "objShell.AppActivate
("Notepad")" statement can not make a window active when
the computer is locked? If so, is there a workaround?
 
R

Ray at

Can't you just open the file with the FSO and do what you have to do with
it? SendKeys is an absolute last resort, in my opinion. And no, you cannot
use sendkeys when the workstation is locked. I've heard other people
mention an application called "AutoIt" that can do things like sendkeys, but
I don't know anything about it. It may be worth searching for if you don't
want to use the FSO (or something else) to modify the file contents.

Ray at home
 
R

Ray at

p.s. I didn't notice which group this was in. You'd have better luck
posting such messages in .scripting.vbscript.

Ray at home
 
P

Phil Robyn

Ray at said:
Can't you just open the file with the FSO and do what you have to do with
it? SendKeys is an absolute last resort, in my opinion. And no, you cannot
use sendkeys when the workstation is locked. I've heard other people
mention an application called "AutoIt" that can do things like sendkeys, but
I don't know anything about it. It may be worth searching for if you don't
want to use the FSO (or something else) to modify the file contents.

Ray at home

AutoIt is free from http://www.hiddensoft.com
 
T

Torgeir Bakken (MVP)

Billy said:
My computer is on 24x7, has no screensaver nor does it use
power management. However, I do need to keep it locked
(Ctrl-Alt-Del, Lock Computer) when I am absent.

I have a WSH script that uses Notepad to open an ASCII
file, activate Notepad, and then issue a bunch of Sendkey
statements to manipulate the contents of the file before
saving and exiting.

The script works flawlessly when the computer is not
locked but never when it is locked - it starts Notepad,
opens the file but appears to fail to activate Notepad.

Am I correct in assuming that "objShell.AppActivate
("Notepad")" statement can not make a window active when
the computer is locked? If so, is there a workaround?

Hi

It is the Sendkeys that does not work while the computer is locked.

As Ray wrote, use the WSH FileSystemObject to read the content of the file into
your script and then use the WSH text manipulation methods on it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top