Expert Texture Home Contact me About Subscribe Digipede Connect on LinkedIn rwandering on Twitter rwandering on FriendFeed

rwandering.net

The blogged wandering of Robert W. Anderson

.NET on Server Core

Dmitry Sotnikov provides the steps to get PowerShell — and of more general interest, .NET 2.0 —  running on Windows Server 2008 Server core.

While this is a stopgap until Microsoft officially supports this configuration, it could still be useful. 

Now the question for me is, will this work for running Digipede components?

[tags]Digipede, .NET, PowerShell, Server 2008, Server Core[/tags]

Tags: , , , ,

Unprivileged Tasks in Windows 6 with VBS

Last week, Bart de Smet wrote about calling the Task Scheduler in Windows Vista (and Windows Server 2008) from managed code.  In his usual style, he does a great job diving into the topic.

It reminded me of something I did last year for Windows Server 2008 Certification: write code to start an unprivileged task in Windows 6 specifically written for installers.   

If you are familiar with UAC, you know that applications identify their least required privilege level in their manifest.  Applications that don’t require elevation identify themselves with the level="asInvoker" tag (the value may be confusing, but makes sense).

This creates a bit of complexity for installations that launch applications when they finish.  If your installation required elevation, but the launched application does not, what should you do?  Windows UAC guidelines say that you should launch them unprivileged.  This makes sense: you don’t want an application to run elevated as a side-effect of the installation.

And you do this by starting the task in the Windows 6 task scheduler.

The UAC guidelines contain some C++ code for this, and Bart has a managed version, but for reasons of maintainability and consistency, we wanted VB Script.  I was able to find some pieces of this online, but the following code is basically a port of the UAC Guidelines version with a check for Windows version too. 

' Arguments 
set args = WScript.Arguments 
if args.Count >= 1 then 
    strCommand = args(0) 
end if 
if args.Count >= 2 then 
    strArguments = args(1) 
end if 

' Determine the version of Windows 
set objWMI = GetObject("winmgmts:\\.\root\cimv2") 
set colOS = objWMI.InstancesOf("Win32_OperatingSystem") 
for each objOS in colOS 
   version = split(CStr(objOS.Version), ".", 2) 
next 

if CInt(version(0)) < 7 then 
    ' pre Vista / Server 2008.  Just run the task directly 
    set objShell = CreateObject("Wscript.Shell") 
    set objProc  = objShell.Exec(strCommand & " " & strArguments) 
else 
    ' Vista / Server 2008 or later.  Schedule it for immediate execution 
    scheduleTask strCommand, strArguments 
end if 

