+ Post New Thread
Results 1 to 10 of 10
Coding Thread, Bat file that gets username and inserts it into a share location in Coding and Web Development; Hello, i'm not really a scripting\coding person, I just put ticks in the right boxes all day So I was ...
  1. #1
    jbailey's Avatar
    Join Date
    Jan 2011
    Posts
    77
    Thank Post
    21
    Thanked 31 Times in 17 Posts
    Rep Power
    34

    Bat file that gets username and inserts it into a share location

    Hello,

    i'm not really a scripting\coding person, I just put ticks in the right boxes all day

    So I was hoping someone could help me with something I am trying to do on a windows network, I have a server path: \\server\share\AUSER\files

    Where the AUSER can be different users each with a folder in that location.

    I want to create a mapped drive to that location, so can use net use D: \\blah...

    but, is there a way I could get the %username% of the logged on user and insert that into the \\ path to replace AUSER before mapping it as:

    \\server\share\NOAREALUSER1\files etc?

    Any help appreciated

    thank you.

  2. #2

    Join Date
    Jan 2014
    Location
    Isle Of Wight
    Posts
    86
    Thank Post
    90
    Thanked 8 Times in 8 Posts
    Rep Power
    3
    In a login script try:

    Net use d: "\\server\share\%username%"


    Sent from my iPad using EduGeek

  3. Thanks to IWDave from:

    jbailey (1st February 2014)

  4. #3
    jbailey's Avatar
    Join Date
    Jan 2011
    Posts
    77
    Thank Post
    21
    Thanked 31 Times in 17 Posts
    Rep Power
    34
    Hello,

    Thank you, but I need to find a way to insert the username into the middle of the path like: \\server\files\"unique username here"\files.

    So i'm thinking, something that gets the %username%, then concatenate the path around the username, then use the new unique path for the net use bit...

  5. #4

    Join Date
    Jan 2014
    Location
    Isle Of Wight
    Posts
    86
    Thank Post
    90
    Thanked 8 Times in 8 Posts
    Rep Power
    3
    The principle is the same

    Net use d: "\\server\share\%username%\files\"

    As far as I can remember at this time in the morning after a night out, this should work.


    Sent from my iPad using EduGeek

  6. #5
    jbailey's Avatar
    Join Date
    Jan 2011
    Posts
    77
    Thank Post
    21
    Thanked 31 Times in 17 Posts
    Rep Power
    34
    lol, you and me both...

    Of course that would work - Doh

    thanks very much

  7. #6

    Join Date
    Jan 2014
    Location
    Isle Of Wight
    Posts
    86
    Thank Post
    90
    Thanked 8 Times in 8 Posts
    Rep Power
    3
    Just to confirm the following string

    %username% is the actual command used to retrieve that information about who the user is.

    Just thought I'd clarify that.


    Sent from my iPad using EduGeek

  8. #7

    Join Date
    Jan 2014
    Location
    Isle Of Wight
    Posts
    86
    Thank Post
    90
    Thanked 8 Times in 8 Posts
    Rep Power
    3
    Quote Originally Posted by jbailey View Post
    lol, you and me both...

    Of course that would work - Doh

    thanks very much
    :-)


    Sent from my iPad using EduGeek

  9. #8
    p858snake's Avatar
    Join Date
    Dec 2008
    Location
    Queensland
    Posts
    1,490
    Thank Post
    37
    Thanked 175 Times in 151 Posts
    Blog Entries
    2
    Rep Power
    51
    What server environment are you running this on? There may be a better way to do this.

  10. #9
    jbailey's Avatar
    Join Date
    Jan 2011
    Posts
    77
    Thank Post
    21
    Thanked 31 Times in 17 Posts
    Rep Power
    34
    hi,

    win 2008 r2

    I had some luck creating separate variables and concatenating them together to form unique paths based on their %username%, this works for what I need, but I am sure there's smarter ways to do this.

    thanks

  11. #10

    sonofsanta's Avatar
    Join Date
    Dec 2009
    Location
    Lincolnshire, UK
    Posts
    5,003
    Thank Post
    874
    Thanked 1,458 Times in 1,002 Posts
    Blog Entries
    47
    Rep Power
    644
    2008R2, you can use Group Policy Preferences to do it ( User Config > Preferences > Windows Settings > Drive Maps). Use the %username% variable still to do something like:
    Action: Update
    Letter: D
    Location: \\server\share\%username%\files
    Label as: User Files

    etc.

    If you're not familiar with scripting it may be easier for you to read/diagnose issues going forward.

SHARE:
+ Post New Thread

Similar Threads

  1. How to Root a 7" Nurvo tablet and put it into recovery mode.
    By carmeruk in forum Netbooks, PDA and Phones
    Replies: 0
    Last Post: 5th June 2013, 04:34 PM
  2. Replies: 12
    Last Post: 29th September 2008, 10:57 AM
  3. Replies: 9
    Last Post: 17th January 2008, 12:45 PM
  4. Replies: 2
    Last Post: 25th October 2007, 11:54 PM
  5. BAT to EXE - one that works well and is free?
    By tarquel in forum Scripts
    Replies: 8
    Last Post: 3rd August 2007, 09:43 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •