• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 620
  • Last Modified:

Logon Script

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
3 Solutions
Lee W, MVPTechnology and Business Process AdvisorCommented:
Download the IFMEMBER command line utility from Microsoft (http://www.microsoft.com/windows2000/techinfo/reskit/tools/new/ifmember-o.asp).  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
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!
Jeffrey Kane - TechSoEasyPrincipal ConsultantCommented:
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:  

kunghui80Author Commented:

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
kunghui80Author Commented:
Thank you guys,

Learnt a lot from your comments.

Kung Hui
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now