[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

10/14/2009 at 03:45PM PDT, ID: 24813237 | Points: 500
[x]
Attachment Details

Logon script to change password failing "permission denied"

Asked by ORBITEC in File Servers, VB Script

Tags: vbs script logon script password change

I have a script that i'm trying to run on our domain as a log on script.  

the first script references the second script.

Script 1:

'LocalAdminPasswordChange.vbs
'******************************

'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 3.1
'
' NAME: Local Admin Password Change
'
' AUTHOR: Tyler Brill
' DATE : 9/14/2009
'
' COMMENT: This script is designed to be used as a login script
' that will change the Password of the Local Administrator
' on the computer that it is run on using creditials from a
' specified user account and password.
' NOTE: It calls the ChangePassword.vbs from a specified path in this
' script. If the ChangePassword.vbs file is not in the path, Then
' the script will not change the local admin password.
'==========================================================================
'==========================================================================
'********** IMPORTANT INFORMATION **********************
'* Because .vbs files are easy to view and this one contains a clear text
'* password it is important to use the Microsoft Script encoder to keep
'* sensitive information unavailable to someone using a text editor.
'* The encoder can be found at:
'* http://msdn.microsoft.com/library/default.asp?url=/downloads/list/webdev.asp
'* It is a command line tool FYI.
'==========================================================================

' ** First we set the variables for the script ** '
Dim WshShell, objFSO

' ** sUser is the Username
' ** sPass is the Users password
' ** sCommand is the command that you want run
' **
' ** You can replace these string variables to any user/password/command
' ** combo that you need to run on a pc.
' ** NOTE: If you change the sPass field be sure to retain the
' ** quotes and the ~ at the end of the actual password, it
' ** is the carriage return character.
sUser = "Administrator@orbitec.int"
sPass = "****************~"

' ** USAGE: sCommand = "wscript <path_to_scripts>\<your_script_here.vbs"
' ** or you can write in any command that needs to be run under
' ** a specific users account.
sCommand = "wscript \\pluto\software\change\changepassword.vbs"

' ** This is where we setup the working environment for the script to run in.
Set objComputer = CreateObject("Shell.LocalMachine")
Set WshNetwork = CreateObject("WScript.Network")
Set WshShell = CreateObject("WScript.Shell")
Set WshEnv = WshShell.Environment("Process")
WinPath = WshEnv("SystemRoot")&"\System32\runas.exe"
Set objFSO = CreateObject("Scripting.FileSystemObject")

'** Here we will check to see if this script has run on this computer.
'** If the file exist then we will end the script.

If objFSO.FileExists("C:\ChangeScriptLog.txt") Then
WScript.Quit

Else
' ** Here we open the Finished.txt and append the name of the computer
' ** that was just changed and the date it happened.

Set objTextFile = objFSO.OpenTextFile("\\pluto\software\change\Finished.txt", 8, True)
objTextFile.WriteLine(objComputer.MachineName) & " " & Date() & " " & Time() & " " & (WshNetwork.UserName)
objTextFile.Close

' ** Here we write a .txt file to the root of c: for verification that the script
' ** has been run on this computer.

Set objFile = objFSO.CreateTextFile("C:\ChangeScriptLog.txt")

End If

' ** This is the meat of the program and where the actual command is run.
rc = WshShell.Run ("runas /noprofile /user:" & sUser & " " & Chr(34) & sCommand & Chr(34))

' ** This gives the command window the time to open.
WScript.Sleep 900

' ** This will grab the active command window to send the password to.
WshShell.AppActivate(WinPath)

' ** This will send the password to the waiting window.
WshShell.SendKeys sPass

WScript.quit

' *********************************************

Script 2:

' Changepassword.vbs


' *********************************************

'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 3.1
'
' NAME: Change Password
'
' AUTHOR: Tyler Brill
' DATE : 10/14/2009
'
' COMMENT: This script is designed to work in conjuntion with
' the LocalAdminPasswordChange.vbs script as it must
' be run with administrative priviledges for the script
' to function properly.
'==========================================================================

'==========================================================================
'********** IMPORTANT INFORMATION **********************
'* Because .vbs files are easy to view and this one contains a clear text
'* password it is important to use the Microsoft Script encoder to keep
'* sensitive information unavailable to someone using a text editor.
'* The encoder can be found at:
'* http://msdn.microsoft.com/library/default.asp?url=/downloads/list/webdev.asp
'* It is a command line tool FYI.
'==========================================================================

' ** Setup the variables and working environment for the script **

Set WshNetwork = WScript.CreateObject("WScript.Network")
strComputer = WshNetwork.ComputerName

'* This gets the name of the current computer and then
'* retrieves the \\<computername>\Administrator account
'* as the object that we want to work with.

strComputer = "."
Set objUser = GetObject("WinNT://" & strComputer & "/Administrator,user")


' ******* This sets the Administrator Password here **************************
' ** NOTE: Type in quotes what you would like the new
' ** Local Administrator Account password to be set
' ** to, but keep in mind password complexity restrictions
' ** for your login server.

objUser.SetPassword "**************" ' <--- this will be the new admin password.
objUser.SetInfo

' **********************************************************


If I run the script while logged in as the domain administrator the script runs successfully.  However logged in as any other user I get the message shown in the screen shot attached to this post.  Line 69 is the line that writes to the output log file on the server.  I have no idea why permission is denied here.  Any ideas?
Attachments:
 
screenshot of error
screenshot of error
 
[+][-]10/14/09 03:50 PM, ID: 25576000

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/14/09 03:52 PM, ID: 25576010

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/14/09 04:06 PM, ID: 25576089

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/14/09 07:30 PM, ID: 25576808

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/15/09 10:16 AM, ID: 25582596

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/15/09 02:03 PM, ID: 25584881

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/15/09 03:01 PM, ID: 25585359

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/15/09 03:19 PM, ID: 25585474

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/16/09 07:01 AM, ID: 25589623

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/16/09 01:34 PM, ID: 25593101

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/16/09 03:27 PM, ID: 25593810

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/23/09 12:33 PM, ID: 25647586

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/31/09 03:07 PM, ID: 25711750

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/04/09 12:00 PM, ID: 25743281

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/05/09 05:42 PM, ID: 25756031

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91 - Hierarchy / EE_QW_3_20080625