10

My Scenario: I am running the pushd command to run searches on remote domain computers. However the search performs very slow/or not at all when a user is not logged on to the machine(machine is still powered on.)

I was wondering if it is possible to pass log in credentials with the pushd command. If not what are some alternate choices?

I cannot use other software or packages such as PsExec.

wonea
  • 1,817
  • 1
  • 23
  • 42
sealz
  • 2,264
  • 2
  • 28
  • 41
  • For those who read this and think it to be nonsense (the `pushd` command having no search mechanism and having nothing to do with searching), I recommend reading [`harper89`'s other question](http://superuser.com/questions/296452/) for context. `harper89`, write precisely what you are actually doing in questions, not some confused outline that people won't understand. – JdeBP Jun 14 '11 at 13:02
  • I am searching remote computers once I use pushd to "connect" to them. – sealz Jun 14 '11 at 13:09
  • I think he's using it to connect to remote systems and checking versions of installed executables, such as java. – Darth Android Jun 14 '11 at 13:58
  • Out of pure curiosity, I still wonder why PsExec is not available when alternate choices are being asked for-- it's a Microsoft utility, with the only difference between it and `pushd` being that it's not shipped by default... – Darth Android Jun 14 '11 at 14:11
  • these commands are being worked into an application and PsExec would involve another possible download for the end user or machines that will be running the application. – sealz Jun 14 '11 at 16:26
  • @harper89: FWIW, SysInternals make their tools available over WebDAV, so you can just `copy /y \\live.sysinternals.com\psexec.exe "%TEMP%\psexec.exe"`. On the other hand, I would *not* recommend putting this into a distributable script, because of a misconfiguration at their "live" server. (Windows normally tries SMB before WebDAV, and the SysInternals server quietly drops SMB and ICMP, therefore a **long** timeout delay is caused during each connection.) – u1686_grawity Jun 15 '11 at 07:38

2 Answers2

11

You can use:

net use \\RemoteComputer\c$ password /user:MY_DOMAIN\remoteUsername
"\\RemoteComputer\c$\Program Files\Java\jre6\bin\java" -version"
net use \\RemoteComputer\c$ /d

(Edited to add simplifications from grawity from comments. Learn something new every day!)

u1686_grawity
  • 426,297
  • 64
  • 894
  • 966
Darth Android
  • 37,872
  • 5
  • 94
  • 112
  • FWIW, you don't need to specify a drive letter for `net use` -- just passing path/user will cause Windows to connect and authenticate. Although `pushd` will create a drive letter *anyway* -- but it's not always needed; most programs will accept `\\remotecomputer\C$` just fine. – u1686_grawity Jun 14 '11 at 18:58
  • @grawity: You mean `net use \\computer ` and then `\\computer\path\executable -arg` will work as expected? – Darth Android Jun 14 '11 at 19:07
  • Yes, that's right. (To disconnect, `net use \\computer\IPC$ /d`.) – u1686_grawity Jun 14 '11 at 19:10
  • One correction to your edits: If you specify a share name when connecting, you must specify the same when disconnecting too. It's only bare `\\computer` (as in your comment) that gets translated to `\\computer\IPC$`. – u1686_grawity Jun 15 '11 at 07:33
1

I would use this command to map a drive. This guarantees that connection will persists and you have a drive name mapped to E: so you can just call that drive name to run commands.

Net Use  E: \\server\share my_password /user:username  /persistent:MY_DOMAIN/username /y
Sam B
  • 447
  • 4
  • 8