Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Call batch file in UNC path which required credentials

Posted on 2013-02-06
6
Medium Priority
?
2,393 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 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 1800 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 71

Assisted Solution

by:Qlemo
Qlemo earned 200 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

926 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