Re: Running Login Script after establishing a VPN connection

Tech-Archive recommends: Fix windows errors by optimizing your registry




"TJCooper1972" <TJCooper1972@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:349C4FE0-1183-4A8D-A02F-CD6F4D9E8258@xxxxxxxxxxxxxxxx
I have to figure out how to parse the file correctly. I dont do a lot of
scripting, so everything is slow going for me. The file has a number of
mapped drives and commented lines. I can ignore commented lines and focus
on
lines that start with a $. This is what I have to parse:

----------

;
; Windows NT and Windows For Workgroups Logon Script
;

$NameLine = "my region"
$HelpDesk = "555-555-5555"

$Drive1 = M:
$Name1 = "drivea"
$Dir1 = "\\server\mapm"

$Drive3 = W:
$Name3 = "driveb"
$Dir3 = "\\server\mapw"

;
; the following should reflect appropriate mapped drive for location
;

$Drive4 = H:
$Name4 = "drivec"
$Dir4 = "\\server\maph"

$Drive5 = P:
$Name5 = "drived"
$Dir5 = "\\server\mapp"

$Drive6 = k:
$Name6 = "drivee"
$Dir6 = "\\server\mapk"

Your reply is a little too vague to give you a precise
recipe but the following batch file may well do the job.
Here is what you need to do:
- Use copy & paste to copy the code into a batch file.
- Adjust Lines 03 and 04 to suit your own environment.
- Remove the line numbers.
- Test the batch file.
- When happy with the result, activate the batch file by
removing the word "echo" on Line 09.

01. @echo off
02. setlocal enabledelayedexpansion
03. set ShareName=$Dir6
04. set ShareList=c:\Shares.txt
05.
06. for /F "tokens=1,2 delims==" %%a in ('type %ShareList%') do (
07. set Share=%%a
08. set Share=!Share: =!
09. if /i !Share!==%ShareName% echo call %%b\netlogon.bat
10. )
Feel free to ask if you want to know how and why the code works.


.



Relevant Pages

  • Re: Command line : how to get the .cmd file name Im running
    ... I tried to use %CD%, but it seems that if the startup directory is a UNC share, it is unusable. ... (in a batch file, %0 is the path to the batch file including the batch ... @echo off ... torgeir, Microsoft MVP Scripting, Porsgrunn Norway ...
    (microsoft.public.windowsxp.general)
  • Re: How to know the PC domain
    ... I tried with batch file but i receive the message 'echo is off' and not the ... > Set colComputer = oWMI.ExecQuery _ ... > torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway ...
    (microsoft.public.windowsxp.configuration_manage)
  • Re: Delete all files in certain folders across multiple users
    ... scripting period. ... This little batch file will what you want. ... echo Cleaning up user "%*" ... You must determine if it is safe to delete the folders you specified. ...
    (microsoft.public.scripting.vbscript)
  • Re: What is the command line scripting language?
    ... from a command prompt, they are just bunched together in a file. ... Echo This batch file will Force the Update Detection from the AU client by ... torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: ...
    (microsoft.public.windows.server.scripting)
  • Re: Renaming a file
    ... I'm trying to create a batch file that renames a certain zip file. ... del %tmp%\today.vbs ... echo Todays date: %today% ... torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: http://www.microsoft.com/technet/scriptcenter/default.mspx. ...
    (microsoft.public.windowsxp.general)