0

At work I sometimes need to access any one of a number of network shares to view certain logs. The path is static \\hostname\share_folder_name but there are almost 50 servers setup like this which may need to be accessed.

Right now I have a basic batch written which will map the share for me, but currently it is specific only to the single host defined in the .bat file.

Example:

netuse A:\\\server1234\share_folder_name

I'd like to rewrite it so that it will prompt me to input ONLY the hostname each time as it's executed. (That way I don't have to modify it 50 different times).

Compo
  • 36,585
  • 5
  • 27
  • 39
Doctorj77
  • 115
  • 2
  • 2
  • 11
  • 1
    `set /?` read about the `/p` switch. – Stephan Jan 10 '18 at 16:27
  • 3
    Possible duplicate of [In Windows cmd, how do I prompt for user input and use the result in another command?](https://stackoverflow.com/questions/1223721/in-windows-cmd-how-do-i-prompt-for-user-input-and-use-the-result-in-another-com) – Instantsoup Jan 10 '18 at 17:26
  • 1
    another way is putting the hostname as a parameter to that batch file – phuclv Jan 10 '18 at 17:31

1 Answers1

0

With Stephan's suggestion I was able to figure it out

    @echo off
    set /p Hostname="Enter Hostname:"
    echo %Hostname%
    net use * \\%Hostname%\Share_Folder /Persistent:No
Doctorj77
  • 115
  • 2
  • 2
  • 11