' Schedule a task for immediate execution; requires Windows 6 or later 
private sub ScheduleTask(strCommand, strArguments) 
    ' Some constants we need 
    TASK_TRIGGER_REGISTRATION = 7 
    TASK_ACTION_EXEC = 0 
    TASK_CREATE	= 2 
    TASK_LOGON_GROUP = 4 

    on error goto 0 
    ' Get the TaskService class 
    set pService = CreateObject("Schedule.Service") 

    ' Connect to the task service. 
    pService.Connect  

    '  Get pointer to root task folder. 
    set pRootFolder = pService.GetFolder("\") 

    Randomize(20000) 
    taskName = "MyBackgroundTask " & CStr(Rnd(1000)) 

    '  See if task exists, delete it if it does. 
    on error resume next 
    pRootFolder.DeleteTask taskName, 0 
    on error goto 0 

    '  Create task 
    set pTask = pService.NewTask(0) 
    set pSettings = pTask.Settings 
    pSettings.StopIfGoingOnBatteries = false 
    pSettings.DisallowStartIfOnBatteries = false 

    ' Create trigger 
    set triggerCollection = pTask.Triggers 
    set trigger = triggerCollection.Create(TASK_TRIGGER_REGISTRATION) 

    ' Create a new action 
    set actionCollection = pTask.Actions 
    set action = actionCollection.Create(TASK_ACTION_EXEC) 
    action.Path = strCommand 
    action.Arguments = strArguments 

    ' Register the task using users group 
    set registeredTask = pRootFolder.RegisterTaskDefinition(taskName, pTask, TASK_CREATE,  "S-1-5-32-545", null, TASK_LOGON_GROUP, "") 

    ' give 10 seconds for the task to start 
    for i = 0 to 100 
        state = registeredTask.State 
        if state = TASK_STATE_RUNNING then 
            break 
        end if 
        WScript.Sleep 100 
    next 

   ' delete the task 
    pRootFolder.DeleteTask taskName, 0 
end sub

You can see it takes arguments for the application and an argument to pass to the application.  Also note that the VBS must be run elevated in Windows 6, otherwise tasks cannot be scheduled.

Ah, VB Script.  You gotta love it.  Or not, but I wish someone else had posted this! 

Note to Microsoft: you would have saved a lot of people time if you had included a VBS version in your guidelines document.

[tags]VBS, UAC, Server 2008, Vista, Windows 6, Task Scheduler[/tags]

Tags: , , , , ,

Come see Digipede at the Microsoft launch event

Heroes who happen by our booth at the Server 2008, Visual Studio 2008, and SQL Server 2008 launch will get a chance to win an XBOX-360.  OK, you don’t have to be hero, but you do have to be spotted wearing a Digipede sticker sporting our mascot, Deatle.

image image

Come on by and see us.

BTW: I won’t be at this event, but I’ll be at the one in SF on March 13th.  No Digipede booth or give-away there.

[tags]Server 2008, Microsoft, Launch, Digipede, XBOX, Deatle[/tags]

Tags: , , , , ,

An SP1 by any other name would . . .

Mary Jo Foley writes there’s no Windows Server 2008 SP1 in the works.

Why?  Because the first RTM of Server 2008 is called Windows Server 2008 SP1.  This is due to Server 2008 and Vista sharing the same core code and components.

Hmm.

This makes only marginal sense, and then only if Microsoft commits to keeping the service packs synchronized across the Windows 6 product family.  I think this will be less confusing to customers.  We’ll see if this synchronization happens. 

Regardless of Microsoft’s plans, the SP1 designation on Server 2008 is misleading.  Most of the server components of Windows 6 will remain without a service pack until SP2.

Customers who like to wait for initial service packs still will — unless they are duped into thinking they’ve already got it.

[tags]Microsoft, Server 2008, Vista, Windows, SP1[/tags]

Tags: , , , ,

Certified for Windows Server 2008

Certified for Windows Server 2008We just received our certification for Windows Server 2008.  Or we are about to — it probably isn’t “official” yet.  Anyway, congratulations to the Digipede team and thanks to everyone at Microsoft and Veritest who helped us through the process.

Getting the logo was arduous.  This has less to do with the technical logo requirements and more to do with the complexities of the process itself.  Some of the complexity is inherent in such a process, but much was due to the program itself being a sort of “work in process”.  But hey, that’s why we early certifiers got the testing fees waived.  I think those who begin the process now will find the test requirements and tools are better written and more robust.

As I said, passing the technical requirements was not arduous for us (we were already very close), but passing the tests did require some minor improvements to the Digipede Network that were motivated by the test:

  • Support for User Account Control (UAC).
  • More useful logging on the Digipede Server and during installations.
  • Improved user messaging and event logging during error conditions between server components and the database.
  • Improvements to the Installation Guide including new sections on Custom Actions, installation artifacts, and more.

Some of these changes have already made their way into the shipping product, though others won’t be available until the Digipede Network 2.1 (which, while a minor upgrade, contains many features beyond the improvements mentioned above — I think the feature set will be announced soon).

So now we’re ready for the big launch of Server 2008, Visual Studio 2008, and SQL Server 2008 in Los Angeles on February 27th.  If you are going to be there, come see us at the Partner Pavilion.  I’m pushing for some kind of Digipede swag — but I’m not in marketing ;).

[tags]Server 2008, VS2008, SQL, Certified, Digipede[/tags]

Tags: , , , ,