

InterviewSolution
Saved Bookmarks
1. |
Solve : DIR of remote machine - RunAs?? |
Answer» <html><body><p>Hi everyone:<br/><br/>I am trying to <a href="https://interviewquestions.tuteehub.com/tag/pipe-245115" style="font-weight:bold;" target="_blank" title="Click to know more about PIPE">PIPE</a> the contents a specific folder on a remote <a href="https://interviewquestions.tuteehub.com/tag/machine-550312" style="font-weight:bold;" target="_blank" title="Click to know more about MACHINE">MACHINE</a> to a text file on my PC through a command line. My initial command looks like this:<br/><br/>dir \\10.11.222.33\c$\folder\subfolder\*.log >textfile.txt<br/><br/>As long as I have mapped a drive to the remote machine (thus already <a href="https://interviewquestions.tuteehub.com/tag/specifying-2278194" style="font-weight:bold;" target="_blank" title="Click to know more about SPECIFYING">SPECIFYING</a> the user name and password), this works great. As the above example goes, I would now have a text file on my PC called textfile.txt, which contains a DIR of *.log files from the remote folder. <br/><br/>However, if I haven't already mapped the remote drive, this command throws 'Access Denied' errors. I am trying to automate the command by running it through a batch file, so somehow I need to include the user name and password credentials in the actual command. I don't know much about RunAs, but what I've tried hasn't worked.<br/><br/>And though I appreciate the suggestion, mapping the <a href="https://interviewquestions.tuteehub.com/tag/drives-959782" style="font-weight:bold;" target="_blank" title="Click to know more about DRIVES">DRIVES</a> in advance won't work for me because I don't have many available drive letters, and I have many remote machines I need to perform this command on (again, in batch). So I need a way to do this without mapping the remote drives.<br/><br/>And for various other network reasons, I can't use FTP or Telnet. Yeah. Fun.<br/><br/>I and the remote machines are running XP Pro.<br/><br/>If someone knows enough about RunAs to show me EXACTLY what I need to include in the command above, I would be extremely grateful. (Or, any other way to make this work given the limitations I've mentioned.)<br/><br/>Thanks loads,<br/><br/>PJHi PJ<br/><br/>Looks like all you need to do is a Net Use command to provide the credentials to the network share.<br/><br/>Please try adding this to the start of your script.<br/><br/>Net Use \\10.11.222.33\c$ /user:domain\username "password without <a href="https://interviewquestions.tuteehub.com/tag/quotes-1175233" style="font-weight:bold;" target="_blank" title="Click to know more about QUOTES">QUOTES</a>"<br/>This will not map the share to a drive letter it will just provide the login details.<br/><br/>Let me know if you need anymore help.<br/>Brett</p></body></html> | |