Jesin's Blog

Welcome to the Portal of Technology

  • Facebook
  • GitHub
  • RSS
  • Twitter
  • Home
  • Categories
    • Domains
    • Linux
    • Networking
    • PHP
    • Virtualization
    • Web Design
    • Web Servers
    • Windows
  • WordPress Plugins
    • Custom Error Pages
    • HTTP Digest Authentication
    • Mailgun Email Validator
  • Toolbox
    • DNS Lookup Tool
    • htdigest Generator Tool Online
    • htpasswd Generator Tool Online
    • HTTP Headers Lookup Tool
    • MD5 Encryption Tool
    • Open Port Check Tool
    • SHA-1 Encryption Tool
    • URL Encoding/Decoding Tool
  • About Me
  • Contact Me
  • Sitemap
Home ›
Windows ›
Windows Logon and Logoff Scripts

Windows Logon and Logoff Scripts

February 26, 2011 Windows Jesin A 1 Comment

windows category thumbnail

Create windows scripts and execute them when logging on or logging off. Windows Logon and Logoff scripts can be set in the group policy editor (gpedit.msc). In a workgroup environment when a windows logon or logoff script is set it works for all the users on that computer. Logoff and Logon scripts can be very useful to perform automated tasks such as take backups synchronize certain files and folder, delete temporary files etc. These scripts can be windows batch files (.bat), VBscripts (.vbs) or any other script than should be run on Logoff or Logon.

This tutorial will describe how to configure logon and logoff scripts in windows and show a practical example of how this can be used day to day. The following are the locations where Logon and Logoff scripts are stored.

C:\WINDOWS\system32\GroupPolicy\User\Scripts\Logon
C:\WINDOWS\system32\GroupPolicy\User\Scripts\Logoff

To configure logon and logoff scripts go to Start -> Run and enter gpedit.msc navigate to

User Configuration\Windows Settings\Scripts (Logon/Logoff)

open the desired item (Logon or Logoff) go to add and set the location of the file. You can specify additional parameters if your script requires.

A practical example

Now a situation, you work on a windows computer and before winding up you move all the files to a network mapped drive say Z: The next time you want to work with these files you copy them back to the local partition. This operation can be automated using logon and logoff scripts. When a user logs in all files related to that user is copied from Z: drive to the local C:\Document and Settings\username\My Documents when the user logs off all files from the local filesystem are moved back to the network mapped Z: drive.

First for the logon script, create a file named logon.bat open using a text editor and paste the following command. The Y parameter overwrites any existing files in the destination.

copy -Y "Z:\%username%\*" "C:\Document and Settings\%username%\My Documents\*"

Next for the logoff script create a file named logoff.bat and place the following code

move -Y "C:\Document and Settings\%username%\My Documents\*" "Z:\%username%\*"

Now go to group policy editor and set the files as logon and logoff scripts and see the magic !!!

Related posts:

windows category thumbnailHide Last Logged in Username in Windows (Registry Tweak) windows category thumbnailHide Last Logged in Username in Windows (Security Policy) windows category thumbnailHow to setup roaming user profiles in Windows Server 2008 windows category thumbnailUsing Sendmail on Windows windows category thumbnailInternet Explorer Change User Agent

Comments

  1. nokukhanya says

    August 5, 2015 at 1:27 am

    This was short but very resource full to technical support student like myself.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Get a wealth of information delivered to your inbox. Subscribe and never miss a single article.

  • Tutorials and howtos
  • Code, scripts and commands
  • Online Tools

* No spam, unsubscribe anytime

Hire Me

  • SSL installation and hardening (A+ on Qualys SSL test)
  • Apache & Nginx configuration
  • Email deliverability improvement (10/10 on Mail Tester & MailGenius)
  • WordPress customization, optimization and migration
  • and much more…

    Tools

    • DNS Lookup Tool
    • htdigest Generator Tool Online
    • htpasswd Generator Tool Online
    • HTTP Headers Lookup Tool
    • MD5 Encryption Tool
    • Open Port Check Tool
    • SHA-1 Encryption Tool
    • URL Encoding/Decoding Tool

    Nav

    • Home
    • About Me
    • Contact Me
    • Privacy Policy
    • Sitemap
    Vultr SSD VPS

    Creative Commons License
    Jesin's Blog by Jesin A is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
    Based on a work at websistent.com.