Solved

Call batch file in UNC path which required credentials

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

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

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…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

828 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