Map network drives on event ID

Need to deploy a scheduled task to run a script only when a certain event ID occurs. The script must use LOGGED ON user credentials, not SYSTEM. The purpose of this is to make something map drives after a VPN connection is connected.

I already have a successful script that creates a scheduled task and gets trigged once the VPN connection has been established (event ID 20267). The following script will create a scheduled task and only run after VPN connection has been enabled. The task runs another script (file location embedded in the file.xml)

schtasks /delete /f /tn "TASK NAME"
schtasks /create /tn "TASK NAME" /ru SYSTEM /xml \\server\folder\file.xml

The problem with the above script is if it will try and map network drives for SYSTEM not current user.

I've tried the replacing /ru SYSTEM with %username% but it insist that I have a password. I obviously do not want the password to be visible in the batch file and the password will be different for everyone. I also do not want the user to have to type the password in every time after they connect the VPN.

Must be a way to do this...can anyone help?? Thanks

 




  • Edited by Kelvin.uk Wednesday, January 28, 2015 6:47 PM
January 28th, 2015 9:45pm

THe VPN connection mamnager can execute a script on connect.  You just need to configure that step.  It can execute scripts and comands at amny point like before conencting, aftterr, before disconnect, after and on error.

Free Windows Admin Tool Kit Click here and download it now
January 28th, 2015 10:27pm

Thanks this will definitely do the job, except it doesn't work on our most popular laptop model. Works perfectly on my PC and some other machines I've tested. Run the .exe that CMAK creates on T440 laptops causes a .NET run time error?

I'm not the only one either: 

https://social.technet.microsoft.com/Forums/windows/en-US/fa49851f-526f-4208-9c26-8bcfd8d5aec6/windows-connection-manager-profile-installer-has-stopped-working?forum=w7itproappcompat

Application: cmstp.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: exception code c0000005, exception address 000007FEFF116B3B
Stack:

 

 

cmstp.exe
7.2.7601.17514
4ce7a860
ole32.dll
6.1.7601.17514
4ce7c92c
c0000005
0000000000036b3b
990
01d03bbe34d2d1a2

January 29th, 2015 4:12pm

You need to run a repair on the laptop.  It may also be mmising updates to Net.

CMAK doen't really use net but may start with it. 

There ia also a way of manually building the text file of config data.  Just name it the same as the link file.  It doesn't have to be in an EXE to work.  The exe is for provacy and to keep people fromm altering it.

Free Windows Admin Tool Kit Click here and download it now
January 29th, 2015 5:23pm

cmstp.exe
7.2.7601.17514
4ce7a860
ole32.dll
6.1.7601.17514
4ce7c92c
c0000005
0000000000036b3b
990
01d03bbe34d2d1a2

This is not a Net error.  It is an old OLE error caused by either a missing patch or running a 32 bit cmak exe on a 64 bit system

January 29th, 2015 5:24pm

No I change that.

 c0000005, exception

This is an access violation.  Try running it the first time as an admin elevated.  It may be trying to write into the registry on init.

http://stackoverflow.com/questions/17168982/exception-error-c0000005-in-vc

It is likley you are missing C lib patches onthe laptop and some OLE patches.

Free Windows Admin Tool Kit Click here and download it now
January 29th, 2015 5:27pm

first you must verify your .NET Framework with this useful tool
http://blogs.msdn.com/b/astebner/archive/2008/10/13/8999004.aspx
http://www.registryquick.net/runtime/Fix-Runtime-error-1026-How-to-Fix-Runtime-error-1026-39453.html

http://blogs.msdn.com/b/astebner/archive/2008/10/13/8999004.aspx

January 29th, 2015 5:30pm

Thanks for the useful feedback. It was ran on a domain admin account, we use .NET very heavily and have not run into this before.

I have found a solution to my problem. I got CMAK to create the files for me (YourVPN.exe cmstp.exe .inf,  etc..) then put them all into a shared folder, then created a batch file like this:

\\Server\ShareFolder\YourVPN.exe /q:a /c:"\\Server\ShareFolder\cmstp.exe \\Server\ShareFolder\VPN.inf /s /su"

This runs perfectly for me. Very frustrating that the installer fails for some of our laptops but never mind.

Thanks very much for pointing out CMAK to me it is exactly what I was looking for.

Free Windows Admin Tool Kit Click here and download it now
January 29th, 2015 5:44pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics