# Wednesday, June 13, 2007

I'll be honest ... I'm lazy.  I hate doing repetitive things over, and over, and over again.  So, while I was going through and installing Commerce Server 2007 on a new virtual machine, I decided to script out the creation of the local user accounts.  Before we get to the script, a little background ...

It is recommended that you create multiple accounts to handle the various roles within Commerce Server (such as the four web services, staging, etc).  In a production environment, these should be created as Domain accounts; however, in development (or the virtual world) you may not have access to, or wish to use, a domain. Consequently, you can create these users as local accounts as well.

Below is a script that will go ahead and create these local users for you (if I have time I'll create a similar script for domain accounts).  Copy the text (or download the link) and save it to a .vbs file.  You should be able to simply double-click the file, and then open up Local Users and Groups under Computer Management to double-check.

' =====================================================
' Author:        Wade Wegner
' Create date:   06/13/2007
' Description:   Automate the creation of CS 2007 users
' File Name:     CreateCS2007LocalUsers.vbs

' =====================================================

' Set the local computer name
strComputer = "."

' Run the Load method
Load

' Encapsulates the processing of this script
Sub Load()

   ' Create the CS 2007 users
   CreateUser "CatalogWebSvc","Pa$$w0rd","Account for running the Catalog Web service"
   CreateUser "CSDMSvc","Pa$$w0rd","Account for running the Commerce Server Direct mailer service"
   CreateUser "CSHealthMonitorSvc","Pa$$w0rd","Account for running the Commerce Server health Monitoring service"
   CreateUser "CSLOB","Pa$$w0rd","Account for running the Commerce Server adapters"
   CreateUser "CSStageSvc","Pa$$w0rd","Account for running the Commerce Server Staging service"
   CreateUser "MarketingWebSvc","Pa$$w0rd","Account for running the Marketing Web service"
   CreateUser "OrdersWebSvc","Pa$$w0rd","Account for running the Orders Web service"
   CreateUser "ProfilesWebSvc","Pa$$w0rd","Account for running the Profiles Web service"
   CreateUser "RunTimeUser","Pa$$w0rd","IIS account for accessing a Commerce Server site or application"

   MsgBox "Complete!"

End Sub

' Create the local user
Sub CreateUser(userName, password, description)

   ' Check to see if the user exists; if so, then skip
   If NOT CheckIfUserExists(userName) Then
      Set objComputer = GetObject("WinNT://" & strComputer & "")
      Set objUser = objComputer.Create("user", userName)

      objUser.SetPassword password
      objUser.FullName = userName
      objUser.Description = description
      objUser.Put "UserFlags", 65600 ' Sets Password Never Expires to TRUE
      ' and sets User Can't Change Password to TRUE
      objUser.SetInfo
   Else
      MsgBox userName & " already exists!"
   End If

End Sub

' Check to see if user exists
Function CheckIfUserExists(userName)

   Set objComputer = GetObject("WinNT://" & strComputer & "")
   objComputer.Filter = Array("user")
   intFound = 0

   For Each User In objComputer
      If lcase(User.Name) = lcase(userName) Then
         intFound =
      End If 
   Next

   If intFound = 1 Then
      CheckIfUserExists = True
   Else
      CheckIfUserExists = False
   End If

End Function

And there you have it!

CreateCS2007LocalUsers.vbs (2.46 KB)

I hope someone else finds this useful!

Saturday, September 22, 2007 6:33:28 PM (Central Standard Time, UTC-06:00)
Thank you very, very much! I really needed this!
Daniel
Sunday, September 23, 2007 2:12:15 PM (Central Standard Time, UTC-06:00)
I am very glad it helped! Best regards!
Monday, August 11, 2008 1:35:48 AM (Central Standard Time, UTC-06:00)
From wow gold the monster filled wow gold depths of Wailing cheap wow gold Caverns to the fanatic's cheap wow gold stronghold known as Scarlet buy wow gold Monestary, the buy wow gold world of Azeroth is a place of world of warcraft gold great danger world of warcraft gold and adventure. Whether fast wow gold you seek to unravel the machinations of free wow gold Onyxia, stem the fast wow gold growth lotro gold of the buy cheap wow gold Scourge or destroy wow gold for sale the resurrected wow gold tips avatar sell wow gold of Hakkar, having wow gold guide to show you age of conan gold the way around the age of conan gold can only be aoc gold to your aoc gold advantage. Simply cheap aoc gold getting to level 60 sometimes buy aoc gold is not enough ffxi gil - in order ffxi gil to even rs gold gain swg credits entrance into silkroad gold the epic guild wars gold dungeons such as anarchy gold Molten Core, Blackwing gaia gold Lair and 2moons dil Naxxramas, your maple story mesos character eve isk must lineage 2 adena complete eq2 plat difficult and warhammer online gold dangerous warhammer gold quests that must warhammer power leveling be done buy warhammer gold in a wow power leveling group.

Whether wow powerleveling,wow power leveling,wow powerleveling you are Alliance or Horde, power leveling the quests to powerleveling become world of warcraft power leveling attuned to world of warcraft powerleveling any high world of warcraft power leveling level dungeon world of warcraft powerleveling needs to be wow power level done in groups. Some wow power level quests require wow powerlevel you to go wow powerlevel to the wow leveling very lowest levels wow leveling of Blackrock Depths, or travel the world power leveling seeking elite dragons ffxi power leveling to kill, or confront aoc power leveling Onyxia and her minions rs power leveling in the throne room of Stormwind City.
Saturday, November 08, 2008 5:19:58 AM (Central Standard Time, UTC-06:00)
Hi,

Thanks for the script it works fine, but can you please provide me account expiry function in the same script please?
I am having following script for setting expiry date for the created account, but don't know to merge both the scripts, as i am not a software guy, so can you please help me out in this.

SCRIPT : for Setting an Expiration Date for a Local User Account

Binds to a local user account (kenmyer) on a computer named atl-win2k-01, and configures the account to expire on March 1, 2003.

strComputer = "atl-win2k-01"
Set objUser = GetObject("WinNT:// " & strComputer & "/kenmyer ")
objUser.AccountExpirationDate = #03/01/2003#
objUser.SetInfo


please mail me the solution on mayurgharat@gmail.com.

Thanks A LOT,
Mayur Gharat
Mayur Gharat
Wednesday, December 17, 2008 9:16:47 PM (Central Standard Time, UTC-06:00)
I think this code is awesome also. It does what a lot of scripts do not. I also have one question though. When I check the accounts it does not add them to local groups. I have tried different variations of the code but none of them add the account to local groups. All the ones I have found require you to specify the computer name.

Is there some way to make this add the accounts to a specific group?

Thanks again Wade.

Kevin
Name
E-mail
Home page

Comment (Some html is allowed: a@href@title, b) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview