Guest wayneywoo Posted August 9, 2005 Share Posted August 9, 2005 Hi all, I've been scouring the net trying to find an answer to this and have drawn a blank so hopefully someone on here can point me in the right direction. I need to detect if a PC is logged on to a network and then do something. The something I've got sorted so I won't bore you with the details but what is happening is that whether a PC is logged on or not, the something is still happening. I've tried using @LogonDomain to check if this equals the domain for the network that the PC should be logged on to and then if it does "equal" the domain in question then do the something but again, PC logged on or not, the something happens. The something is a scheduled task. Is there a way to use SCHTASKS so that the task only runs if a PC is logged on to a network? Thanks for the help!! Link to comment Share on other sites More sharing options...
LxP Posted August 9, 2005 Share Posted August 9, 2005 Welcome to the forums! Possibly a small syntax glitch? Could you please post your AutoIt code? Link to comment Share on other sites More sharing options...
Guest wayneywoo Posted August 9, 2005 Share Posted August 9, 2005 (edited) Thanks for the welcome LxP and hope to help others where I can! Here's the first script that places the necessary scheduled task in to the scheduler: RunWait("schtasks /create /tn TestLogon /tr ""C:\Windows\testlogon.exe"" /sc DAILY /st 21:58:30 /ru ""bellgas\zLocalAdmin"" /rp ""rtr3dnrd!""", "C:\Windows", @SW_HIDE) Here's the code from the program testlogon.exe that actually tests to see if the PC is logged on?.... If @LogonDomain = "BELLGAS" Then RunWait("schtasks /create /tn RebootNotification /tr ""c:\windows\blat.exe c:\windows\blatbody.txt -subject PC_Left_Logged_In -to SupportIT@coronaenergy.co.uk -server bell_appserver -f " & @ComputerName & """ /sc DAILY /st 21:59:00 /ru ""bellgas\zLocalAdmin"" /rp ""rtr3dnrd!""", "C:\Windows", @SW_HIDE) EndIf Thanks! Edited August 9, 2005 by wayneywoo Link to comment Share on other sites More sharing options...
LxP Posted August 9, 2005 Share Posted August 9, 2005 There doesn't appear to be a problem with the code itself. Have you tried switching the second RunWait() with a MsgBox() for debugging purposes? Link to comment Share on other sites More sharing options...
Guest wayneywoo Posted August 9, 2005 Share Posted August 9, 2005 Yeah and I get BELLGAS appear. Is there some other function in AutoIT that can be used to check if a PC is logged on? I understand that scheduled tasks run regardless of a PC being logged on or not. That's my problem. I need to check, at the point the scheduled task runs, that the PC is logged on. I think my problem with the code above (testlogon.exe) is that @LogonDomain will equal BELLGAS whether the PC is logged on or not because the PC is already a member of the domain even though it's not logged on?.... Link to comment Share on other sites More sharing options...
jdickens Posted August 9, 2005 Share Posted August 9, 2005 While $WantToDoAction If ping("Bellgas") then ;do the action WEND (not tested) J If I am too verbose, just say so. You don't need to run on and on. Link to comment Share on other sites More sharing options...
nobby Posted August 10, 2005 Share Posted August 10, 2005 I think the @logondomain relies on a registry entry which is set at the last logon and remains after logoff, so even if the PC is not logged on but just turned on that value will remain. You could try using a mapped drive as your check, if that suits your enviroment. Check "DriveMapGet", it could work CheersNobby Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now