Click here to Skip to main content
15,917,862 members
Home / Discussions / System Admin
   

System Admin

 
GeneralRe: TCP/IP Printer Pin
donreturns20-Jan-10 19:16
donreturns20-Jan-10 19:16 
GeneralWinXP: annoying MSN Messenger! Pin
BlackSmith10-Jul-03 1:39
BlackSmith10-Jul-03 1:39 
GeneralBatch files Pin
abhinarulkar9-Jul-03 22:45
abhinarulkar9-Jul-03 22:45 
GeneralRe: Batch files Pin
Garth J Lancaster13-Jul-03 15:59
professionalGarth J Lancaster13-Jul-03 15:59 
GeneralService pack Pin
Member 4242597-Jul-03 3:29
Member 4242597-Jul-03 3:29 
GeneralRe: Service pack Pin
abhinarulkar9-Jul-03 22:12
abhinarulkar9-Jul-03 22:12 
GeneralRe: Service pack Pin
Atlantys17-Jul-03 18:55
Atlantys17-Jul-03 18:55 
GeneralProgrammatically using WMI to remotely run apps which access locally mapped drives relative to the remote machine. Pin
NullStream4-Jul-03 13:18
NullStream4-Jul-03 13:18 
The following code in theory should pop up a CMD window and show me the contents of a mapped drive mapped locally on a remote machine called "remote_workstation_a".

I'm running this script from my workstation and when I do the CMD window pop's up and tells me access denied. I tried logging in on the local machine as the domain administrator then run this script again with no luck.

I can't seem to figure out programmatically how to connect to a remote machine with a specific username and password yet still access the Win32_Process WMI object.

<br />
strComputer = "remote_workstation_a"<br />
Set objWMIService = GetObject("winmgmts:" _<br />
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2:Win32_Process")<br />
<br />
Error = objWMIService.Create("cmd.exe /K dir w:\", null, null, intProcessID)<br />
If Error = 0 Then<br />
Wscript.Echo "was started with a process ID of " _<br />
& intProcessID & "."<br />
Else<br />
Wscript.Echo " could not be started due to error " & _<br />
Error & "."<br />
End If<br />


I know this is possible because there are tools that already exist (psexec and beyondexec naming two) that can do this.

As an example with PSEXEC (from sysinternals.com):
<br />
psexec \\remote_workstation_a -u MY_PDC_DOMAIN\Adminstrator -p PASSWORD -i cmd.exe /K dir w:\<br />


This works so I know for certain this is possible I can't can't find anything clear in the WMI docs on MSDN to show me how to do this. Based on this I just need to encode the username and password of the account I would like to impersonate on the remote machine somehow (through the 'GetObject("winmgmts:" ...' call?).

The obvious answer is to just use PSEXEC but I need to run this a whole lot of times (which would open up MANY MANY processes) and PSEXEC's source is not exactly available.

Any hints or suggestions would be greatly appriciated.

The whole point of me attempting this is to make the tech guy's life a bit easier when pushing updates to the compute farm.

And while I'm at it why is all the WMI documentation so vague on almost everything? I'm eventually going to need to map a printer to each machine on the network and I'd love to do it though WMI but it's going to be a BIG BIG chore without some insight.

Thanks,


Sean
GeneralRe: Programmatically using WMI to remotely run apps which access locally mapped drives relative to the remote machine. Pin
Venet5-Jul-03 7:22
Venet5-Jul-03 7:22 
GeneralWindows' Handle Pin
ladder3-Jul-03 23:23
ladder3-Jul-03 23:23 
GeneralRe: Windows' Handle Pin
Michael Dunn4-Jul-03 5:36
sitebuilderMichael Dunn4-Jul-03 5:36 
GeneralRe: Windows' Handle Pin
ladder5-Jul-03 6:00
ladder5-Jul-03 6:00 
GeneralRe: Windows' Handle Pin
Michael Dunn5-Jul-03 6:07
sitebuilderMichael Dunn5-Jul-03 6:07 
GeneralRe: Windows' Handle Pin
Alexander M.,22-Jul-03 9:40
Alexander M.,22-Jul-03 9:40 
GeneralEnvironment Vars - using Pin
john john mackey1-Jul-03 10:04
john john mackey1-Jul-03 10:04 
GeneralRe: Environment Vars - using Pin
John M. Drescher1-Jul-03 10:18
John M. Drescher1-Jul-03 10:18 
GeneralRe: Environment Vars - using Pin
jlb1-Jul-03 13:35
jlb1-Jul-03 13:35 
GeneralRe: Environment Vars - using Pin
john john mackey2-Jul-03 5:32
john john mackey2-Jul-03 5:32 
GeneralRe: Environment Vars - using Pin
Michael Dunn4-Jul-03 7:00
sitebuilderMichael Dunn4-Jul-03 7:00 
GeneralRe: Environment Vars - using Pin
john john mackey4-Jul-03 9:17
john john mackey4-Jul-03 9:17 
GeneralRe: Environment Vars - using Pin
Atlantys11-Jul-03 20:05
Atlantys11-Jul-03 20:05 
GeneralDNS Insert/Delete/Modify Pin
vss-130-Jun-03 13:55
vss-130-Jun-03 13:55 
GeneralIIS ASP.NET Rant/Question Pin
Matt Newman29-Jun-03 18:45
Matt Newman29-Jun-03 18:45 
GeneralRe: IIS ASP.NET Rant/Question Pin
Richard Deeming1-Jul-03 4:57
mveRichard Deeming1-Jul-03 4:57 
GeneralRe: IIS ASP.NET Rant/Question Pin
Matt Newman1-Jul-03 6:06
Matt Newman1-Jul-03 6:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.