/ Sign-up
Your question

Writing Scripts Client computers

  • Computers
  • College
  • Business Computing
Last response: in Business Computing
November 18, 2013 11:09:33 AM

Hello everyone,
I'm fresh out of college, thankfully I was able to land a job in the IT world. And I went computer networking. For the life of me I can't remember how to do a script. We just installed a windows 2012 server. And I'm wanting to write a script for the users. I want to do a drive where all there files go to. Including my documents, and favorites. Are the two things that get saved to the server.

Then I created a shared folder that has all the company files in it. HR type of stuff. Which i want that drive separate from there personal stuff. So one drive for personal files that they can only see. And one drive everyone can see. Could anyone help me out here? Please. I'll be very great full. I them to be able to sign into any computer and have them able to see and view there files like they usually do without any problems.

More about : writing scripts client computers

November 18, 2013 11:41:34 AM

ss202sl said:
Do you have a domain? You can easily do this with group policy on a domain.

Anyway if you create a script, then you could use the "net use" command to map the drives.

Thank you for the replay. I do have a domain controller. Right now underneath the user account, if you go to profile, then underneath home folder, i select connect, assign H as the driver and i select the user folder to save the files in. But when I go to the client computer. I have to physically move the documents folder to the H drive. I can't add the location to the documents area because it says H isn't index right. I just wanted to run a Login Script for all the users. So that if the computer crashes on them. They can sign into another computer and still save their documents same way no matter computer they are now. And not have to go to the H and save their documents.

And how would I do this in group policy? My school didn't go over that very well.
Related resources
November 19, 2013 7:05:01 AM

To answer your question about the script. I would set a log-off script that would synchronize the documents folder to the H drive. Look up robocopy (you'd have to put it on every computer in the system32 dir) it's part of the 2003 admin tools pack. Robocopy will synchronize 2 folders. You could create a script to robocoy the documents folder to H:\documents. I think something this would work:

Robocopy "%userprofile%\Documents" h:\documents

Test this out to make sure it works.
Here's an article for a GUI interface for robocopy - I use this
November 20, 2013 1:07:32 PM

That would be to much of pain for me. My company has 80 computers.
November 20, 2013 1:49:09 PM

The script would be pushed out in group policy by the domain controller. You can script it to copy the robocopy.exe from the server to the local system 32 directory(this could be in a computer startup script that you only have running for a week or so to get it on all computers).

Once that is done, you could set up the logon(or logoff) script to run everytime someone logs on that will copy their profile documents from that computer to the network.

You shouldn't have to manually touch every computer to get this done.
November 22, 2013 11:09:18 AM

While you could write a script to perform RoboCopy as suggested by ss202sl simply by entering that command in Notepad and saving the file as a .bat, a much better solution would be to use the existing Folder Redirection technology through Group Policy. The settings available in Folder Redirection are provided here on TechNet. To move the data to the new location, ensure the setting to move the contents to the new location is set.

As a new sysadmin, keep in mind the Springboard Series on TechNet. There you will find walkthroughs, tools, videos and resources for IT professionals that address the tasks and situations that are encountered as an IT pro working with the Windows Client.
November 27, 2013 11:16:28 AM

If you have a somewhat recent version of WMI on all your machines, I'd recommend using PowerShell scripts for logon/logoff or startup/shutdown scripts. PowerShell is really well thought-out, and highly functional.
December 4, 2013 11:18:32 AM

zarberg said:
If you have a somewhat recent version of WMI on all your machines, I'd recommend using PowerShell scripts for logon/logoff or startup/shutdown scripts. PowerShell is really well thought-out, and highly functional.

I would use Powershell. But I never learned Powershell, I will learn it when i further my education.


Best solution

December 6, 2013 5:55:42 PM

CisloIT said:

I would use Powershell. But I never learned Powershell, I will learn it when i further my education.

With the information you provided, we are limited in understanding your needs. That said, I saw nothing in your original post or follow-up posts that requires any scripting in a Windows 2012 domain environment. On your file server, create a folder for users' "personal" or home drives (e.g. D:\Home). Share this folder and give the group Everyone Full Control share permissions. I recommend setting the folder's NTFS permissions as follows:

Domain Admins (this folder, subfolders and files): Full Control
Domain Users (this folder only): Traverse folder / execute file, List folder / read data

On the domain controller or a domain-joined workstation with RSAT (remote server administration tools):

  1. Open the Active Directory Users and Computers (dsa.msc) Microsoft Management Console snap-in (you need to run it as a domain administrator).
  2. Locate and select the users that will have a mapped home/"personal" folder/drive.
  3. Press ALT+Enter or right-click and then click Properties.
  4. On the Profile tab, check the "Home folder" checkbox and select the Connect radio button.
  5. Select an appropriate drive letter from the drop-down (e.g. H: ).
  6. In the To field, type \\ServerName\Home\%username% where ServerName is the file server hostname and Home is the name of the share you created earlier. %username% is a placeholder, environment variable that is automatically replaced with the user name.
  7. Click OK.

  • If you didn't manually create individual user subfolders in the home shared drive earlier, the user's subfolders will be created automatically and users will be granted full control over their own subfolder. That's all you need to do for home folders / mapping. Much simpler than scripting. Personally, I'm a bit OCD when it comes to permissions, and to prevent users from accidentally deleting their home folder, I change their home folder permissions (this folder only) to allow them to traverse/execute their home folder, create/edit/delete subfolders and files (of their home folder) and read the home folder's permissions. Then I add another permission to the user's subfolder (subfolders and files only) and grant full control. This way, the user has full control of everything inside their home folder but can't delete their home folder by accident. To ease/centralize data backup, I recommend redirecting user's My Documents folders (or Documents libraries) to their home folder, and enabling offline files (at least for mobile users). You can use group policy to do this.

    For the HR/shared directory mapping, I'll assume you've already created the folder and shared it.

    1. On the domain controller or workstation with RSAT, open Group Policy Management Console (gpmc.msc).
    2. Expand the Forest/Domain structure.
    3. Right-click an organizational unit (OU) at or above the level of your users (if you don't have any OUs, right-click your domain) and click Create a GPO in this domain, and Link it here.
    4. Give the GPO an appropriate name (e.g User Targeted Policies; you'll probably want to use the policy for more than mapping drives).
    5. Click OK.
    6. Right-click the new GPO and click Edit. Expand User Configuration\Preferences\Windows Settings, and select Drive Maps.
    7. Right-click Drive Maps and click New > Mapped Drive. Under Action, select Create.
    8. In the Location field, type \\FileServer\HRShare where FileServer is the hostname for your file server and HRShare is the share name for the public/HR share.
    9. You can set the policy to use the first available drive letter or a specific drive letter (my recommendation; easier to provider user support).
    10. Click OK to save your changes.

  • If your users are local administrators on their workstations/computers, you may need to change set the registry value (DWORD) HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLinkedConnections to 1 for group policy preference-mapped drives to work. If needed, you can also use group policy preferences to push this registry setting to your workstations/computers.

    All that and not a single line of script! Before learning scripting, I would recommend putting effort into learning Windows Server 2008/2012 and Active Directory deployment and management (Microsoft Press is a good source for material; for some topics, you may need to go with a book intended for Server 2008). But yes, as you have opportunity, start picking up PowerShell scripting skills. To get started, see:

  • Hope this is helpful and whets your appetite for group policy! :D 
    December 9, 2013 6:55:41 AM

    @MotleyCrew Thank you. That will be very helpful.