Solved

Batch Script - Map Network Drive

Posted on 2012-12-25
3
1,047 Views
Last Modified: 2012-12-26
Hello,

I have a batch script that among other things, maps a network drive using syntax similar to this:

Net use Z: \\192.168.200.10\dog$ /USER:dog-pc\cat C9d!42$%

When I execute the script, I get a "logon failure unknown username or password" error.

When I type the syntax (exactly the same as the batch script) into a command prompt, the command executes successfully and the shared folder is mapped.

What am I doing incorrectly that is preventing the batch script from working successfully?

Thanks
0
Comment
Question by:TacomaVA
  • 3
3 Comments
 
LVL 43

Accepted Solution

by:
Steve Knight earned 500 total points
ID: 38720430
The ! And % signs have special meaning in batch files for expanding variables, e.g. echo %computername% so either change the password to not include them, or try one of these - been a long day and taking a breather from Xmas stuff to flick through emails so haven't double checked
C9d!!etc.%%
or
C9d!etching %%
Will look back another day if not and noone else helpsfor before.

Steve
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 38720476
To add to that.... the ! shouldn't be an issue unless you have setlocal  enabledelayedexpansion used in the batch.  If so I don't know a way that you can use ! but if not using the above then just doubling the % to %% should do it.

Steve
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 38721696
Glad it helped.

Steve
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now