?
Solved

Batch Script - Map Network Drive

Posted on 2012-12-25
3
Medium Priority
?
1,058 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 2000 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
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 …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

771 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