Page 1 of 1 1
Topic Options
#89689 - 2002-11-21 08:51 AM Need help with translation
Vig Offline
Starting to like KiXtart

Registered: 2001-11-14
Posts: 166
Loc: Saudi Arabia
I'm attempting to translate the following bit of code from this vbs script.
code:
 Set OpSysSet=GetObject("winmgmts:{(Debug,RemoteShutdown)}//" _
& ComputerName & "/root/cimv2").ExecQuery( _
"Select * from Win32_OperatingSystem where Primary=true")
For Each OpSys in OpSysSet
OpSys.Win32Shutdown(x)
Next

Unfortunantly I know as much about COM as I know about VBS.

Here are a couple of my attempts. Please let me know where I am going wrong.

code:
$ObjShutdown = GetObject("winmgmts:{(Debug,RemoteShutdown)}!\\computername\root\cimv2")
.ExecQuery("Select * from Win32_OperatingSystem where Primary=true")
For Each $OpSys in $ObjShutdown
$execut = $OpSys.Win32Shutdown(4)
Next

code:
$ObjShutdown = GetObject("winmgmts:{(Debug,RemoteShutdown)}!\\computername\root\cimv2")
$OpSysSet = $ObjShutdown.ExecQuery("Select * from Win32_OperatingSystem where Primary=true")
For Each $OpSys in $OpSysSet
$execut = $OpSys.Win32Shutdown(4)
Next

Thanks

Top
#89690 - 2002-11-21 08:57 AM Re: Need help with translation
Vig Offline
Starting to like KiXtart

Registered: 2001-11-14
Posts: 166
Loc: Saudi Arabia
Hmm...

Nevermind I got it. Just needed to capitalize computername.

Edit: Capitilaztion seems to be irrelevent. Just started working when I removed all of the error checking. Strange..

Well anyways I give you Remote Logoff! Ta-Da (the first bit of my code that is)

[ 21. November 2002, 09:04: Message edited by: Vig ]

Top
#89691 - 2002-11-21 09:31 AM Re: Need help with translation
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Cool ... I didn't get anything though [Eek!]

Damn lack of WMI Knowledge [Mad]

Not allowed to install in my NT environment...

But seems to get a real sweety when finished

J.
_________________________



Top
#89692 - 2002-11-21 10:17 AM Re: Need help with translation
Vig Offline
Starting to like KiXtart

Registered: 2001-11-14
Posts: 166
Loc: Saudi Arabia
I posted this in a UDF named RemoteLRF.
RemoteLRS() - Remotely logoff/shutdown/reboot a computer

Please let me know of any problems.

Thanks

Top
#89693 - 2002-11-21 10:34 AM Re: Need help with translation
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
I will test this at home (I promise)
As I have there 2 W2K machines [Cool]
_________________________



Top
#89694 - 2002-11-21 01:02 PM Re: Need help with translation
Vig Offline
Starting to like KiXtart

Registered: 2001-11-14
Posts: 166
Loc: Saudi Arabia
I believe I'm on the verge of understanding this and if someone could answer a couple questions I'd be greatfull.

First, what is the purpose of "Debug,Remoteshutdown" in the following line.
code:
winmgmts:{(Debug,RemoteShutdown)}

In some of the examples on this board I've seen different words such as "impersonationLevel=impersonate" and others were blank.

Second, why was it necessary to do a query for "Primary=true". I was looking at Win32Shutdown on MS MSDN but I see no reference to "this must happen" before you can do "this".

I'm trying to understand what the value of $OpSys is in "$execut = $OpSys.Win32Shutdown(4)".

Thanks for any help.

Top
#89695 - 2002-11-21 01:12 PM Re: Need help with translation
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
The last one :

$OpSys is simply a pointer to elements of OpSysSets ... just like an array index

J.
_________________________



Top
#89696 - 2002-11-21 03:04 PM Re: Need help with translation
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Answers:

1) Debug. Executes Privileged Operations. From the SDK: Revokes and Resets Privileges

2) "Primary=true". Used to verify that the returned OS is the primary OS that WMI is 'finding'.

3) value of $OpSys/ Jpols is correct. The line: $OpSysSet = $ObjShutdown.ExecQuery("Select * from Win32_OperatingSystem where Primary=true") creates an object that is a collection (array) of all the installed operating systems. Therefore it must be parsed to operate instructions against it.

[ 21. November 2002, 15:12: Message edited by: Chris S. ]

Top
#89697 - 2002-11-21 04:37 PM Re: Need help with translation
Vig Offline
Starting to like KiXtart

Registered: 2001-11-14
Posts: 166
Loc: Saudi Arabia
Thanks, I guess I need to RTFSDK. [Big Grin]
Top
#89698 - 2002-11-21 08:10 PM Re: Need help with translation
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
RTNSDK

Normal manual is okay as well. [Roll Eyes]

Top
#89699 - 2002-11-21 08:16 PM Re: Need help with translation
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
I like that... rtfsdk... [Smile]
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#89700 - 2002-11-21 08:23 PM Re: Need help with translation
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Sure.. no problem. Its what, 300 pages or so long. I'll memorize it by the end of the day. [Wink] LOL
Top
#89701 - 2002-11-21 11:03 PM Re: Need help with translation
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Has a nice online help and search, no need to print it pout.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.069 seconds in which 0.029 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org