Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Creating a policy that runs a .bat file on loging in from a network share

Posted on 2011-10-03
3
Medium Priority
?
362 Views
Last Modified: 2012-05-12
Hi
I would like to run a .bat file from a DFS drive that runs every time a user logs in a Pc on the network,
The file is on a server called file2 which is shared as everybody’s Y drive. I thought I can run this through a system policy and would like help with the correct syntax please.
Drive as said is the y drive on all users Pc and is as follows Y: \\FILE2\FIle2 DFS
and the bat file I want to run is below

 @echo off
if exist %systemdrive%\policy\it_policy1.szp goto end
if not exist %systemdrive%\policy\ goto next
:next
mkdir %systemdrive%\policy
net use y: /d
net use y: \\file2\file2 DNS
copy y:\it_policy1.szp %systemdrive%\policy
Regedit /s y:\it_policy1.reg
net use y: /delete goto end
:end

Would this work or am I totally wrong?
0
Comment
Question by:dances1960
3 Comments
 

Author Comment

by:dances1960
ID: 36906793
Or since the Y drive already exists do I need this at all?
0
 
LVL 42

Accepted Solution

by:
kevinhsieh earned 1000 total points
ID: 36908262
No need to map the Y drive. You can use UNC paths instead. Group POlicy Preferences is preferred over regedit, especially when running on Vista/7/Windows 2008/R2 because of UAC. Group Policy Preferences can even copy over your file, so you don't actually need a script at all.

Group Policy Preferences
http://www.thincomputing.net/2007/11/27/windows-server-2008-group-policy-preferences-the-end-of-the-login-script-2/
http://technet.microsoft.com/en-us/library/cc771589.aspx
0
 
LVL 66

Assisted Solution

by:johnb6767
johnb6767 earned 1000 total points
ID: 36911811
There is a policy specifically for this....

Run these programs at user logon
http://technet.microsoft.com/en-us/library/cc975916.aspx
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Resolving an irritating Remote Desktop connection that stops your saved credentials from being used.
This program is used to assist in finding and resolving common problems with wireless connections.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

564 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