Solved

Batch Script - Map Network Drive

Posted on 2012-12-25
3
1,051 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

740 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