Solved

Call batch file in UNC path which required credentials

Posted on 2013-02-06
6
2,260 Views
Last Modified: 2013-02-07
Hello Experts,
I need to call the batch which is on server (\\TestServer01\shared path\batch.bat). But to access to shared path requires credential.
Don't know how I can do this.. Here is piece of code I am using. How can I pass credentials so that I could execute the batch file on server.

pushd \\TestServer01\Shared Path
set Mnemonic=%1
call PennyFW.bat %Mnemonic% 
popd

Open in new window

0
Comment
Question by:sonawanekiran
[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
  • 2
6 Comments
 
LVL 85

Expert Comment

by:oBdA
ID: 38862931
Try this:
net use \\TestServer01\IPC$ "SomePasswordSurroundedByQuotes" /user:[SomeDomain\]SomeUser
pushd \\TestServer01\Shared Path
set Mnemonic=%1
call PennyFW.bat %Mnemonic%
popd
net use \\TestServer01\IPC$ /delete

Open in new window

0
 
LVL 17

Author Comment

by:sonawanekiran
ID: 38862981
Thanks oBDa. Batch file is calling but getting couple of errors

1) C:\Data\FileWatcher\ThirdParty>net use \\TestServer01\IPC$ "mypass" /user:tkp\myuser

System error 1219 has occurred.

Multiple connections to a server or shared resource by the same user, using more
 than one user name, are not allowed. Disconnect all previous connections to the
 server or shared resource and try again..

2)
C:\Data\FileWatcher\ThirdParty>net use \\TestServer01\IPC$ /delete
The network connection could not be found.
0
 
LVL 85

Accepted Solution

by:
oBdA earned 450 total points
ID: 38863012
1) In your session, you already have a network mapping to that server, probably with your current user. In a command prompt, enter "net use" to see all open connections.
Either delete all other connections to that server, or use the server's IP address instead of the name in the script.
2) Can be ignored; because the connection couldn't be established, it can't be deleted. In this version, errors deleting the connection will be suppressed:
net use \\1.2.3.4\IPC$ "SomePasswordSurroundedByQuotes" /user:[SomeDomain\]SomeUser
pushd \\TestServer01\Shared Path
set Mnemonic=%1
call PennyFW.bat %Mnemonic%
popd
net use \\TestServer01\IPC$ /delete >NUL 2>&1

Open in new window

0
Veeam gives away 10 full conference passes

Veeam is a VMworld 2017 US & Europe Platinum Sponsor. Enter the raffle to get the full conference pass. Pass includes the admission to all general and breakout sessions, VMware Hands-On Labs, Solutions Exchange, exclusive giveaways and the great VMworld Customer Appreciation Part

 
LVL 70

Assisted Solution

by:Qlemo
Qlemo earned 50 total points
ID: 38863081
You'll need to replace all occurances of TestServer01 above by its IP, of course, not only the first one.
0
 
LVL 85

Expert Comment

by:oBdA
ID: 38863090
That's true.
0
 
LVL 17

Author Closing Comment

by:sonawanekiran
ID: 38863214
Thank you all
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

635 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