?
Solved

bat data

Posted on 2011-10-31
18
Medium Priority
?
263 Views
Last Modified: 2014-05-15
i try to a .bat file create.But i would like password and login name  login.


net use H: \\192.168.0.3\share$ loginname: test password:testpassword domainname:test.intern
0
Comment
Question by:orkinos
  • 6
  • 5
  • 3
  • +1
16 Comments
 
LVL 85

Expert Comment

by:oBdA
ID: 37055720
Try this (put double quotes around the password!):
net use H: \\192.168.0.3\share$ "testpassword" /user:domain\test

Open in new window

0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 37055723
Correct syntax is

net use h: \\server\share /user:domain\username password
or
net use h: \\server\share /user:username@domain.local password
hth

Steve
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 37055731
Posted same time there...

Or use /savecred

net use h: \\server\share /user:domain\username /savecred

It will prompt for password and not ask next time.
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

 
LVL 7

Expert Comment

by:Rahul_Gade
ID: 37055756
See if this batch file helps you, you need net logon before net use:

set /P UName="Enter the User name : " 
set /P PWD = "Enter the password : " 
NET LOGON %UName% %PWD%
NET USE \\server\Cloud /USER:%UName% %PWD%

-Rahul
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 37055820
No you don't!

Steve
0
 

Author Comment

by:orkinos
ID: 37055868
net use h: \\server\share /user:domain\username /savecred---ITS NOT WORKING
0
 

Author Comment

by:orkinos
ID: 37055880
sorry i can t all are not working.

net use h: \\server\share ---ITS WORKING, not other
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 37055911
are you saying the option i gave doesnt work?  are there any special characters in the password?

Whaaat about if you use /user:domain\username or /user:username for a local one but not password and let it prompt.

What errors do you get?

Steve
0
 
LVL 85

Expert Comment

by:oBdA
ID: 37055965
What exactly "is not working"; what is the error you're getting?
Did you put double quotes around the password, as I mentioned above?
Is the user you want to use specified correctly? Possible formats are
* <NetBIOSDomainName>\<user's samid>
* <domain.intern>\<user's samid>
* <UPN> (some.user@domain.intra; note that the user id here as well as the domain name may be different from the samid and the AD domain name!)
Do you already have other connections open to 192.168.0.3?
Does it work if you delete H: before connecting?
net use H: /delete
net use H: \\192.168.0.3\share$ "testpassword" /user:domain\test

Open in new window

0
 
LVL 85

Expert Comment

by:oBdA
ID: 37056031
Oh, and just in case: if the path to the share to which you want to connect has a space in it, you need to enclose it in double quotes as well:
net use H: /delete
net use H: "\\192.168.0.3\share$\Shared Documents" "testpassword" /user:domain\test

Open in new window

0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 37056060
Good points oBdA, could be an existing connection to the same box and clash of credentials.

@orkinos - Please advise what error you get - Access denied, no drive mapped, drive is mapped but then access denied etc.?

Do the commands from a cmd.exe prompt rather than a batch file to see the errors more easily.

Steve
0
 
LVL 43

Assisted Solution

by:Steve Knight
Steve Knight earned 1000 total points
ID: 37056082
If you want the password hidden / saved within the batch file but less easy to spot give this a try:

http://scripts.dragon-it.co.uk/links/batch-prompt-password-save-it

or a more simple version.  On first run this will prompt for a password then store it away hidden from view (but not encrypted) and then next time it runs it will use that password.  You should be able to use other methods but giving the option rather than storing the password in the bat visible to all.

@echo off
set /p password=<%~nx0:password

if not "%password%"=="" goto OK
  set /p password=Enter password:
  echo %password%>%~nx0:password
:OK

net use "\\192.168.0.3\share$" /user:domain\test %password%

0
 
LVL 85

Accepted Solution

by:
oBdA earned 1000 total points
ID: 37056099
Rahul_Gade,
there are several issues with your script (aside from "net logon" not being required, as dragon-it already mentioned).
1. With set /P PWD = "Enter the password : ", you're assigning the variable "PWD " (including a trailing space!) the password; %PWD% in the following script will always be empty.
2. Using "set /p" to query for the password will display the password in plain text in the command shell, and the password will be accessible in the shell's typed history as well (if called from an open command shell). If a password entry is required with "net use", an asterisk (*) should be passed instead of a password, then "net use" will do the query, hiding the input.
3. When passing a password to "net use" in a batch file, the password should be enclosed in double quotes, otherwise any password containing characters with special meaning in batch scripts (%, &, <, >, ...) will result in logon errors (and might eventually lead to locking the account, especially if used in your combination with a displayed password, when the user can be absolutely certain he typed the password correctly).
0
 
LVL 7

Expert Comment

by:Rahul_Gade
ID: 37056122
I was just trying to give guidelines to proceed further, there was no intension to provide ready to use script. But thanks for your time in identifying errors in the script.

-Rahul
0
 

Author Comment

by:orkinos
ID: 37056479
Hey guys Thanks to you. You are perfect.

My error is : i run the all of above scripts ,but there is no error comes out and no drive map too.I cant see the error because cmd runs very quick ,difficult to read
0
 
LVL 85

Expert Comment

by:oBdA
ID: 37056518
Save the script in C:\Temp.
Open a command prompt, enter
cd /d C:\Temp
Now start the script from the command prompt, not by a double-click in Explorer.
net use
net use H: /delete
net use H: "\\192.168.0.3\share$\Shared Documents" "testpassword" /user:domain\test

Open in new window

If you post any output here, don't forget to change the password you actually used.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A safe way to clean winsxs folder from your windows server 2008 R2 editions
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question