1. You are viewing our forum as a guest. For full access please Register. WindowsBBS.com is completely free, paid for by advertisers and donations.

Resolved Command line login to a NAS

Discussion in 'Other PC Software' started by elcajongunsfan, 2015/04/26.

  1. 2015/04/26
    elcajongunsfan Lifetime Subscriber

    elcajongunsfan Well-Known Member Thread Starter

    Joined:
    2012/01/01
    Messages:
    377
    Likes Received:
    12
    This question, again, is probably an Arie area of expertise but I could be wrong.
    So I have a NAS. I created a desktop shortcut to the NAS. I have to login with the user name and the password. However, even after logging in using the shortcut, if I drop to DOS and run net view, it sez "access denied ". If I go to windows explorer, which sees the NAS, and I click on it, I have to re-authenticate again.

    What i want to be able to do, is run a .bat file using net user or whatever the net command is, be able to login to the NAS and authenticate and then be able to copy files from the host to the NAS

    This would be cool:


    @echo off
    cls
    net user login admin password password \\iomega-nas
    copy c:\test.txt \\iomega-nas (some command line function that answers yes to overwrite existing file)
    exit


    I remember when I was a kid I ran a BBS using Remote Access with Doors like Tradewars, Barren Realms, etc in the FidoNet network, I would write .bat files to toss email when they came in.

    Those were fun times. But if anybody can give me some direction on copying files to a NAS using a .bat file I would appreciate it. And I know some folks might say just use some backup software, but my view is keeping files in their native format in a non continuous online routine is a another layer of protection that defeats ransomware exploits. I would prefer not to debate my view, let's just construct the .bat file

    Thanks all
     
  2. 2015/04/26
    rsinfo

    rsinfo SuperGeek Alumni

    Joined:
    2005/12/25
    Messages:
    4,038
    Likes Received:
    174
    How are you sharing files from NAS ? Is it SAMBA ?

    The easiest way I have found to share resources on LAN is to have the same username & password on every device that you want to access. That way, if you login to one you login to everything.
     

  3. to hide this advert.

  4. 2015/04/27
    SpywareDr

    SpywareDr SuperGeek WindowsBBS Team Member

    Joined:
    2005/12/31
    Messages:
    3,752
    Likes Received:
    338
  5. 2015/04/27
    elcajongunsfan Lifetime Subscriber

    elcajongunsfan Well-Known Member Thread Starter

    Joined:
    2012/01/01
    Messages:
    377
    Likes Received:
    12
    @rsinfo--Yes, it is a Seagate Samba

    @spy doc What does the i mean after net use?

    thanks
     
  6. 2015/04/27
    rsinfo

    rsinfo SuperGeek Alumni

    Joined:
    2005/12/25
    Messages:
    4,038
    Likes Received:
    174

    @spy doc What does the i mean after net use?


    net = command
    use i: = Drive mapping. \\iomega-nas would be mapped as I:
    \\iomega-nas = your nas name
    /user {username} = username on nas
    {password} = password on nas for the user
     
  7. 2015/04/28
    elcajongunsfan Lifetime Subscriber

    elcajongunsfan Well-Known Member Thread Starter

    Joined:
    2012/01/01
    Messages:
    377
    Likes Received:
    12
    A NAS is a network object--not a drive
     
  8. 2015/04/28
    rsinfo

    rsinfo SuperGeek Alumni

    Joined:
    2005/12/25
    Messages:
    4,038
    Likes Received:
    174
    You would be sharing something on that NAS. Substitute \\iomega-nas with \\iomega-nas\folder_to_be_shared
     
  9. 2015/05/02
    elcajongunsfan Lifetime Subscriber

    elcajongunsfan Well-Known Member Thread Starter

    Joined:
    2012/01/01
    Messages:
    377
    Likes Received:
    12
    OK, here is where I am stuck at:


    C:\Users\Owner>net use \\ba-23d106
    The password or user name is invalid for \\ba-23d106.

    Enter the user name for 'ba-23d106': mike
    Enter the password for ba-23d106:
    The command completed successfully.

    looking at above, I couldn't get the net use //device username password to work, I had to enter it manually as shown above.. My symbol syntax must be wrong (i.e. /:username or whatever) But the good news is I could "copy file \\ba-23d106|sharename successfully" after logging in. So now I need to tweak this command line to take the login.

    Thanks
     
    Last edited: 2015/05/02
  10. 2015/05/02
    SpywareDr

    SpywareDr SuperGeek WindowsBBS Team Member

    Joined:
    2005/12/31
    Messages:
    3,752
    Likes Received:
    338
    You forgot the:

    i:

    between the "use" and "\\ ".

    Now that we know all but the password, the command would be:

    net use i: \\iomega-nas /user:mike {password}

    But, replace that "{password}" part with your real password. (And don't forget the space between "mike" and your password).

    When you get it right, your iomega-nas will show up as drive I: in Windows Explorer.
     
  11. 2015/05/02
    elcajongunsfan Lifetime Subscriber

    elcajongunsfan Well-Known Member Thread Starter

    Joined:
    2012/01/01
    Messages:
    377
    Likes Received:
    12

    Doc, I don't understand why you want to call the NAS a drive, albeit virtual. When I open up networks in explorer, it already sees the NAS. When I click on it, that is when I need to login and authenticate.

    I don't think I need to map it. As you can in my command line output, I left out the login/auth procedure and thats what I need to add to the command line.

    Thanks for your time
     
  12. 2015/05/02
    rsinfo

    rsinfo SuperGeek Alumni

    Joined:
    2005/12/25
    Messages:
    4,038
    Likes Received:
    174
    Use net use i: \\ioemega-nas\shared_folder instead of use i:\\iomega-nas.
     
  13. 2015/05/03
    Arie

    Arie Administrator Administrator Staff

    Joined:
    2001/12/27
    Messages:
    15,174
    Likes Received:
    412
    It's not clear to me what the exact problem is at this point?

    Also, I assume you are using Windows 7?

    AFAIK this should be:

    net use DeviceName \\ComputerName \ShareName Password /user

    DeviceName: Assigns a name to connect to the resource or specifies the device to be disconnected. There are two kinds of device names: disk drives (that is, D: through Z:) and printers (that is, LPT1: through LPT3:). Type an asterisk (*) instead of a specific device name to assign the next available device name.

    \\ ComputerName \ ShareName : Specifies the name of the server and the shared resource. If ComputerName contains spaces, use quotation marks around the entire computer name from the double backslash (\\) to the end of the computer name (for example, "\\Computer Name\Share Name "). The computer name can be from 1 to 15 characters long.

    Password: Specifies the password needed to access the shared resource. Type an asterisk (*) to produce a prompt for the password.

    /user: Specifies a different user name with which the connection is made.
     
  14. 2015/05/03
    elcajongunsfan Lifetime Subscriber

    elcajongunsfan Well-Known Member Thread Starter

    Joined:
    2012/01/01
    Messages:
    377
    Likes Received:
    12
    Just trying to get the right syntax.. Right off the bat, I wanna leave out the drive mappng--that's a distraction right now

    Here's where I am at:

    @echo off
    cls
    net use \\ba-23d106 /user:mike [password]
    copy test.txt \\ba-23d106\file /Y
    exit

    Two last things: How do I hash out the password prompt, if possible, and how can I do a dir of
    the share name that the file was copied to?

    dir \\ba-23d106\file does not show the contents of that directory..But if i do a net view \\ba-23d106 it shows all the shares/directories of the NAS

    Thanks
     
  15. 2015/05/03
    TonyT

    TonyT SuperGeek Staff

    Joined:
    2002/01/18
    Messages:
    9,068
    Likes Received:
    396
    Well, a NAS is a drive according to Windows. Sure, it's also a network object, but all Network Attached Storage devices are assigned drive letters by Windows once mapped. If you map it, use Windows Explorer to access it, and allow Windows to remember your login credendials, then you can simply use a .cmd or .bat file with xcopy to copy files, or any other NT commands to manipulate files on the drive. And you will not need to use login credentials in the bat file.

    If worried about security, realize it's far more secure to have Windows store your login credendials than it is to store them as plain text in bat files.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.