Windows 7, kick logged on users like XP did
Source site: View forum post
Archive for the ‘ Windows 7 ’ Category
Source site: View forum post
My below script can be referenced inside BGInfo.
I might be worth downloading WMI Code Creator v1.0 This can be used to show what other information is ready for the picking.
Editing the below script will be able to report on any of the records WMI can throw your way.
Copy and paste the following code into a new .vbs file
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * From SoftwareLicensingProduct") Coltest = int(0) IsWinActivated = True For Each objitem In colItems IF int(objitem.GracePeriodRemaining) = 0 Then Coltest = True else Coltest = False IF Coltest = False then IsWinActivated = False Next IF IsWinActivated = False then call echo "Failed" ELSE call echo "Successful" END IF
OK, So at work I was asked to devise a way to make users return their laptops to us in IT for maintenance reviews. Now if anyone else has tried to get users to return hardware of maintenance on their own, it’s impossible…
So I have created a script that disables user logins after a X number of days. They also receive warnings after a different X number of days. In my environment the PC’s are not connected to the domain. they run Windows7 32-bit.
I would like to know if I could get this to work on a domain system, but I’m going to say no for now.. No user to lockout, but you could amend to corrupt some type of file.
Basicly, I have created a services that runs a script to check the current date is not grater than or equal to the date of lockout. The script then locks specific user accounts if the date is grater than or equal to today’s date. If it’s not grater than or equal to today’s date then it checks if the notify period is grater than or equal to today’s date. Again, if this is grater than or equal to today’s date it will start to display messages to the user. The background login wallpaper will also change to a warning. Once the lockout date as been reached or passed, the lockout action is committed and the users cannot login. The wallpaper on the login screen changes to access denied. Now the only user who can use the computer is the local administrator account.
So now they bring the PC back to you because it’s now useless to them in it’s current state. When you login it runs the notify.bat as it does when any user logs in, but instead or it’s normal action of displaying a pop-up message, it will reset the restriction an set the schedule back to X days in the future. This is because you logged in as administrator, not because you are an administrator of the PC.
This service will lock administrator accounts as well, it just works on username. So even if the user is a local admin, this will still work. Although they could go into the Win7Checker folder and edit the dates so to stop lockout. So a normal user account for users is best. The service runs as an administrator so can make changes that the current your can’t make.
There is also a grace of one extra login after expiry. this is to allow access if the PC have been off for months. It also allows updates of the wallpaper to take place.
1. Download 2. Extract files to a temp folder 3. Run install.bat as an administrator user with elevated privileges.
NOTE: When installing on x64 OS take the (x86) off the Program files on install of the RKTools.exe
5. Navigate to the folder "c:\windows\system32\Win7Checker\" 6. Right Click run.bat and click properties 7. Under the General Tab, Click Unlock 8. Repeat steps 6 & 7 for notify.bat & doff.exe in the same folder. 9. Reboot And COMPLETE 10. Use the .psd (Adobe Photoshop 3 document) to create your own JPG messages..
NOTE: the JPG files have to be less than 256kb in size otherwise windows will not use it.
Below is a basic idea of what each files does.
BackgroundDefault.jpg - Normal background wallpaper. BackgroundDefault2.jpg - Warning Wallpaper. BackgroundDefault3.jpg - Access Denied Wallpaper. doff.exe - Required for processing the dates. notify.bat - Display messages. Admin user login does a reset. run.bat - service run script. Main processing script date.txt - This holds the date of expiry notify.txt - This holds the date of starting to notify user. today.txt - This holds the current date for processing. bginfo.txt - This holds a readable date of expiry, I use BGInfo to put this on the desktop wallpaper.
Microsoft Information:
Other Information:
1. Easy solution to shortcuts disappearing… create a folder on your desktop called Shortcuts and put all your desktop shortcuts in the folder. Then “send” the shortcuts back to your desktop from the folder. Now they won’t disappear because they are linked to the desktop not to the correct location.
2. PowerShell Amend
BAT FILE FIX
@echo ************************************* @echo ** REMEMBER : Run as Administrator ** @echo ************************************* @pause %SystemDrive% cd \Windows\diagnostics\scheduled\Maintenance takeown /F TS_BrokenShortcuts.ps1 icacls TS_BrokenShortcuts.ps1 /grant "%USERNAME%":F @echo “” @echo ***************************************************************** @echo ** Search for '-gt 4' and replace with '-gt 400' and then SAVE ** @echo ***************************************************************** @echo "pess to edit file" @pause notepad TS_BrokenShortcuts.ps1
This works on a std PC and a Domained Machine
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon] "DisableCAD"=dword:00000001 "AutoAdminLogon"="1" "ForceAutoLogon"="1" "DefaultPassword"="PASSWORD" "DefaultDomainName"="DOMAIN" "DefaultUserName"="USERNAME"
The code allows you to check registry settings
On Error Resume Next sResults = "" Set oWShell = CreateObject("Wscript.Shell") Call GetAppVersion("Internet Explorer", "HKLM\SOFTWARE\Microsoft\Internet Explorer\Version") Call GetAppVersion("Java", "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{26A24AE4-039D-4CA4-87B4-2F83216016FF}\DisplayVersion") msgbox sResults Set oWShell = Nothing Sub GetAppVersion(sApplication, sRegPath) On Error Resume Next sTemp = oWShell.RegRead(sRegPath) If Err.Number <> 0 Then sResults = sResults & "Version not found for " & sApplication & "." & vblf Err.Clear Else sResults = sResults & sApplication & " Version: " & sTemp & vblf End If End Sub