/\/\o\/\/ PowerShelled

This blog has moved to http://ThePowerShellGuy.com Greetings /\/\o\/\/
$AtomFeed = ("Atom.xml")
$PreviousItems = (" MSH access NT provider "," Update-TypeData (Democracy to the types) "," MSH directory watcher with popup-balloon "," StartRDP script "," convert images in MSH "," Style Problems "," ColorCoding MSH scripts on blog "," GUI folder copy tool "," MSHObjectViewer mentioned in More talking about Monad "," MSH registry access "," ")

Saturday, October 22, 2005

 


playing with MY-object from MSH



I did some playing with the MY-namespace from VB.NET

a lot we have already but there are some nice tricks,
for example the audio

to bad the clipboard does not work, also that the user-object can not be used.
(I'm realy looking for that for my SetOwner function)

gr /\/\o\/\/

PS. I past all as code, as it has alot if pasted info and I lose all linebreaks if I do not.




[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.VisualBasic")
$myComputer = new-object Microsoft.VisualBasic.Devices.computer

this give you acces to the following :

Audio : Microsoft.VisualBasic.Devices.Audio
Clipboard : Microsoft.VisualBasic.MyServices.ClipboardProxy
Ports : Microsoft.VisualBasic.Devices.Ports
Mouse : Microsoft.VisualBasic.Devices.Mouse
Keyboard : Microsoft.VisualBasic.Devices.Keyboard
Screen : Screen[Bounds={X=0,Y=0,Width=1280,Height=1024} WorkingArea={X=0,Y=
0,Width=1280,Height=960} Primary=True DeviceName=\\.\DISPLAY2 ?
O?????? ??☺ ?
Clock : Microsoft.VisualBasic.Devices.Clock
FileSystem : Microsoft.VisualBasic.MyServices.FileSystemProxy
Info : Microsoft.VisualBasic.Devices.ComputerInfo
Network : Microsoft.VisualBasic.Devices.Network
Name : computername
Registry : Microsoft.VisualBasic.MyServices.RegistryProxy

so now you can do !

$mycomputer.audio.play("C:\WINDOWS\Media\tada.wav")

$mycomputer.info
MSH C:\> $mycomputer.info


TotalPhysicalMemory : 2145816576
AvailablePhysicalMemory : 1505857536
TotalVirtualMemory : 2147352576
AvailableVirtualMemory : 1913438208
InstalledUICulture : en-US
OSFullName : Microsoft Windows XP Professional
OSPlatform : Win32NT
OSVersion : 5.1.2600.131072

MSH C:\> $mycomputer.network.isAvailable
True

$MyComputer.network.ping("localhost")
True

not so nice :

MSH C:\> $MyComputer.network.ping("foo")
Exception calling "Ping" with "1" argument(s): "An exception occurred during a
Ping request.".
At line:1 char:25

MSH C:\> $mycomputer.clock

LocalTime GmtTime TickCount
--------- ------- ---------
10/22/2005 8:04:33 PM 10/22/2005 6:04:33 PM 423435437

also .NET has another path as MSH !!!


MSH C:\> $mycomputer.filesystem.CurrentDirectory
C:\Documents and Settings\mow

MSH C:\> $mycomputer.filesystem.SpecialDirectories


MSH C:\> $mycomputer.mouse

ButtonsSwapped WheelExists WheelScrollLines
-------------- ----------- ----------------
False True 3



you can also get the user object but that does not seem to work.

$me = new-object Microsoft.VisualBasic.ApplicationServices.user

MSH C:\> $me.InitializeWithWindowsUser()
MSH C:\> $me

Name CurrentPrincipal IsAuthenticated
---- ---------------- ---------------
System.Security.Princip... False


MSH C:\> [system.threading.thread]::currentPrincipal
realy not so nice :

MSH C:\> $mycomputer.clipboard.setText("hello Clip")
Exception calling "SetText" with "1" argument(s): "Current thread must set to s
ingle thread apartment (STA) mode before OLE calls can be made. Ensure that you
r Main function has STAThreadAttribute marked on it.".
At line:1 char:30
+ $mycomputer.clipboard.setText( <<<< "hello Clip")

Identity
--------
System.Security.Principal.GenericIdentity

looks like we have no indentity in MSH


but there is alot to play again ;-)



Comments:
Blogger Sung Meister
Is there a way to load assembly with partial name for C# instead of visual basic by chance?

I am not sure what the counterpart is for C# for "Microsoft.VisualBasic"
 
Blogger /\/\o\/\/
I'm not completly sure, but I think there is no assembly for c#


The microsoft.visualbasic are Extra functions for VB.NET to look like VB6
(for example msgBox adn alot of VB string functions) there more like shortcuts you can do this in other way's to.
but you can use them from any CLS language, you can load any DLL of the framework.

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



<< Home

Archives

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.
Google
 
Web mow001.blogspot.com

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