Tag Archives: programming

New To Android? Why Not Start Developing For It!

I am new to the Android platform, but a few weeks ago I bought a Samsung Galaxy S2 mobile phone running Android 2.3.3 (gingerbread) and I absolutely love it. It has gotten me really interested in developing applications for it and as I already have experience writing applications in Java from my university days the learning curve should be pretty small.

All that’s really needed to get started is:

  • A Java Integrated Development Environment (IDE) such as Eclipse
  • The JAVA Software Development Kit (SDK) – The latest version is JDK version 7
  • The Android SDK available here
Android itself is open source so there are heaps of great resources online to get started developing applications. Google themselves have a great developer resource at their website¬†http://developer.android.com/guide/index.html¬†which has a lot of source code examples and tutorials. If I manage to build anything exciting I’ll be sure to post it up on here.

Wish me luck!

VBScript: How-To Obtain The Currently Logged On User’s SID

I wanted a quick script to determine the current logged on user’s SID which I could then write into a new script for example to log each user’s SID at logon (during a logon script, etc).

The script I wrote below uses the environment variables USERNAME and USERDOMAIN to determine who the current logged on user is, and which domain they have logged on to. That information is then used to in a call to the getSid() function which connects to the local computer WMI service and queries it to retrieve the SID for the current user from the Win32_UserAccount wmi class.

First we want to find the current user and domain that they have logged on to:

'find current user & domain
Set wshShell = CreateObject("WScript.Shell")
strUsername = wshShell.ExpandEnvironmentStrings("%USERNAME%")
strDomain = wshShell.ExpandEnvironmentStrings("%USERDOMAIN%")

We’ll then show that information to confirm we’ve retrieved the right information:

WScript.Echo "Username: " & strUsername
WScript.Echo "Domain: " & strDomain

'use the user/domain information to retrieve the SID of the user and print it to the screen
WScript.Echo getSid()

The code above makes a call to a function called ‘getSid() so lets write that procedure. The procedure below creates an object with reference to the local machine’s WMI service, and then retrieves the SID information from the Win32_UserAccount class. It would be better programming practice to pass the username and domain variables to the function and use those parameters locally in the function, but this was written quickly to illustrate the idea.

Private Function getSid()
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set objAccount = objWMIService.Get("Win32_UserAccount.Name='" & strUsername & "',Domain='" & strDomain & "'")
getSID = objAccount.SID
End Function

That’s it. This will return the SID for the currently logged on user. Hope this helps.