Logon Script

Posted on 2005-05-02
Last Modified: 2010-04-18
Dear Expert,

I'm not sure if this is the right place to ask for this kind of question. I have the following scenario, and I wish it to be done quickly using logon script method.

Files on server: f:\abc.xls
Logon Domain: ABCDE
Staff Group: STAFF


I need to drag a file (f:\abc.xls) from my server and copy to all staff PCs's desktop when the users under the group STAFF are logged on to the server. And the file permission is set to FULL.

Anyone know how to compile the logon script for this?

Kung Hui
Question by:kunghui80
    LVL 95

    Accepted Solution

    Download the IFMEMBER command line utility from Microsoft (  Place it in the logon script folder (\\server\netlogon) and then use the following script:

    \\server\netlogon\ifmember "YourDomain\Staff"
    If "%errorlevel%" == "1" Copy \\server\staff\abc.xls %userprofile%\desktop
    LVL 7

    Assisted Solution

    The second line in leew's post above should likely read something like:

    If "%errorlevel%" == "1" Copy \\server\staff\abc.xls "%userprofile%\desktop"

    Since there are spaces in the path, you may receive an error similar to "syntax is incorrect" without the quotes.  Depending upon how distributed your environment may be, you may also want to change the reference to NETLOGON to use the device that authenticated the user.  Something like this:

    %logonserver%\netlogon\ifmember "YourDomain\Staff"

    If you were opposed to using external utilities, you could likely complete this task using VBScript and ADSI (if your client OS is Windows 2000 or newer or you have the DS client installed on NT4).  Something similar to this saved with a .vbs extension would likely accomplish the task:

    Set objWSHNetwork = WScript.CreateObject("WScript.Network")
    Set objWSHShell = WScript.CreateObject("WScript.Shell")
    Set objGroup = GetObject("WinNT://" & objWSHNetwork.UserDomain & "/Staff")
    If objGroup.IsMember("WinNT://" & objWSHNetwork.UserDomain & "/" & objWSHNetwork.UserName) Then
        Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
        objFSO.CopyFile "\\server\staff\abc.xls", objWSHShell.ExpandEnvironmentStrings("%USERPROFILE%\Desktop")
    End If

    ' The only line that would require modification is the call to the CopyFile method, which would need an accurate source path (and possibly a different destination).  I typed this blind (as I suspect leew did :) , so post back if you encounter any errors.  Good luck!
    LVL 74

    Assisted Solution

    by:Jeffrey Kane - TechSoEasy
    Mind if I ask why you want to do this?  It seems like a rather complex way to deliver an Excel spreadsheet when Windows Sharepiont Services does exactly that and is a free addition to Server 2003.

    If you are unfamiliar with WSS, you may want to take a look because it could solve more than what you are attempting to do:

    LVL 2

    Author Comment


    Just to let you guys know i'm still trying on the solutions, will get back to you soon. Thanks a lot for all the suggestion & idea.

    Kung Hui
    LVL 2

    Author Comment

    Thank you guys,

    Learnt a lot from your comments.

    Kung Hui

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    The HP utility "HP Lights-Out Online Configuration Utility for Windows Server 2003/2008" could be of great use when it comes to remotely configure a HP servers ILO WITHOUT rebooting the server. We would only need to create and run scripts using thi…
    Learn about cloud computing and its benefits for small business owners.
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now