/\/\o\/\/ PowerShelled

This blog has moved to http://ThePowerShellGuy.com Greetings /\/\o\/\/
$AtomFeed = ("Atom.xml")
$PreviousItems = (" It's busy at the Monad front "," Monad Remoting "," How MSH Works "," Hosting an MSH runspace from Monad "," MSH get-WmiMethodHelp function Update 3 "," out-dataGrid function for Monad "," Windows "Monad" Shell (MSH) Beta 3.1 "," Windows "Monad" Shell (MSH) Beta 3.1 "," scripting games Last Day MSH answers for event 7 a... "," Scripting Games almost over "," ")

Sunday, March 26, 2006


Some Monad Com hacks

Just some Com hacks in MSH I think are nice :
*edit* I keep on forgetting, you will need this alias, or change the new to new-object,
set-alias new new-object

# Some COM hacks

# local user management

MSH>(new -com shell.users).create('foo')

isLoggedOn               : False
passwordRequired         : False
interactiveLogonAllowed  : True
isProfilePrivate         :
isPasswordResetAvailable : False

MSH>(new -com shell.users).item('foo').changePassword('Secret','')

MSH>(new -com shell.users).item('foo')

isLoggedOn               : False
passwordRequired         : True
interactiveLogonAllowed  : True
isProfilePrivate         :
isPasswordResetAvailable : False

MSH>(new -com shell.users).remove('foo')

MSH>(new -com shell.users).item('foo')
Exception calling "item" with "1" argument(s): "The parameter is 
incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))"
At line:1 char:28

# File Dialog

$c = new -com UserAccounts.CommonDialog


Filter      :
FilterIndex : 0
FileName    : C:\Documents and Settings\mow\My 
Flags       : 0
Owner       :
InitialDir  :

# Make a CAB file

$m = new -com  makecab.makecab


gr /\/\o\/\/
Tags :

Anonymous Anonymous
Very cool! You could use that to good effect if you had a function which took a filename (and you knew that you'd always have the GUI available):
$Script:CmnDiag = New -Com UserAccounts.CommonDialog

function Get-FileNameViaGUI ($fileName="*.*")
$Script:CmnDiag.FileName = $fileName
$done = $false
While (!$done)
$done = $Script:CmnDiag.ShowOpen()

function cat1 ($file = $(Get-FileNameViaGUI))
get-Content $file

cat1 foo.txt # would display the file
cat1 # would open up the GUI to get the file to then cat
Blogger /\/\o\/\/
> You could use that to good effect if you had a function which took a filename (and you knew that you'd always have the GUI available):

Lol, how did you guess I wanted to use it for that ;-)

Nice Implementation,

the reason this COM way is handy here is that the .NET dialog boxes get no focus. (for forms, you can use this trick :


but not for the dialog boxes,

thanks for the script and comments.

gr /\/\o\/\/
Post a Comment

<< Home


October 2005   November 2005   December 2005   January 2006   February 2006   March 2006   April 2006   May 2006   June 2006   July 2006   August 2006   September 2006   October 2006   November 2006   December 2006  

$Links = ("PowerShell RC1 Docs"," PowerShell RC1 X86"," PowerShell RC1 X64"," Monad GettingStarted guide"," Monad Progamming Guide"," Monad SDK"," Monad videos on Channel 9"," MSH Community Workspace"," scripts.readify.net "," MonadSource"," www.reskit.net"," PowerShell Blog"," Under The Stairs"," computerperformance powershell Home"," proudlyserving"," MSH on wikipedia"," MSHWiki Channel 9"," Keith Hill's Blog"," Precision Computing"," PowerShell for fun"," MSH Memo (Japanese)"," monadblog")

find-blog -about "PowerShell","Monad" | out-Technorati.
find-blog -contains "","" | out-Technorati.
Web mow001.blogspot.com

This page is powered by Blogger. Isn't yours?