Hello, i found a script online to enable or disable a local user account, unfortunately i wanted to deploy this on AD and the script is name specific, im not much of a scripter but can i query the computer name in the script and then pass it to the string? This is what i have right now which doesn't work
*Modified*
' From the book "Windows XP Cookbook"
' ISBN: 0596007256
' ------ SCRIPT CONFIGURATION ------
' Set to FALSE to disable account or TRUE to enable account
Dim objUser
on error resume next
strDisableAccount = FALSE
strUserName = "HelpAssistant" ' e.g. rallen
strComputer = "objUser.ComputerName"
' ------ END CONFIGURATION ---------
set objUser = GetObject("WinNT://" & strComputer & "/" & strUserName)
if objUser.AccountDisabled = TRUE then
WScript.Echo "Account for " & objUser.Name & " currently disabled"
if strDisableAccount = FALSE then
objUser.AccountDisabled = strDisableAccount
objUser.SetInfo
WScript.Echo "Account enabled"
end if
else
WScript.Echo "Account currently enabled"
if strDisableAccount = TRUE then
objUser.AccountDisabled = strDisableAccount
objUser.SetInfo
WScript.Echo "Account disabled"
end if
end if
*Original*
' From the book "Windows XP Cookbook"
' ISBN: 0596007256
' ------ SCRIPT CONFIGURATION ------
' Set to FALSE to disable account or TRUE to enable account
strDisableAccount = FALSE
strUserName = "HelpAssistant" ' e.g. rallen
strComputer = ""
' ------ END CONFIGURATION ---------
set objUser = GetObject("WinNT://" & strComputer & "/" & strUserName)
if objUser.AccountDisabled = TRUE then
WScript.Echo "Account for " & objUser.Name & " currently disabled"
Question
ka0s
Hello, i found a script online to enable or disable a local user account, unfortunately i wanted to deploy this on AD and the script is name specific, im not much of a scripter but can i query the computer name in the script and then pass it to the string? This is what i have right now which doesn't work
*Modified*
' From the book "Windows XP Cookbook"
' ISBN: 0596007256
' ------ SCRIPT CONFIGURATION ------
' Set to FALSE to disable account or TRUE to enable account
Dim objUser
on error resume next
strDisableAccount = FALSE
strUserName = "HelpAssistant" ' e.g. rallen
strComputer = "objUser.ComputerName"
' ------ END CONFIGURATION ---------
set objUser = GetObject("WinNT://" & strComputer & "/" & strUserName)
if objUser.AccountDisabled = TRUE then
WScript.Echo "Account for " & objUser.Name & " currently disabled"
if strDisableAccount = FALSE then
objUser.AccountDisabled = strDisableAccount
objUser.SetInfo
WScript.Echo "Account enabled"
end if
else
WScript.Echo "Account currently enabled"
if strDisableAccount = TRUE then
objUser.AccountDisabled = strDisableAccount
objUser.SetInfo
WScript.Echo "Account disabled"
end if
end if
*Original*
' From the book "Windows XP Cookbook"
' ISBN: 0596007256
' ------ SCRIPT CONFIGURATION ------
' Set to FALSE to disable account or TRUE to enable account
strDisableAccount = FALSE
strUserName = "HelpAssistant" ' e.g. rallen
strComputer = ""
' ------ END CONFIGURATION ---------
set objUser = GetObject("WinNT://" & strComputer & "/" & strUserName)
if objUser.AccountDisabled = TRUE then
WScript.Echo "Account for " & objUser.Name & " currently disabled"
if strDisableAccount = FALSE then
objUser.AccountDisabled = strDisableAccount
objUser.SetInfo
WScript.Echo "Account enabled"
end if
else
WScript.Echo "Account currently enabled"
if strDisableAccount = TRUE then
objUser.AccountDisabled = strDisableAccount
objUser.SetInfo
WScript.Echo "Account disabled"
end if
end if
Link to comment
Share on other sites
11 answers to this question
Recommended Posts