October 2005 - Posts

How to create GUI in Monad?

Hey guys! Sometimes you need to create some GUI - msgbox, inputbox etc... Till now it was really problem if you needed something more advanced - for example checkboxes etc. With Monad it is quite easy! And thats because you can use .net... In fact it is similar to creating normal program!

[Reflection.Assembly]::LoadWithPartialName(”System.Windows.Forms”)

$Form = New-Object System.Windows.Forms.Form

$Button = New-Object System.Windows.Forms.Button

$Form.Text = “You didnt clicked yet”

$Button.Text = “Click here!”

$Button.Add_Click({$Form.Text = “You clicked!})

$Form.Controls.Add($Button)

$Form.ShowDialog()

Posted by martin | 1 comment(s)
Filed under:

New Microsoft division - We-SYP ;)

Have a look - new MS division is coming :D

http://wwwapp.wug.cz/VIDEO/sharing_customer_pain.wmv

Posted by martin | with no comments
Filed under:

Sometimes quite problem - file that came from network wont run in silent mode :(

I sometimes encountered this problem - message This file is from network and it wont run until user manually selected to allow it...

Today I encountered the same problem - so I tried to find really simple solution and now I want to share with you :)

As you maybe know, this information is stored in ADS - Alternate Data Stream. If you are interested in this, I could make standalone post dedicated to this topic.

So I tried little trick and it worked like a charm :) I know it is not good solution, however I needed to use it remotely and only once :)

File.exe --- this is file with ADS information about network

 

Ren File.exe Temp.exe

Type Temp.exe File.exe

 

And thats it! :) As I said - I was looking for really simple solution and I found it...

Posted by martin | with no comments
Filed under:

Interview with Johan Arwidmark about deployment

Here we go! This is second interview, now with Johan Arwidmark and we talked about deployment... As you can see, Johan have same opinion as me about availability of WinPE ;)

1.) What tools are you missing most in deployment today?

 Multicast, offline image editing (when using SMS OSD), good driver injection tools, support for multiple partition handling (when using SMS OSD) and Windows PE free for all Windows Users…

 

2.) What are your favourite upcoming deployment technologies? SMS v4, Monad, WIM or something absolutely else?

 This would be all technologies using the new WIM format (WDS, SMS v4 and Ximage)

 

3.) What do you think is the biggest problem with deployment today? I mean like non-msi installers, profile migrations etc...

 Windows PE is not available for all Windows customers

 

4.) What are your favourite tools for deployment? I mean everything including 3rd party tools/support tools (IDE...) etc.

 SMS 2003 OSD (with ZTI from BDD 2.5) for clients and ADS 1.1 for servers

Posted by martin | 1 comment(s)
Filed under:

JIT Setup - really nice feature and most people dont know about it!

Well, when I talked with Noise in discussion under one of my previous posts, I decided I will write something about this feature. It is called Active Setup.

When new user logged on first time, their profile is created from Default user and ntuser.dat from default user... However there are some things that you cant find in default user - for example icons for Outlook Express. Most administrators dont want to have these icons - mostly because they are using more robust email client like outlook.

Most of these administrators just left them where they are. However how are these icons created?

When you look to HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components, you will see a pack of GUIDs -

every GUID here means what to do when new profile is created. The most important value is StubPath - it is path to command to execute. When this is not available, it will just ignore it.

Lets try small experiment - first locate key {6BF52A52-394A-11d3-B153-00C04F79FAA6} - it is key responsible for creating WMP icon. When you change the name of StubPath (for example DisableStubPath), the icons wont create. Neat, right? :)

Now you know how to disable certain components - however there is of course another use for them - you can create new!

For example you have application, that is using per-user settings. You want to specify default settings and you cant use HKLM\All users.

If you dont know how to create GUID, you can use my script:

