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_sc
ript_here.
vbs"
' ** or you can write in any command that needs to be run under
' ** a specific users account.
sCommand = "wscript \\pluto\software\change\ch
angepasswo
rd.vbs"
' ** This is where we setup the working environment for the script to run in.
Set objComputer = CreateObject("Shell.LocalM
achine")
Set WshNetwork = CreateObject("WScript.Netw
ork")
Set WshShell = CreateObject("WScript.Shel
l")
Set WshEnv = WshShell.Environment("Proc
ess")
WinPath = WshEnv("SystemRoot")&"\Sys
tem32\runa
s.exe"
Set objFSO = CreateObject("Scripting.Fi
leSystemOb
ject")
'** 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:\Chan
geScriptLo
g.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("\\plu
to\softwar
e\change\F
inished.tx
t", 8, True)
objTextFile.WriteLine(objC
omputer.Ma
chineName)
& " " & 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:\
ChangeScri
ptLog.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(WinPa
th)
' ** 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.v
bs 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("WScr
ipt.Networ
k")
strComputer = WshNetwork.ComputerName
'* This gets the name of the current computer and then
'* retrieves the \\<computername>\Administr
ator 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?