I'm trying to write a bash script and need to learn how many seconds past since user logged in(xsession). I'm searching for hours and i couldn't find a solution for that. I found only uptime command but i think it's only get computers running time.
To be more clear...
I'm writing gui with gtkdialog and i have "hide gui on startup" option. I can start program when user login and if user check that option i can hide gui. But if user wants to configure options and open the gui again???
My only solution for that. I can write the condition if user logged in 30 sec ago or if not checked "hide gui on startup" option than show gui. So if user click program in xsession can see gui again.
You can get information about users currently logged in with te w and the who commands. If you would like to see a log about recent sessions (with login and logout time, etc) use the last command.
Related
I have made an apple script that takes pictures of people using PhotoBooth. However, every time I open it, it asks for permission to use PhotoBooth instead of instantly taking a photo. I have already set the [Security & Privacy > Privacy > Automation > Allow Script to use PhotoBooth] but it still prompts me every time to allow PhotoBooth. Is there any way to fix this without downloading anything or changing my script? Thanks!
Is your script saved as an applet? While 10.14 remembers previous user-granted permissions, it will re-prompt every time the script changes. Traditional AppleScript applets implement a basic persistence mechanism that saves the current state of the script's top-level variables upon quitting. Discussion here:
https://forum.latenightsw.com/t/mojave-and-applescript-applets/1563/13
One quick trick for avoiding any persistent state:
script MyScript
-- original code goes here…
end script
on run
local tempScript
copy MyScript to tempScript
run tempScript
end run
If you do need to save state (e.g. user preferences) between runs, then you'll either need to code sign the applet or else use an alternate mechanism (e.g. NSUserDefaults via AppleScript-ObjC).
I am probably asking this question in the wrong place (Maybe I should go to an OS forum) - but I still want to know this.
I am using a windows- 7 machine for my work. I log in everyday, do some work and then log off. I take a few short breaks in between when I Lock (Windows+L) my laptop.
I have to account for the number of hours worked by the end of the week which means the time for which I was logged in to this machine.
The problem is that I do complete all the work that is assigned to me, but I forget to keep track of the exact hours I was logged into this machine. I may have logged in at 5 am in the morning and then logged off at 3 in the afternoon- and I dont have any manual logs of my time.
Is there someplace where windows keep a weekly track of
Say per day:
"The Latest log-off time - The Earliest Log in time" into that system for a particular day. I only need these logs for a week.
any heads up would be appreciated. Thanks
I have tried to solve this problem for years, but only recently found a solution that:
May be implemented without administrative privileges
Does not require extra software
Kudos to Guiding Tech for providing the solution shown below. Change the suggested folder and filenames as you desire, but adjust the batch file code and Task Scheduler commands accordingly.
Part One: Create the script
Create the folder where you would like the script and text log file of login and lock/logoff to reside. For this example, I will presume the desired folder is "C:!Scripts\Login\"
Create a new text file in the folder and name it login.bat. A quick way to do this is to right-click a blank space in the folder view, and select New > Text Document, then name it login.bat.
Open the text file and copy and paste in the following code:
echo off
set datecode=%date:~-4%-%date:~7,2%-%date:~4,2% %time:~0,2%:%time:~3,2%:%time:~6,2%
if "%1"=="i" echo %datecode% - Logged in >> C:\!Scripts\Login\login.txt
if "%1"=="o" echo %datecode% - Locked computer >> C:\!Scripts\Login\login.txt
Save the new batch file
Part Two: Create the login task
Open Task Scheduler. Press the Windows key, and then type "Task Scheduler" and click on the application that appears with that name. Alternatively, use Start > Run (Win + R), type taskschd.msc and press Enter.
Select Create Task... from the actions on the right hand side
Enter a task name like "Log the login date and time"
Click on the Triggers tab and add a new trigger. Select:
Begin the task: At log on
Specific user: This should be your Windows account name.
Click OK to add the trigger.
Add another trigger, except this time select Begin the task: On workstation unlock. Click OK to add the trigger.
Click on the Actions tab. Add a new action and point it to your login script with the argument i.
Click OK to add the action.
7. (Optional – Only required if you are using a laptop) Click on the Conditions tab and uncheck the box that says Start the task only if the computer is on AC power. Click on OK to create the task.
Part Three: Create the lock task
In Task Scheduler, select Create Task… from the actions on the right hand side.
Enter a task name like Log the lock date and time.
Click on the Triggers tab and add a new trigger. Select:
Begin the task: On workstation lock
Specific user: This should be your Windows account
Click OK to add the trigger.
Click on the Actions tab. Add a new action and point it to your login script with the argument o.
Click OK to add the action.
(Optional – Only required if you are using a laptop) Click on the Conditions tab and uncheck the box that says Start the task only if the computer is on AC power. Click on OK to create the task.
Part Four: Testing that everything is working as expected
Your work is now complete. You just need to test that everything is working as expected. Just lock your computer by hitting WIN+L and log back in. If you followed the instructions properly, you should now have a file called login.txt in the same folder as your script. This file should contain a log of each time you log in and out of your computer.
You can use the event log to check when you logged in and logged put (or locked the PC for that matter) but you would have to do that by hand.. You could write a program to do that but that would be hard.
BTW: You will need to enable a group policy or something to enable login events. Have a look here
As all know, Win8's windows logon sound setting does't work, so I decided to run a program to play a welcome sound right after user logon.
I write a vbs file, and I added it in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run.
It works, but I still have to wait a few seconds to listen the welcome music after user logon. I think that might be because my vbs file doesn't run immediately after user logon, it might have to wait other programs that are also listed on startup menu before starting.
Could you help me?
(I know my english is so bad, I hope you can understand what I say (●'◡'●) )
For UI automation testing purposes, I need to click a button on the windows 8.1 logon screen where it prompts to select a user account. And no, I do not need to select a user account. Its a button in particular. I am not quite sure how to do it. I tried to include my script as a Group Policy (gpedit.msc) startup script but its not working. But the same works when I include it as a Group Policy logon script.
I tried to directly include it in the registry as well under Group Policy startup scripts but it didn't work. Adding the script in the registry to be executed at logon works. My script is in Python.
Has anyone done anything like this by adding their script through gpedit.msc? (I might be doing something wrong at this step in that case). Other methods and ideas are good too. Any help is much appreciated. :)
I have the following problem: I've created scheduled jobs that are only containing calls to a cmd and have parameters that contain things like project name etc.
I know about the fact that you have to set it to "Run only when user is logged on" if you want to see the window (cmd in this case) and also have to uncheck "hidden".
Until a week or two ago that worked fine, the box was showing up. Now the exact same job does no longer show the dos box. I suspect a windows update but I couldn't find anything useful in the update history of the server.
Do you guys have any idea what it might be? I tried switching the settings between the two "run as" options, tried setting it to hidden, tried switching "configure for" around...
The jobs run ok most of the time, the output is generated in most cases but if things go wrong I want to see the shell and not have to pipe everything to a .txt :/
I tried looking on google etc for a solution but only found other problems or the "my tasks run hidden if I choose run whether user is logged on or not" solutions.
Any ideas or hints? Anything would be really appreciated!
As you use scheduler to automate running of some rutine task, what's the point of manually checking/controlling it's execution? It is sort of negates benefit of automation and should be done through some basic logging (you can built in in your task scripts or whatever it is) and even viewer where you can check whether your tasks was run successfully.
Why it is required to you to see this window? Are you really need it?
If you state that it used to work OK then check logs does your tasks run successfully all the tine but hidden from you or it's something else?
Try to re-create / create new task & check whether it is not run hidden with settings you use.
From your description your scheduled task indeed configured so that it should be visible, namely:
- It is scheduled under your current logon account.
- It is configured to Run only when user is logged on.
These 2 conditions required for task to be visible.
The Hidden checkbox in the Windows Task Scheduler has nothing to do with how the scheduled program is displayed (in fact, there are no display options for scheduled tasks like there are with shortcuts). The Hidden checkbox controls whether or not the task is displayed in the Task Scheduler. If you set check it, then Task Scheduler will not display it unless the View Hidden Tasks option in the View menu is selected. You should still see the program window when it runs even if it is checked.
You did not indicate what changes you had made to the task between the time it worked and when it stopped, but one change that would prevent the window from being shown is if you had changed the account that runs it to the SYSTEM account. That is a trick that people use to hide the window (which is not a good solution, especially since there are much safer options), so if you had changed that, then you would not see it.
(The OP may have already fixed this by now), but if anyone else has the same problem, check the user account. If the task is not too complicated, you could do as Mikhail suggested and re-create the task from scratch.