strGuid = Left(CreateObject("Scriptlet.TypeLib").Guid, 38)
strInterpreter = Wscript.FullName
strInterpreter = InStr(strInterpreter,"cscript")
If strInterpreter = 0 Then
 InputBox "Generated GUID:", "GUID Generator", strGuid
Else
 Wscript.Echo strGUID
End If

  1. create new key containing GUID.
  2. create file test.cmd with content “mkdir c:\test“ in c:\temp
  3. create value StubPath with path to your script, that will create this settings. In our example it will be “C:\Temp\test.cmd“
  4. create value ComponentID with any name you prefer. For example “Test active setup“
  5. Last needed value is IsInstalled. It should be REG_DWORD with value 1.

Now try to log as new user... Is it working? :)

Posted by martin | 6 comment(s)
Filed under: ,

You think you know everything about registry? :)

Well, I had discussion with one guy today - it was really horrible, he was from government... I thought that he knew everything about registry. This is what he told me:

“I know everything! I am IT professional you know... For example I can change your wallpaper through registry!”

Because I really hate this baby administrators (it doesnt mean I hate people that are not real professional - I hate people that think they know everything, however their knowledge is really miserable), I kindly asked him if he know what are for example REG_QWORD or REG_LINK (I though he at least knows about different structures like REG_SZ or REG_DWORD)...

Of course he was not able to say anything about it, he just said that real professional dont need this kind of informations and leaved the room quickly.

However what I wanted to speak about is REG_LINK, because I found out I didnt mentioned it before.

REG_LINK allows using symbolic links in registry - quite neat, right? :)

