views:

83

answers:

1

Hi,

My requirement is that I need to create a local user on my System (On my Windows OS) using T-SQL. And I need to set this user under ‘Administrators’ group.

Using this local user I should be able to login to my Windows OS (At System Startup).

Is it possible? If so may I know how could we do this?

Many Thanks,

Regards.

Anusha.

+1  A: 

You might want to look into xp_cmdshell for T-SQL

Example

The rows are returned in an nvarchar(255) column.

Executing this xp_cmdshell statement returns the following result set:

xp_cmdshell 'dir *.exe', NO_OUTPUT

You should also look over the security when doing this, see this msdn article

Adding users through command line

See this documentation on adduser

Syntax

Create Users:

        AddUsers /c filename [/s:x] [/?] Domain Password_options

Dump to file:

        AddUsers /d{:u} filename [/s:x] [/?] Domain Password_options

Erase Users:

        AddUsers /e filename [/s:x] [/?] Domain Password_options
Filip Ekberg