Solved

Batch Script - Map Network Drive

Posted on 2012-12-25
3
1,042 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

758 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

20 Experts available now in Live!

Get 1:1 Help Now