Need .CMD script module

Discussion in 'Scripting' started by David H. Lipman, Jun 16, 2010.

  1. Using SharePoint.
    It doesn't like '.' in Usernames such as; David.H.Lipman and converts them to '_' so in
    SharePoint MySites the user name is; David_H_Lipman

    Need a .CMD script snippet that will take %USERNAME% and convert it to a string with '_'
    replacing all occurances of '.' within the Active Directory Username.
     
    David H. Lipman, Jun 16, 2010
    #1
    1. Advertisements

  2. This is what I used on a similar occasion:
    SET MyUsername=%@REPLACE[.,_,%USERNAME]
    with 4NT as command processor; I believe 4NT now succeeded by "Take
    Command", which includes the free TCC/LE.

    I guess it's possible to do it with CMD, but less concisely and clearly.
     
    Michael Bednarek, Jun 17, 2010
    #2
    1. Advertisements

  3. From: "Michael Bednarek" <>

    | On Wed, 16 Jun 2010 17:00:19 -0400, "David H. Lipman" wrote in
    | microsoft.public.windows.server.scripting:

    | This is what I used on a similar occasion:
    | SET MyUsername=%@REPLACE[.,_,%USERNAME]
    | with 4NT as command processor; I believe 4NT now succeeded by "Take
    | Command", which includes the free TCC/LE.

    | I guess it's possible to do it with CMD, but less concisely and clearly.


    4NT ? Hmmm, that's in the JP Software family of interpreters such as 4DOS which was
    OEM'd to Norton and was called NDOS ?

    It was great but... It is not a viable option on our Active Directory Domain.

    The CMD.EXE, .CMD, batch processor is what I may only be able to use :-(

    The objective would be such as I can eventually do...

    net use Z: \\myspad.oursite.com@SSL\DavWWWRoot\Firstname_Lastname

    or

    net use Z: \\myspad.oursite.com@SSL\DavWWWRoot\Firstname_MI_Lastname

    Where aall the Domain Accounts use the naming convention; Firstname.MI.Lastname or
    Firstname.MI.Lastname

    Personally I'd much rather use the latest version of KiXtart. I have already written, and
    tested, a KiXtart script. However our central IS group is in a time warp and is using
    KiXtart v3.60 that is (believe it or not) 11 years old! I have to write a letter of
    justification of upgrading the KiXtart interpreter on the Login Server to the latest
    version and can only "hope" they will do it. If that fails, I need a fall back position
    which would be using the .CMD batch interpreter of Vista.
     
    David H. Lipman, Jun 17, 2010
    #3
  4. Your loss. I couldn't do my job without it.
    Maybe Microsoft's PowerShell can do it, too.
    This is a bit more complicated than the original brief description; I
    suppose you only want to replace the full stops after the last back
    slash. This would do that:
    SET Target=\\myspad.oursite.com@SSL\DavWWWRoot\Firstname.MI.Lastname
    Net Use Z: %@LEFT[%@INDEX[%Target,\,-1],%Target]%@REPLACE[.,_,%@RIGHT[-%@INDEX[%Target,\,-1],%Target]]

    Commiserations.
     
    Michael Bednarek, Jun 17, 2010
    #4
  5. It's actually pretty straight forward in CMD:

    SET SHAREPOINTNAME=%USERNAME:.=_%

    Should work in XP and later Windows versions, possibly in Win2k but I
    don't have one handy to test.
     
    Zaphod Beeblebrox, Jun 17, 2010
    #5
  6. From: "Zaphod Beeblebrox" <>






    | It's actually pretty straight forward in CMD:

    | SET SHAREPOINTNAME=%USERNAME:.=_%

    | Should work in XP and later Windows versions, possibly in Win2k but I
    | don't have one handy to test.

    That is awesome and very eloquent - Danke !
     
    David H. Lipman, Jun 17, 2010
    #6
  7. From: "Zaphod Beeblebrox" <>






    | It's actually pretty straight forward in CMD:

    | SET SHAREPOINTNAME=%USERNAME:.=_%


    Man that works well..

    SHAREPOINTNAME=david_h_lipman

    USERNAME=david.h.lipman

    net use Z: \\myspad.oursite.com@SSL\DavWWWRoot\%SHAREPOINTNAME%
     
    David H. Lipman, Jun 17, 2010
    #7
  8. Glad I could help. It's not often the experts have left low-hanging
    fruit like this for me to pluck when I wander through a group (but
    I'll take it when it happens! (-; )

    --
    Zaphod

    Pan-Galactic Gargle Blaster: A cocktail based on Janx Spirit.
    The effect of one is like having your brain smashed out
    by a slice of lemon wrapped round a large gold brick.
     
    Zaphod Beeblebrox, Jun 18, 2010
    #8
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.