We can run own scripts on Windows platform like the time of logon or Windows logoff. Using this feature we can run own maintenance tasks or user-defined tasks.
For this, we will need an in-build Windows tool named group policy editor. This tool is the part of Windows XP pro, Windows Vista Business, Enterprise, Ultimate and Windows 7 Professional, Enterprise, Ultimate. Other versions of the Windows do not support this tool.
In Windows 7 start the group policy editor by clicking start and type run in search bar. In the newly opened run windows type gpedit.msc and hit enter. However in Windows 7/Vista you can just type gpedit.msc in search bar and also you must have administrator rights for this.
To run a specific user-defined script while user is logging off or logging on, Navigate to “Local Computer Policy >User Configuration >Windows Setting >Scripts(Logon/Logoff)”
On the right-side plane you will see the logon/logoff scripts containers. If a user wants to run the script while he is logging on, then double-click on the logon which is on the right side of the window . Then click on the Show Files button which will open a new window where you paste your script file.
As the scripts are in the respective folder click add button and browse for the particular script, you may add script parameter also if the scripts wants any type of parameters.
You may add many scripts, edit and remove them also.
As if the user wants to open the optical drive at the time logon ![]()
Just write this script on the notepad and save it as cd.vbs
do
Set oWMP= CreateObject(“WMPlayer.OCX.7″)
Set colCDROMs= oWMP.cdromCollection
if colCDROMs.Count>=1 then
For i=0 to colCDROMs.Count-1
colCDROMs.Item(i).Eject
Next ‘ cdrom
End if
loop
this will eject the optical drive at the time of user logon.
Or if you want to popup hello box on logon, Just type the following string in notepad:
MsgBox “Hello…!!!”
Save it with .vbs extension.
this will popup a box saying Hello…!!! at the time of logon.
This may be very useful if you wants to run your own scripts and these are run by The Microsoft Windows Script Host (WSH) which is an automation technology for Microsoft Windows operating systems that provides scripting capabilities comparable to batch files, but with a greater range of supported features.
Note: if you do not want to run the particular script then just delete or remove it from the respective field. And also you can only run VBScripts and Jscripts because WSH supports only these scripts extentions. If you wants to run other scripts then you will have to install the Script Host for that script.





