Solved

Call batch file in UNC path which required credentials

Posted on 2013-02-06
6
2,145 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 84

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 84

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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
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 84

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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

739 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