• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 605
  • 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

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

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