Typical example of usage is HKCU (mapped to HKU\<SID>) or CurrentControlSet (mapped to ControlSet###)... I am sure you can find many usage for this little registry type, like centralized per-user settings etc....

I am using it mostly using APIs, however there is at least one tool available: http://www.ntinternals.net/regln

Did you know about this? Are you interested in more informations similar to this?

Posted by martin | 2 comment(s)
Filed under:

Monad documentation

I noticed this information on Lee`s blog - Monad documentation from PDC is available!

And it is great, I noticed few things I didnt know you could do, for example

Filter get-company {$_.Company}

Get-Process | Get-Company

Download it today! :)

http://www.microsoft.com/downloads/details.aspx?FamilyID=8a3c71d1-18e5-49d7-952a-c55d694ecee3&DisplayLang=en

Posted by martin | with no comments
Filed under: ,

Help! How to change screen resolution in batch/script???

Well, I encountered this problem - I am not able to change screen resolution using script :(

I dont want (yet) to use external utilities like multires, I want to find a way to do it using native command - I found function ChangeDisplaySettingsA in user32.dll, however I am not able to call it right way :(

I tried this: rundll32 user32.dll,ChangeDisplaySettingsA 1280,1024,60

Any ideas? :(

Posted by martin | 5 comment(s)
Filed under:

How to search in Active Directory and few more tricks... :)

Well, I have funny request today - we have OU PC with subOUs Desktops/Notebooks and suOUs Win2k and WinXP inside them.. I had to write script, that will move computer account to these OUs based on

a.) Computer type (notebook/desktop)
b.) installed OS (Win2k/WinXP)

So the structure is

---Desktop --- WinXP

                  --- Win2k

---Notebooks --- WinXP

                       --- Win2k

 

Here is the script I created (it is working like a charm :)) :

'Move PC to OU
'Martin Zugec
'3.10.2005

Set objShell = WScript.CreateObject("WScript.Shell")
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set arrayChassis = objWMIService.ExecQuery("Select * from Win32_SystemEnclosure")
Set objNetwork = CreateObject("Wscript.Network")
Set objRootDSE = GetObject("LDAP://RootDSE")

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")

objConnection.Provider = "ADsDSOObject"
objConnection.Open

strDC = objRootDSE.Get("dnsHostName")
strDomain = objRootDSE.Get("DefaultNamingContext")

strComputerName = objNetwork.ComputerName

Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = "<LDAP://" & strDomain & ">;(&(objectClass=computer)(objectCategory=computer)(cn=" & strComputerName & "));distinguishedName;subTree"
Set objResult = objCommand.Execute
Do Until objResult.EOF
 strSourceOU = objResult.Fields("distinguishedName")
 objResult.MoveNext
Loop


TargetOU = GetOS()
   
For Each objChassis in arrayChassis
    For  Each strChassisType in objChassis.ChassisTypes
        Select Case strChassisType
            Case 3 ' Desktop
             Call MoveComputer(TargetOU, "Desktopy")
            Case 8 ' Notebooky
             Call MoveComputer(TargetOU, "Notebooky")
        End Select
    Next
Next

Function GetOS()
    Dim strVer : set strVer = objShell.exec("%comspec% /c ver")
    Dim sResults
    sResults = strVer.stdout.readall
    Select Case True
       Case InStr(sResults, "Windows 2000") > 1
         GetOS = "Win2K"
       Case InStr(sResults, "Windows XP") > 1
         GetOS = "WinXP"
       Case Else
         GetOS = "Unknown"
    End Select
End Function

Function MoveComputer(TargetOU, ComputerType)
 Set objTargetOU = GetObject("LDAP://OU=" & TargetOU & ",OU=" & ComputerType & ",OU=PC," & strDomain)
 Set objMoveComputer = objTargetOU.MoveHere ("LDAP://" & strDC & "/" & strSourceOU, "CN=" & strComputerName)
End Function

Posted by martin | 3 comment(s)
Filed under:

Deployment presentation no.3: User profiles

Hey guys!

As maybe some of you know, I am working on series of (free) presentations about (free) deployment tools & techniques.

First two part were successful - right now I am preparing third part, which will be about user accounts and application installation.

Why am I telling you about this? Because I would like to ask you to help... Bring some new ideas, you experiences etc.

So I will share with you informations I want to provide there.

User accounts - I want to talk about different aspects of user profiles.

Local user profiles, roaming profiles, redirecting directories... I want to describe the difference between w2k “Wipe&Load” method of roaming profiles and wxp “Merge” method...

Next I would like to talk about how profiles are working - detecting SID, ProfileImagePath, mapping ntuser.dat to HKU\SID and HKU\SID to HKCU etc...

Also quite important will be section about Default user/All users... Informations like that you can use domain Default user (just create Default user in NetLogon) etc.. Here I have one question - have anyone tried to redirect All users directory to network? I think it should be possible, however never tried it.

Also important part about modifying profiles - how to load HKCU for different user, how to modify Just-in-time setup (like when Outlook Express icons are automatically generated), methods for modifying Default user...

 

So right now I am waiting for your comments :) What do you miss in this list, what are your experiences, tips&tricks etc...

Hope so you wont let me down :D I am always interesting in finding new informations/ideas...

Posted by martin | 4 comment(s)
Filed under:

LongHorn Server Terminal Server feature list

Feature list for TS is available! I wont comment, instead I will wait till I get my own hands on (at least Beta 2) version...

Source: http://www.brianmadden.com/content/content.asp?id=500

Posted by martin | with no comments
Filed under:

First alternative shell for Monad!

Heh, I was waiting for this moment, however I didnt know it will happen before first release :)

We have alternative shell for monad - it is called jaMSH (Jeff`s Alternative Monad SHell)... It includes few nice features - greater autocomplete, emacs/vi editing etc...

However it was really unstable on my machine and really slow :( I will wait for next release...

Link: http://www.coldie.net/project/jamsh 

Posted by martin | 3 comment(s)
Filed under: ,

How to retrieve your product key for Windows/Office?

Well, I know there will be people that will use this tool illegal way, however it is often usefull for administrators... I few times needed to find product key of installed machine and now I found really nice and reliable application - RockXP...

You can find it here: http://www.snapfiles.com/get/rockxp.html

And use it only for legal tasks!  ;)

