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


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

Posted on 2011-10-03
Medium Priority
Last Modified: 2012-05-12
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
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

Would this work or am I totally wrong?
Question by:dances1960

Author Comment

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

Accepted Solution

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
LVL 66

Assisted Solution

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

Run these programs at user logon

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