Solved

Call batch file in UNC path which required credentials

Posted on 2013-02-06
6
1,872 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
  • 3
  • 2
6 Comments
 
LVL 83

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 83

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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 68

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 83

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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 …
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

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

23 Experts available now in Live!

Get 1:1 Help Now