Question : How to get login script stored in mssql database

Hi,

I want to put an entire login script in a sql database and then get it when the user login in the domain.

I tested write a script like this:

Set obj_Shell = CreateObject("WScript.Shell")
select.txt run sp for print out login script in text form
Set obj_WSH = obj_Shell.Exec("sqlcmd -h-1 -S 192.168.0.184\wdb11 -U xx -P xx -d loginscript -i select.txt")

Set obj_STDOUT = obj_WSH.StdOut
str_Output = obj_STDOUT.ReadAll
WScript.echo str_Output

'objFile.writeLine str_Output


Can I use sql database for storing login script in text form in the database? And get it from there, and run it when the user login?

Regards
//Peter

Answer : How to get login script stored in mssql database

I figured out....:
'Start -----------------------------------------------
Set WSHNetwork = WScript.CreateObject("WScript.Network")
UserName = ""
UserName = WSHNetwork.UserName

On Error Resume Next
Set obj_Shell = CreateObject("WScript.Shell")

sql_query = "sqlcmd -h-1 -S 192.168.0.184\wdb11 -U xx -P xx -d loginscript -Q ""exec LongPrint """ + username + """"
Set obj_WSH = obj_Shell.Exec(sql_query )
Set obj_STDOUT = obj_WSH.StdOut
str_Output = obj_STDOUT.ReadAll

'WScript.Echo str_Output
Execute(str_Output)
'End ------------------------------------------------------------------------

The procedure I had to use, found at: http://blog.falafel.com/2007/02/28/TSQLExceedingThe8000ByteLimitOfThePRINTStatement.aspx
I neded this because the loginscript field vas more then 8000 characters.
Random Solutions  
 
programming4us programming4us