Posted by martin | 2 comment(s)
Filed under:

Interview with Lee Holmes from Monad team!

[MZ] How would you compare Monad to Ruby (as far as I know it is object-oriented shell for Linux, however dont have practical experiences)

[LH] Ruby is actually a programming language. There is an interactive Ruby Shell, but it doesn't really have support for system administration tasks, such as changing directories, maintaining files, getting processes, etc.

However, MSH is also a scripting language, which would be a valid target for comparison to the Ruby programming language. However, that would be quite an enormous comparison, to do it any justice.


[MZ] I am from czech republic, we are using different date format (dd/mm/yyyy). How to add values to variable by specifying these its properties? I mean something like [DateTime]$Test -Month=12 -Day=24

-year=2005

[LH] The .Net framework (and by extension, Monad,) is very aware of multiple cultures. At your command prompt, you just type as though you normally would type in a date:

$date = [DateTime] "02/10/2005"

COMMENT: I sent this question to Lee again :) The problem is that czech culture is using different time format and I would like answer to this question - it is VERY common error in batches here :(


[MZ] hmmm, what do you think about running Monad on Linux (maybe based on

Mono?) :)

[LH] Monad uses a lot of features not yet available on Mono. It would be interesting, but not yet possible.


[MZ] will there be "remoting" capability in Monad? Something like /node switch in WMIC?

[LH] Definitely. It's something we're working on, and I'm quite looking forward to it.


[MZ] Will there be only MSH or also cmd as shell in Vista? This is quite important question and I didnt find answer - I am afraid windows administrators are too lazy to learn new things :(

[LH] I doubt that cmd.exe will ever go away. People have a lot invested in their batch files, and it would be a travesty if they were to all stop working.


[MZ] what about support for encrypted scripts? Like .vbe or autoit compilations?

[LH] Monad doesn't support any type of obfuscation or compilation of its scripts. That's primarily because there is no such thing as an encrypted script :) You can make it slightly harder for people to reverse-engineer your code, but not much. Just think about how easy it is for people to read and reverse engineer assembly language.


[MZ] Also one thing I am missing these days - will there be any chance to encrypt somehow administrator password? The problem with today scripts is you must almost everytime use plain text password/use interactive scheduled task :(

[LH] There is some degree of support for encrypted credentials -- take a look at the get-credential command. It's restricted to interactive sessions, though. To protect the password from casual file snoopers, you can experiment with new-secureString, export-secureString, and import-secureString. That said, the moment your script passes the password to another program, it's exposed for the world to see.


[MZ] What about signed scripts? I am afraid it isnt really good idea, because administrators/geeks wont use them and the final effect would be that almost everybody (I mean every person using MSH :)) will disable them in first place. Will there be any other way to secure scripts - like personal/public keys (similar to old PGP)?

[LH] I'm not sure what you mean here. You think nobody will want to sign their scripts, yet you wonder if we offer a way to sign them via PGP? We don't support PGP signing of scripts, but it is very easy to set yourself up with a "self signed" certificate to sign your own scripts. I'll be writing something about this in the near future.


[MZ] small question - will you add ability to create variable without iniciating it? Like $Variable = [DateTime] or [DateTime]$Variable?

[LH] Why do you ask? I've never seen the need for this feature, so you might just be thinking about the problem in a way that can be solved differently.

COMMENT: I meant this question to provide similar functionality like Dim Today as DateTime. Waiting for kind response from Lee....


[MZ] How to rewrite function Prompt? I tried to modify Profile.msh, however it didnt work :(

[LH] http://www.leeholmes.com/blog/GettingStartedCustomizeYourPrompt.aspx

COMMENT: Strange, it is working now - maybe it was solved, however my function (Function Prompt {“$(get-location)>“}) wasnt working when I add it to profile.msh. However now it is working like a charm...

 

Posted by martin | with no comments
Filed under: