After someone has logged off (Start button→Logoff) for the night, at a certain time in the morning I want to have the Task Scheduler automatically log into the Windows 7 user account (the opposite of Start button→Logoff) that is password protected. The machine is 64 bit. I am doing this so systems (vbs, vba, etc.) can prep files prior to the user showing up to work.
I was pretty sure this was possible, but I can't find it anywhere online, so I am wondering if it really is possible.
I have to this in a VBScript.
For security reasons I need to log him off at night, but I figured that part out (vbs from SO):
Set = wshell = Wscript.CreateObject(Wscript.Shell")
wschell.exec("shutdown.exe -L -F") 'logoff and force shutdown programs
Edit1: Using an answer from Sujith, I attempted to set this up. First I must point out that this is NOT a remote computer or connection. I'm trying to get the local computer to log back in to the user account.
I created logon.vbs with this vbs code:
Set = wshell = Wscript.CreateObject(Wscript.Shell")
wschell.exec("shutdown.exe -L -F") 'logoff and force shutdown programs
WScript.Sleep(5000)
computer = "computername"
username = "OTHERDOMAIN\user"
password = "password"
Set locator = CreateObject("WbemScripting.SWbemLocator")
Set wmi = locator.ConnectServer(computer, "root\default", username, password)
wmi.Security_.ImpersonationLevel = 3
In other words, I am logging off and right back on (avoiding the Task Scheduler so things are simplified). I also tried a lot of variations on this trying to get it to work. It logs me off just fine, but nothing happens after that. I have to login manually.
I also tried the Task Scheduler setting mentioned in Sujith's answer, but it never turned on that I could tell.
Edit2: Or please tell me what you need to provide an answer?