Need last logon time and account creation.
I pulled a last logon script from the internet, and i cant figure out why i
am getting the specified error:
(158, 5) (null): A referral was returned from the
server.
I want to retrieve, last logon, user id, accounts disabled and when account
was created.
I thought it was the LDAP:\\ query and tried putting in dc =xyz,dc=local
But that didnt work either.
script pulled from internet below:
'
' File: AllUsersLastLogon.vbs
' DESCRIPTION:
' * User-ID
' * Last Logon server
' * Date and Time of last logon
' * Logon older than 30 days
' * Has never logged on at all.
' * Account Disabled
' * Account created at
' * Flag error Code
' * Users Full name
' * OU path
' * LDAP path
' * Special Error codes
Option Explicit
Dim DomainName, DomainName2, strDN, concat, obj
Dim objExcel, ws, WriteFile, WriteFilePath
Dim oConnection, oCommand, oRoot, strDomain
Dim strPath, strQuery, oResults, sPosition
Dim CRLF
Dim FolderPath
Dim fso, WshShell
Dim User, DC, ShowResult
Dim Pos1, Pos2, Pos3, Pos4, Pos5, Pos6
Dim OldYearTime, OldYearTimeLen, DateTimeCounter
Dim NewYearTime, NewYear, OldYear, CompareYear, NewYearVal, OldYearVal
Dim NewDate, NewDateTime, NewMonth, OldDate, OldDateTime, OldMonth, NewDay,
NewDayVal, OldDay, OldDayVal
Dim NewTime, NewTimeVal, OldTime, OldTimeVal
Dim LogonDC, intButton
Dim i, x, c, DomainObj, UserObj
Dim UserLastLogonArray()
Dim MyArraySize
Dim MyDateAndTimePos, MyPeriodPos, a, MessageVal
Dim Flag, CodeAccDis, Code
Dim DCName, UserInDomain, DomainString, userName, iElement, UserVal
Dim strWhenCreated, objUser, DateTimeVal
Dim Users30DaysNo
Dim UserInDomainNo
Dim UsersNoLogonNo
Dim AccountDisNo, FileTime, ExcelPath, NoLastLoginCounter, UserNeverLoggedOn
NoLastLoginCounter = 0
UserNeverLoggedOn = False
FileTime = Timer
AccountDisNo = 0
UsersNoLogonNo = 0
Users30DaysNo = 0
UserInDomainNo = 0
MessageVal = 0
DateTimeCounter = 0
OldYearTime = 1
FolderPath = "C:\Temp"
WriteFilePath = "C:\Temp\WriteAllUsersLastLogon"
c = 2
DateTimeVal = Date & " " & Time
'*******************************************************************************************
' Preliminary work and functions
'*******************************************************************************************
Set WshShell = Wscript.CreateObject("WScript.shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Function ControlSyntax()
if wscript.arguments.count <> 1 Then
wscript.echo "Syntax error. Usage: cscript badauths.vbs loginname"
wscript.quit (5555)
end If
DomainName = "dc=" & wscript.arguments(0) & ",dc=dk"
DomainName2 = wscript.arguments(0) & ".dk"
End function
'Creates the folder if necssesary
Function MakeFolder()
If Not fso.FolderExists (FolderPath) then
fso.CreateFolder ("C:\Temp")
End If
End Function
'Creates the file if necssesary, and writes the headers of the rows
Function MakeFile()
If (fso.FileExists(WriteFilePath + ".htm")) Then
fso.DeleteFile(WriteFilePath + ".htm")
End If
Set WriteFile = fso.OpenTextFile(WriteFilePath & "_" & FileTime &
".htm", 8, true, -2)
WriteFile.Write "<html>" & vbCRLf & "<head>" & vbCRLf
WriteFile.Write "<link rel='stylesheet' TYPE='text/css'
HREF='http://dkweb:12345/css/default.css'>" & vbCRLf
WriteFile.Write "</head>" & vbCRLf & "<body bgcolor='#98FB98'>" & vbCRLf
WriteFile.Write "<script language='vbscript'>" & vbCRLf
WriteFile.Write "Set WShell = CreateObject(" & chr(34)& "WScript.Shell"
& chr(34) & ")" & vbCRLf
WriteFile.Write "</script>" & vbCRLf
WriteFile.Write "<h1 class='H4'>User last logon was ...</h1>" & vbCRLf
WriteFile.Write "<hr color='#6B8E23' width='100%'><br>" & vbCRLf
WriteFile.Write "<font class='LogText'>Script startet at " & Date & " "
& Time & vbCRLf
WriteFile.Write "<br><hr color='#6B8E23' width='100%'><br><font
class='LogText'>" & vbCRLf
WriteFile.Write "<br><br><h3>STATUS:" & vbCRLf & vbCRLf
Set objExcel = WScript.CreateObject("EXCEL.application")
objExcel.Visible = True
objExcel.Workbooks.Add
Set ws = objExcel.Worksheets(1)
objExcel.ActiveSheet.Name = "Last Logon"
ws.Cells(1,1).Value = "User-ID"
ws.Columns(1).ColumnWidth = 15
ws.Cells(1,2).Value = "Last logged on Server"
ws.Columns(2).ColumnWidth = 20
ws.Cells(1,3).Value = "At date and time"
ws.Columns(3).ColumnWidth = 20
ws.Cells(1,4).Value = "Older than 30 days"
ws.Columns(4).ColumnWidth = 25
ws.Cells(1,5).Value = "Has Never Logged On"
ws.Columns(5).ColumnWidth = 25
ws.Cells(1,6).Value = "Account Disabled"
ws.Columns(6).ColumnWidth = 20
ws.Cells(1,7).Value = "Account Created at"
ws.Columns(7).ColumnWidth = 18
ws.Cells(1,8).Value = "Flag Error Code"
ws.Columns(8).ColumnWidth = 15
ws.Cells(1,9).Value = "Users Full Name"
ws.Columns(9).ColumnWidth = 35
ws.Cells(1,10).Value = "OU path"
ws.Columns(10).ColumnWidth = 30
ws.Cells(1,11).Value = "LDAP path"
ws.Columns(11).ColumnWidth = 70
ws.Cells(1,12).Value = "Special Error codes"
ws.Columns(12).ColumnWidth = 20
objExcel.Range("A1:L1").Select
objExcel.Selection.Font.Bold = True
objExcel.Selection.Interior.ColorIndex = 5
objExcel.Selection.Interior.Pattern = 2
objExcel.Selection.Font.ColorIndex = 2
objExcel.ActiveSheet.Range("A1").Activate
ws.Cells(1,1).Select
intButton = WshShell.Popup("Working, please wait...", , "Working !", 64)
End Function
'*******************************************************************************************
' Get All Users for all DC's
'*******************************************************************************************
Function GetDCforDomain()
Set oConnection = CreateObject("ADODB.Connection")
Set oCommand = CreateObject("ADODB.Command")
oConnection.Provider = "ADsDSOObject"
oConnection.Open = "Active Directory Provider"
Set oCommand.ActiveConnection = oConnection
Set oRoot = GetObject("LDAP://RootDSE")
'strDomain = oRoot.Get("DefaultNamingContext")
strDomain = DomainName
concat="LDAP://OU=Domain Controllers," & strDomain
'OU for Domain Controllers
set obj=GetObject(concat)
For Each DCName In obj
UserInDomainNo = UserInDomainNo + 1
Next
For Each DCName In obj
UserInDomain = DCName.name
Exit For
Next
ForAllUsers()
End Function
Function ForAllUsers()
Set DomainObj = GetObject("WinNT://" & DomainName2)
DomainObj.Filter = Array("user")
' List all users
For Each UserObj In DomainObj
userName = UserObj.Name
GetUserLastLogon()
NoGo = 0
'If c = 40 Then
'If you only want to check a specific number of users for a start
'Exit Function
'then undo the remark and type the number of users you want to check
'End If
Next
End Function
'*******************************************************************************************
' Get All Users LastLogin for all DC's
'*******************************************************************************************
Dim UsersOU, UserFullName, MyPos1, MyPos2, TopOU, SearchName, BadSymbol
Dim counter, BadName, NoGo, UserGotNoOU
counter = 0
NoGo = 0
Function GetUserLastLogon()
'Check all users LastLogin at all DC's
i = 2
x = 0
For Each DCName In obj
'For each DC in DC-collection, go check ...
strQuery = "SELECT distinguishedName, AdsPath, ou FROM 'LDAP://" &
strDomain & "'WHERE sAMAccountName = '" & userName & "'"
oCommand.CommandText = strQuery
Set oResults = oCommand.Execute
strDN = oResults.Fields("distinguishedName")
strPath = DCName.name & "." & DomainName2 & "/" & strDN
'Remove the initial CN= from the distinguished name, put it back in
strPath.
sPosition = InStr(1, strPath, "=", 1)
strPath = Mid(strPath, sPosition +1)
Pos1 = InStr (1,strPath,"/",1)
DC = Left (strPath, (Pos1 -1))
Set User = GetObject("WinNT://" & DC & "/" & userName & ",user")
'userName = User-ID
UsersOU = oResults.Fields("AdsPath")
UserFullName = User.FullName
'-------- Checking validity of users FullName and OU membership
--------
MyPos1 = ""
MyPos2 = ""
UserGotNoOU = False
MyPos1 = InStr (4, UsersOU, "OU=", 1)
If MyPos1 = 0 Then
'If user is not a member of a manually created OU, then
... (ex. member of default OU Users)
UserGotNoOU = True
MyPos1 = InStr (9, UsersOU, "CN=", 1)
'Search for the next 'CN=' in the AdsPath
MyPos2 = InStr (MyPos1, UsersOU, "DC=", 1)
TopOU = Mid (UsersOU, (MyPos1+3), ((MyPos2-1)-(MyPos1+3)))
'Gets a default OU, ex. OU=Users (It's really called
CN=Users)
Else
MyPos2 = InStr (MyPos1, UsersOU, "DC=", 1)
'Capture the users OU
TopOU = Mid (UsersOU, (MyPos1+3), ((MyPos2-1)-(MyPos1+3)))
'Gets the OU path, ex. OU=TEST2,OU=TEST1,OU=TEST
End If
MyPos1 = ""
MyPos2 = ""
MyPos1 = InStr (4, UsersOU, "CN=", 1)
'Capture the users Full Name
MyPos2 = InStr (MyPos1, UsersOU, ",OU=", 1)
'Capture the users Full Name
If MyPos2 = 0 Then
'If user is not a member of a manually created OU, then
... (ex. member of default OU Users)
UserGotNoOU = True
MyPos2 = InStr (MyPos1, UsersOU, ",CN=", 1)
'Capture the users Full Name
SearchName = Mid (UsersOU, (MyPos1+3), (MyPos2-(MyPos1+3)))
'Capture the users Full Name
ws.Cells(c,9).Value = SearchName
ws.Cells(c,10).Value = TopOU
ws.Cells(c,11).Value = UsersOU
Else
SearchName = Mid (UsersOU, (MyPos1+3), (MyPos2-(MyPos1+3)))
'Capture the users Full Name
ws.Cells(c,9).Value = SearchName
ws.Cells(c,10).Value = TopOU
ws.Cells(c,11).Value = UsersOU
End If
'-------- End of 'Checking validity of users FullName and OU
membership' --------
Flag = UserObj.UserFlags
'User Flag Code Set
On Error Resume Next
ShowResult = User.LastLogin
'Gets the last login date and time for the user
If Err.Number <> 0 Then
'Capture any no-LastLogin events
OldYearTime = " - "
NoLastLoginCounter = NoLastLoginCounter + 1
'Accumulating requested DC's
LogonDC = "-"
Else
'... Else ... Building up the Array with last logins
ReDim Preserve UserLastLogonArray(x)
UserLastLogonArray(x) = ShowResult & "_" & DC
UserVal = 1
'... User did at least one log on to the Domain
x = x + 1
'Counting up the Array size
End If
If NoLastLoginCounter = 9 Then
UserNeverLoggedOn = True
UsersNoLogonNo = UsersNoLogonNo + 1
End If
Next
MyArraySize = UBound (UserLastLogonArray) + 1
GetDateAndTime()
End Function
'*******************************************************************************************
' Get date and time for all elements in the Array, if any,
' and writing the result to the worksheet.
'*******************************************************************************************
Function GetDateAndTime()
a = 0
i = 0
For a = 1 To MyArraySize Step 1
'Go throug elements in the Array
If UserVal = 0 Then
'If user do not have a LastLogin value, then ...
If NoGo <> 1 Then
OldYearTime = " - "
LogonDC = " - "
End If
ws.Cells(c,1).Select
ws.Cells(c,1).Value = UserObj.Name
objExcel.Selection.Font.ColorIndex = 3
ws.Cells(c,2).Select
ws.Cells(c,2).Value = LogonDC
objExcel.Selection.Font.ColorIndex = 3
ws.Cells(c,3).Select
ws.Cells(c,3).Value = OldYearTime
objExcel.Selection.Font.ColorIndex = 3
If UserNeverLoggedOn = True Then
ws.Cells(c,5).Select
ws.Cells(c,5).Value = "Has Never Logged On"
objExcel.Selection.Font.ColorIndex = 3
End If
ws.Cells(c,7).Value = strWhenCreated
Else
MyDateAndTimePos = InStr (UserLastLogonArray(i), "_")
NewYearTime = Left (UserLastLogonArray(i), MyDateAndTimePos
- 1)
MyPeriodPos = InStr (UserLastLogonArray(i), ".")
DC = Mid (UserLastLogonArray(i), (MyDateAndTimePos + 1),
MyPeriodPos - (MyDateAndTimePos + 1))
Call LatestLogon (NewYearTime, DC)
Call CheckLogonDates (OldYearTime, LogonDC)
DateTimeCounter = DateTimeCounter + 1
i = i + 1
End If
Next
If MessageVal = 0 Then
ws.Cells(c,1).Value = UserObj.Name
ws.Cells(c,2).Value = LogonDC
ws.Cells(c,3).Value = OldYearTime
ws.Cells(c,8).Value = Flag
If Flag = 515 Or Flag = 547 Then
ws.Cells(c,6).Select
ws.Cells(c,6).Value = "Account Disabled***"
objExcel.Selection.Font.ColorIndex = 3
ws.Cells(c,8).Select
ws.Cells(c,8).Value = Flag
objExcel.Selection.Font.ColorIndex = 3
AccountDisNo = AccountDisNo + 1
End If
ws.Cells(c,7).Value = strWhenCreated
Else
ws.Cells(c,1).Select
ws.Cells(c,1).Value = UserObj.Name
objExcel.Selection.Font.ColorIndex = 3
ws.Cells(c,2).Select
ws.Cells(c,2).Value = LogonDC
objExcel.Selection.Font.ColorIndex = 3
ws.Cells(c,4).Select
ws.Cells(c,4).Value = OldYearTime
objExcel.Selection.Font.ColorIndex = 3
Users30DaysNo = Users30DaysNo + 1
ws.Cells(c,7).Value = strWhenCreated
ws.Cells(c,8).Value = Flag
End If
DateCreationForUser()
c = c + 1
UserVal = 0
ReDim UserLastLogonArray(x)
OldYearTime = 1
DateTimeCounter = 0
counter = 0
NoLastLoginCounter = 0
UserNeverLoggedOn = False
End Function
'*******************************************************************************************
' Which logon in the UserLastLogonArray is the
latest
'*******************************************************************************************
Function LatestLogon(NewYearTime, DC)
If DateTimeCounter >= 1 Then
Pos1 = 0
Pos2 = 0
Pos1 = InStr (NewYearTime, " ")
NewYear = Left (NewYearTime, (Pos1-1))
NewYearVal = Right (NewYear, 4)
OldYearTimeLen = Len (OldYearTime)
If OldYearTimeLen > 2 Then
Pos2 = InStr (OldYearTime, " ")
OldYear = Left (OldYearTime, (Pos2-1))
OldYearVal = Right (OldYear, 4)
If NewYearVal >= OldYearVal Then
If NewYearVal = OldYearVal Then
NewDate = Left (NewYear, 5)
NewMonth = Right (NewDate, 2)
OldDate = Left (OldYear, 5)
OldMonth = Right (OldDate, 2)
If NewMonth >= OldMonth Then
If NewMonth = OldMonth Then
NewDay = Left (NewYear, 2)
OldDay = Left (OldYear, 2)
If NewDay >= OldDay Then
If NewDay = OldDay Then
Pos5 = Len (NewYearTime)
NewTime = Right (NewYearTime,
(Pos5-Pos1))
Pos6 = Len (OldYearTime)
OldTime = Right (OldYearTime,
(Pos6-Pos2))
If NewTime > OldTime Then
OldYearTime = NewYearTime
LogonDC = DC
End If
Else
OldYearTime = NewYearTime
LogonDC = DC
End If
End If
Else
OldYearTime = NewYearTime
LogonDC = DC
End If
End If
Else
OldYearTime = NewYearTime
LogonDC = DC
End If
End If
End If
End If
If DateTimeCounter < 1 Then
OldYearTime = NewYearTime
LogonDC = DC
End If
MessageVal = 0
End Function
'*******************************************************************************************
' Check to see if the latest logon is older than
30 days
'*******************************************************************************************
Dim MyVal
Function CheckLogonDates (OldYearTime, LogonDC)
User = UserObj.Name
Pos2 = ""
OldYear = ""
OldYearVal = ""
Pos2 = InStr (OldYearTime, " ")
OldYear = Left (OldYearTime, (Pos2-1))
OldYearVal = Right (OldYear, 4)
OldDate = Left (OldYear, 5)
OldMonth = Right (OldDate, 2)
OldDay = Left (OldDate, 2)
NewYearVal = Right (Date, 4)
NewDate = Left (Date, 5)
NewMonth = Right (NewDate, 2)
NewDay = Left (NewDate, 2)
MyVal = (NewMonth - OldMonth)
If OldYearVal <= NewYearVal Then
If OldYearVal < NewYearVal Then
MessageVal = 1
Else
If OldMonth < NewMonth Then
If (NewMonth - OldMonth) < 2 Then
If OldDay <= NewDay Then
MessageVal = 1
End If
Else
MessageVal = 1
End If
End If
End If
End If
End Function
'*******************************************************************************************
' Checking creation date for user account
'*******************************************************************************************
Function DateCreationForUser()
BadSymbol = InStr (1, SearchName, "/", 1)
'Check for bad symbol in canonical name ...
If BadSymbol <> 0 Then
ws.Cells(c,7).Select
ws.Cells(c,7).Value = "Check Manually !"
objExcel.Selection.Font.ColorIndex = 3
NoGo = 1
Else
On Error Resume Next
If UserGotNoOU = True Then
Set objUser = GetObject ("LDAP://cn=" & UserFullName &
",cn=" & TopOU & ",dc=cdas,dc=dk")
If Err.Number <> 0 Then
ws.Cells(c,12).Value = Err.Number
End If
Else
Set objUser = GetObject ("LDAP://cn=" & UserFullName &
",ou=" & TopOU & ",dc=cdas,dc=dk")
If Err.Number <> 0 Then
ws.Cells(c,12).Value = Err.Number
End If
End If
objUser.GetInfo
strWhenCreated = objUser.Get("whenCreated")
ws.Cells(c,7).Value = strWhenCreated
Set objUser = Nothing
End If
End Function
'*******************************************************************************************
' Calling the Functions, Writing final statements to files and
displaying the HTML file
'*******************************************************************************************
'Calling the functions in the right order
ControlSyntax()
MakeFolder()
MakeFile()
GetDCforDomain()
'---------------------------
'--- Writing to the Excel file ---
ws.Cells(c,1).Value = "Script started at " & DateTimeVal
c = c + 1
ws.Cells(c,1).Value = "Script Ended at " & Date & " " & Time
Set ws = objExcel.Worksheets(1)
ExcelPath = "c:\Temp\WriteAllUsersLastLogon_" & Date & "_" & FileTime &
".xls"
MsgBox ExcelPath
ws.SaveAs ExcelPath
objExcel.quit
'---------------------------
'---------------------------
'--- Writing to the HTML file ---
WriteFile.Write "<table border='0' cellpadding='0' cellspacing='0'>" &
vbCRLf
WriteFile.Write "<tr>" & vbCRLf
WriteFile.Write "<td class='LogText' width='390'>Number of users
queried:</td>" & vbCRLf
WriteFile.Write "<td class='LogText' width='10' align='right'>" & (c -
3) & "</td>" & vbCRLf
WriteFile.Write "</tr>" & vbCRLf
WriteFile.Write "<tr>" & vbCRLf
WriteFile.Write "<td class='LogText' width='390'>Number of DC's
queried:</td>" & vbCRLf
WriteFile.Write "<td class='LogText' width='10' align='right'>" &
UserInDomainNo & "</td>" & vbCRLf
WriteFile.Write "</tr>" & vbCRLf
WriteFile.Write "<tr>" & vbCRLf
WriteFile.Write "<td class='LogText' width='390'>Users that haven't
logged on for 30 days or more:</td>" & vbCRLf
WriteFile.Write "<td class='LogText' width='10' align='right'>" &
(Users30DaysNo - 1) & "</td>" & vbCRLf
WriteFile.Write "</tr>" & vbCRLf
WriteFile.Write "<tr>" & vbCRLf
WriteFile.Write "<td class='LogText' width='390'>Users that haven't
logged on ever:</td>" & vbCRLf
WriteFile.Write "<td class='LogText' width='10' align='right'>" &
(UsersNoLogonNo - 1) & "</td>" & vbCRLf
WriteFile.Write "</tr>" & vbCRLf
WriteFile.Write "<tr>" & vbCRLf
WriteFile.Write "<td class='LogText' width='390'>Number of disabled
accounts:</td>" & vbCRLf
WriteFile.Write "<td class='LogText' width='10' align='right'>" &
AccountDisNo & "</td>" & vbCRLf
WriteFile.Write "</tr>" & vbCRLf
WriteFile.Write "</table><br><br>" & vbCRLf
WriteFile.Write "<br><br><br><br>" & vbCRLf
WriteFile.Write "<script type=" & chr(34)& "text/vbscript" & chr(34)& "
language=" & chr(34)& "VBScript" & chr(34)& ">" & vbCRLf
WriteFile.Write "sub FireExcel()" & vbCRLf
WriteFile.Write " WShell.run " & chr(34)& "excel.exe" & " " &
ExcelPath & chr(34) & vbCRLf
WriteFile.Write "end sub" & vbCRLf
WriteFile.Write "</script>" & vbCRLf
WriteFile.Write ""
WriteFile.Write "<font class='LogText'>Click here to open the Excel
file: <a href=" & chr(34) & WriteFilePath & "_" & FileTime & ".htm" & chr(34)
& "name='FireExcel' onclick='FireExcel'>" & ExcelPath & "</a></font>" & vbCRLf
WriteFile.Write ""
WriteFile.Write "</body>" & vbCRLf & "</html>" & vbCRLf
WriteFile.Close
wshShell.Run """C:\Program Files\Internet Explorer\IEXPLORE.EXE""" &
WriteFilePath & "_" & FileTime & ".htm"
'---------------------------
MsgBox "The AllUsersLastLogon.vbs script has ended !" Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208454
developing VB Scripts
Hi there,
What development environment does one use for creating VBScripts? It looks
like VS2003 supports it but not VS2005. Does anyone have any thoughts on
this. I know one can create it with note pad, but I was hoping for something
that had intelisense.
Also, is there anywhere that there is a primer for developing VB Scripts?
Thanks! Happy coding! Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208449
How to execute remote vbscript
First things first.......
I'm trying to get a list of network mapped printers on all of the
workstations in our domain and put into a file. The following DOES work if
ran locally, but NOT if executed from a remote computer. Below lists the
local vbs script that is trying to be executed and the script from the server
that tries to execute the local script. Any ideas would be helpful.
PS: I'm not the finest code writer......just starting
Thanks,
Brian
------------------------------------------------------
Below script runs and tries to execute a script on each workstation
-------------------------------------------------------
Function findprinters(strcomputer)
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Scripts\printers_local.vbs", "\\" & strcomputer &
"\C$\Admin\", True
Set objWMIService = GetObject ("winmgmts:\\" &
"{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2:Win32_Process")
' Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
objWMIService.Create "cscript.exe c:\admin\printers_local.vbs", null, null,
intProcessID
wscript.sleep(2000)
End Function
-----------------------------------------------------
local vbs script on workstations that puts printers into a file
-----------------------------------------------------
strComputer = "."
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("\\nywpsmsm03\printer_logs\" &
"printer_log_" & datestring & ".txt", ForAppending)
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer")
For Each objPrinter in colPrinters
strstring = strstring & objprinter.name & "*"
Next
objTextFile.Write strstring & vbcrlf
--------------------------------------------------- Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208442
How to retrieve the "Connect As" property for a Virtual Folder?
Hi,
I am trying to build a script that will loop through all of the Virtual
Directories on a given server and print the "Connect As" property. Not all
Virtual Directories have this property, but anything that has "A share
located on another computer" and a UNC path will have this property available.
I can't seem to find out how to retreive the Windows Account used in the
"Connect As" property for a given Virtual Directory in IIS. I have found how
to find all the Virtual Directories (code is below).
Can anyone advise me on how to get the domain account that is being used in
the "Connect As" property?
SCRIPT TO LOOK VIRTUAL DIRECTORIES ON LOCAL IIS SERVER:
Dim IISObj, strQuery, Item
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\MicrosoftIISv2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM IIsWebVirtualDirSetting",,48)
For Each objItem in colItems
Wscript.Echo "Name: " & objItem.Name
Next Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208441
vb script to search c drive for particluar file types
Hi All
I apologise as this post is v.basic for the most of you but I was
wodnering whether anyone could spare some time to help me.
All I want is some vb script that I can use to search local hard
drives for particluar kinds of files, ie pst files.
So basically what I want is a recursive loop that finds whatever file
type I have specified and then output the size of that file to a text
file I have created.
If anyone can help I'd very grateful.
Kind Regards
Ryan Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208440
Transport Control Protocol
TCP/IP is the "language'' of the Internet. Anything that can learn to
"speak TCP/IP'' can play on the Internet. Worth Reading!!!
http://www.brsx.co.uk/NetworkSecurity/Articles/NetSec02.asp Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208439
Determining Which Version of Office is Installed on a Computer
I want to determine which version of MS Office is installed on a computer (in
domain). There are two versions (Office 2000 and 2003) here at the moment and
i want to upgrade Office 2000 clients to 2003. All of our clients run on
Windows XP Pro SP2 and our AD is 2003 (FL: 2000 Native). I found a script
from "Hey Scripting Guy!" at below, it's working well on local. But I want to
run it as startup script on domain and it must write all client results into
a text file (with AD computer name and office version together in case of two
columns). How can i do that?
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colApps = objWMIService.ExecQuery _
("Select * from Win32_Product Where Caption Like '%Microsoft Office%'")
For Each objApp in colApps
Wscript.Echo objApp.Caption, objApp.Version
Next
Thanks your support... Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208437
Change paper settings
Hi,
I need to create a script that changes the paper settings of a user
printer(s) to A4.
Can someone help me in this process
--
Urvin
--
Urvin Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208434
Save a encoded MS-Word document to a text file
Is there any sample vbscript for saving a encoded MS-Word document to a text
file Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208432
Errors 70 & 424?
The script:
On Error Resume Next
Const HKCU = &H80000001 ' HKEY_CURRENT_USER
Const ForReading = 1
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\"
& _
"ZoneMap\Domains"
strAOLKeyPath = "\aol.com"
strNapsterKeyPath = "\napster.com"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = _
objFSO.OpenTextFile("C:\Documents and Settings\MyUser\Desktop\computers.TXT")
strComputers = objTextFile.ReadAll
objTextFile.Close
arrComputers = Split(strComputers, vbCrLf)
Set objShell = CreateObject("WScript.Shell")
For Each strComputer In arrComputers
strCommand = "%comspec% /c ping -n 3 -w 1000 " & strComputer
Set objExecObject = objShell.Exec(strCommand)
strText = objExecObject.StdOut.ReadAll
If Instr(strText, "Reply") > 0 Then
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objConn = objLocator.ConnectServer(strComputer, "root\cimv2")
Set objReg = GetObject("winmgmts:\\" & strComputer & _
"\root\default:StdRegProv")
WScript.Echo("For workstation " & strComputer & ":")
objReg.DeleteKey HKCU, strKeyPath & strAOLKeyPath
If Err.Number = 0 Then
WScript.Echo(vbTab & "Deleted key: " & strAOLKeyPath & _
" if it existed.")
Else
WScript.Echo(vbTab & "Error number " & Err.Number & " occurred.")
End If
objReg.DeleteKey HKCU, strKeyPath & strNapsterKeyPath
If Err.Number = 0 Then
WScript.Echo(vbTab & "Deleted key: " & strNapsterKeyPath & _
" if it existed.")
Else
WScript.Echo(vbTab & "Error number " & Err.Number & " occurred.")
End If
Else
WScript.Echo strComputer & " could not be reached."
End If
Next
The problem:
Several of the machines return error 70, helpfully defined as "Permission
denied." Three of them return error 424, mysteriously defined as "Object
required."
I'm running the script while logged into a server as a domain admin, and
said server can ping every machine, so connectivity is not an issue. Can
anyone explain the above errors and how I might fix them? The script ran
against most of the machines just fine, removing the registry keys I wanted
removed.
Thanks in advance! Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208425
Set File/User Permission with ASP/VBScript to a File
hi
i would like to add a user and set file permission to a file with ASP.
(No component). is that possible ?
do you have a link ? an example ?
thanks david Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208422
check for file
hey all,
how do i check if a file exists and then if it does run a batch file?
thanks,
rodchar Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208420
Vista & Windows Scripting Components (WSC)
I have windows vista business edition - upgraded from winXP. This is
my dev workstation. Vista would not identify WSCs with the
scrobj.dll file so I had to do this manually. On XP one could right-
click and select "register component." I am not getting this option
with Vista.
So the question is...to I have to go command line with the regsvr32 ad
register each of the 50 components I have? Or can I do this another
way?
Thanks!
Rus Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208417
Auto Emails Without User Intervention
I have this task of sending emails using vbscript ASP Classic. I want to send
emails to users based on a certain criteria. For example, if a user has to
renew membership an automatic email would be sent to remind them. This is
done from the web application with out any intervention.
I tried using the Application Object in Global.asp, but don't have much
knowlege about using it. Can some out help with this problem?
Thanks
--
techno_zed Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208414
"time to display the list of operating systems"
Does anyone know how I can script a change in windows 2003 to change
the "time to display the list of operating systems" value from 30 sec.
to 5 sec.? This
is located under startup and recovery under system properties. I have
to change this setting on 100 servers and would rather run a script/
vbscript
than change it manually for obvious reasons. Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208412
Help with VBscript to calculate total order discount on sales cart web
Hi I am new at this, and am trying to cusomize a sales cart
application for my web.
The boxed application allows you to select either discounts per item
or whole order discounts. All of my products would fit into the whole
order discount category, but I have one that is not elligeble for a
discount at all!
The whole order discount is setup to start when order total is equal
or over $600 and the discount ammount is a fixed amount of $60. The
item that is not elligeble for a discount costs $1215. How can I
modify the code to put an exclusion criteria for that item when
calculating the whole order discount?
Here is the code on the page:
<%@ LANGUAGE="VBScript.Encode" %>
<!--#include virtual="/cgi-bin/GetOrder.asp"-->
<!--#include virtual="/cgi-bin/codepage.asp"-->
<!--#include virtual="/cgi-bin/ADOVBS.inc"-->
<!--#include virtual="/cgi-bin/IASUtil.asp"-->
<%
coupon = FGETVar("coupon","","s")
'READ STUFF From Database
Dim objSimpleAdo, rstRS, SQLStmt
SQLStmt = "SELECT * From item "
SQLStmt = SQLStmt & "WHERE [Orderid] =" & Order & "; "
Set SimpleAdo = New CSimpleAdo
SimpleAdo.setConnectionString = Session("ConnectionString")
Set RS = SimpleAdo.getRecordSet(SQLStmt)
'Do stuff with the record set
'Initialize variables for this application
thedate = Cstr(Date) 'get the date
thetime = Cstr(Time) 'get the time
subtotal = 0 'the subtotal for a row of items
subweight = 0 'the subweight for a row of items
subsize = 0 'the subsize for a row of items
subquantity = 0 'the subquantity for a row of items
subship = 0 'the subshipping for a row of items
subhand = 0 'the subhandling for a row of items
%>
<%
'Calculate the individual totals for a row
subweight = subweight + (RS("Quantity") * RS("Weight"))
subsize = subsize + (RS("Quantity") * RS("Size"))
subtotal = (RS("Quantity") * RS("Price"))
subquantity = subquantity + RS("Quantity")
subship = subship + (RS("Quantity") * RS("ExtraShip"))
subhand = subhand + (RS("Quantity") * RS("ExtraHand"))
total = MyCurrency (CCur(subtotal))
grandtotal = grandtotal + subtotal
%>
'Do item discount
If RS("Price") <> 0 Then
If RS("Price")/RS("RawPrice") <> 1 Then
itemdiscount = 100-(RS("Price")/RS("RawPrice") * 100)
strdisplay = "<font color=#BB0000> (" & Round(itemdiscount,2) & "%
off)</font>"
Response.write(strdisplay)
End If
End If
'Here is where I think the code should be modified. I tried several
ways but it does not work
<%'do whole order discount here Original
'Dim discountarray(1)
Set DiscountObj = New CDiscountObj
'If RS("Price") = 1215 Then
'discountarray = DiscountObj.wholeDiscount (subtotal + 60)
'Else
discountarray = DiscountObj.wholeDiscount (grandtotal)
'End If
'discountarray(1) = DiscountObj.wholeDiscount (grandtotal)
'discountarray(2) = "HELOOOOOOOOOOOO"
Set DiscountObj = Nothing
'Next do COUPON DISCOUNTS
If Session("ChkCoupons") > 0 then
'Dim discountarray(0)
'If RS("Price") = 1215 Then
'discountarray = 0
'Else
Set DiscountObj = New CDiscountObj
discountarray = DiscountObj.couponDiscount (discountarray,coupon)
Set DiscountObj = Nothing
'End If
End If
%>
<%
If discountarray(0) = 1 Then
If RS("Price") = 1215 Then
Response.write("<font color=#BB0000>(Total was " & MyCurrency
(CCur(discountarray(1))) & " Discounts do not apply to webinars)</
font>")
Else
Response.write("<font color=#BB0000>(Total was " & MyCurrency
(CCur(discountarray(1))) & " Discount of $60.00 Applied)</font>")
Response.write (MyCurrency (CCur(RS("Price"))))
End IF
End If
%>
Any help would be appreciated!
PS. I omited the HTML tables that display the results. Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208411
System Event Log Reading
I have a need to query the System Event Log and I'm using the following
query.
Set colLoggedEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where Logfile = 'System'")
For Each objEvent in colLoggedEvents
do stuff
Next
Is it safe for me to assume that the log will ALWAYS be read starting from
the most recent event, so when I find the first occurance the
objEvent.EventCode I'm looking for it will ALWAYS be the most recent? If
not, what steps do I have to take to ensure that?
Thanks,
Tom Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208405
Forcing a refresh of Network Printer Settings from Print Server
Hello Guys,
Is there a way via scipting to force a pc to refresh their local printer
settings from the print server ? We have enabled Duplexing as the default for
printing ( conserve that paper ! :) ) for our HP Laserjet printers on the
Print Server, but if a user goes on their local printer settings and unchecks
duplexing, it will not re-pull that device setting from the print server
unless you delete and then re-add the printer on the local machine. Is there
a way to have the printer settings pulled from the server without have to
delete and then readd the locally installed network printer ? Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208403
Help required to script a message
Hi,
Can someone help me out with the below problem?
I have a grid and each row has a checkbox as the first column. In case
if they want to edit or send a mail, they can tick the check box and
click the edit button.
In case if they have selected more than one row by ticking the check
box and click on edit, I want to display a message in the client side
saying select only one record.
Since I am using ASP.Net/VB.net I can't use a msgbox as it will be
displayed in the server only.
As I have no experience with script, can someone help me with some
code pls?
Thnx,
Vithya Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208402
Scripting Groups
Hi all, i have the following script that i have tried to piece
sections from two scripts together, my overall aim is to have the
local machine that this script is run on, added to the group specified
in objGroup....
and i deperate for help - not sure what i'm doing wrong....
many thanks in advance
Jason
--------------------------------------------------------------------------------------------------------------------------------------------
' Constants required for name translate
Const ADS_PROPERTY_APPEND = 3
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1
'Get the NETBIOS name of the domain
Set objSystemInfo = CreateObject("ADSystemInfo")
Set objGroup = GetObject ("LDAP://cn=Adobe Reader 8,ou=software
distribution,ou=distribution groups,ou=********,dc=********,dc=local")
strDomain = objSystemInfo.DomainShortName
' Get the name of the computer
set objNetwork = createobject("Wscript.Network")
strComputer = objNetwork.ComputerName
' Call function to return the distinguished name (DN) of the computer
strComputerDN = getComputerDN(strComputer,strDomain)
function getComputerDN(byval strComputer,byval strDomain)
' Function to get the distinguished name of a computer
' from the NETBIOS name of the computer (strcomputer)
' and the NETBIOS name of the domain (strDomain) using
' name translate
Set objTrans = CreateObject("NameTranslate")
' Initialize name translate using global catalog
objTrans.Init ADS_NAME_INITTYPE_GC, ""
' Input computer name (NT Format)
objTrans.Set ADS_NAME_TYPE_NT4, strDomain & "\" & strComputer & "$"
' Get Distinguished Name.
getComputerDN = objTrans.Get(ADS_NAME_TYPE_1779)
end Function
'MsgBox strComputerDN
objGroup.PutEx ADS_PROPERTY_APPEND, "member", strComputerDN
objGroup.SetInfo
------------------------------------------------------------------------------------------------------------------------------------------- Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208401
changing appeareance settings with a script
I need to make several changes in the appearance tab of the display
properties on several machines.
This is an overview of the items I need to change
- Font size: Extra Large
- advanced:
- Active Title bar: size, font and fond size
- Caption Buttons: size
- Icon: size, font and fond size
- ....
Is there anyone who knows how this best can be done using a scrip or
any other way? Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208399
Microsoft.XMLHTTP
I have used the "Microsoft.XMLHTTP" object in ASP numerous times, but I
can't get it to work in a VBS script to save my life.
Does anyone have an example of loading a web page from a VBS file?
Thanks! Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208389
active directory script to reset passwords
Hello all,
I am trying to write a script that will reset all user account
passwords under a specific OU. This part i have accomplished. I
would like the script to reset ALL user accounts though, including
child containers. My script only resets the passwords in the first OU
and will not go into the underlying containers. Any help would be
greatly appreciated. Please see my existing code below. Thanks in
advance!!!!
' VBScript to change a user's password
' ---------------------------------------------------------'
Option Explicit
Dim objOU, objUser, objRootDSE
Dim strContainer, strDNSDomain, strPassword
Dim intCounter, intAccValue, intPwdValue
Const ADS_SCOPE_SUBTREE = 2
' --------------------------------------------------------'
' Note: Change OU=nowhere, to reflect your domain
' --------------------------------------------------------'
strContainer = "OU=Remote Users, "
strPassword = "P@$$w0rd"
intAccValue = 544
intPwdValue = 0
intCounter = 0
' -------------------------------------------------------'
' Makes the user change P@$$w0rd password at first logon
' -------------------------------------------------------'
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("DefaultNamingContext")
strContainer = strContainer & strDNSDomain
set objOU =GetObject("LDAP://" & strContainer )
objOU.Filter = Array("user")
For each objUser in objOU
If objUser.class="user" then
objUser.SetPassword strPassword
objUser.SetInfo
objUser.Put "pwdLastSet", intPwdValue
objUser.SetInfo
objUser.Put "userAccountControl", intAccValue
objUser.SetInfo
intCounter = intCounter +1
End if
next
WScript.Echo strPassword & " is Password. UserAccountValue = " _
& intAccValue & vbCr & intCounter & " accounts changed"
WScript.Quit Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208387
Get the "target" property of shortcuts in a directory
Hi,
I'm new to scripting and could use some help please...
I need to get the target of all the shortcuts in users local profile
under the Recent folder (i.e. C:\Documents and Settings\<Username>
\Recent.
The goal is to see if any of their "recent files/folders" are
referencing URLs or using mapped drives.
I would like the script to:
1) get the list of shortcuts in the "Recent" folder for the logged in
user.
2) traverse the "target" property of each shortcut found.
3) log the targets to a text file.
I've written a script that can get the target property of a shortcut,
but that's as far as my scripting can take me... just starting out.
Thanks in advance! Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208386
map drive based on computer name
Hi Everybody, I have been trying to map network drives based on the
computername but hava had little success. Computers are in different
locations. The first 5 letters are similiar for the first location,
for the second location, the first 5 letters are 61new. the script is
supposed to take the first five characters of the computername and run
a mapping of home drive and some network drives. It is greatly
appreciated if someone could give some suggestions or post a working
script. I know that the script could have the entries below. I put it
in a script but it didnot work.
thanks a lot.
++++++++++++++++++++++++++++++++++
Check if the drive(s) is there, leave them and just map the ones
missing
IF left(strCompName,4) = "61syd" THEN
MAPPING drives
end if
+++++++++++++++++++++++++ Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208377
Add string to the System Variable "PATH"
Hi,
I'm looking for a script to add string at the begining of the System
Variable "PATH" Statement to deploy remotely VIA SMS. I've tried using SETX,
I didn't have much luck I can't modify the PATH I can instert any varible I
want but I can't edit the "PATH".
Thanks Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208375
Validate entry from input box
In VBScript, how does one go about ensuring the response to an input box is
greater than 0 and less than 5? This also means error trapping for blank
entry and text entries, etc.
Your example script would be most helpful, thanks... Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208373
the oShell.Run not working on remote server.
Hi,
I wrote a script which creates a batch file on the remote server and
tries to run from there itself.
This script is working in all the servers connected in network except
one. I checked the netlogon services and secondarylogon services both
of them are started. I checked the logon user id permissions its
having domain id rights.
Here is the script.
Set objFSO = CreateObject("Scripting.FileSystemObject")
strLine1 = "copy c:\ d:\" & " " & ">" & " " & Unescape("%22") & "d:
\test.txt" & Unescape("%22")
copy1 = "d:\copys.bat"
Set strFile1 = objFSO.CreateTextFile(copy1, True)
strFile1.WriteLine(strLine1)
strFile1.Close
Set oShell = CreateObject("Wscript.Shell")
nReturn = oShell.Run("cmd /c d:\copys.bat")
wscript.echo nReturn
this script runs fine on server A but in server B it doesnt even
initiates the line "CreateObject("Wscript.Shell")".
I'm not sure wat could be the reason.
any suggessions are gladly welcomed. Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208372
getting date from day/month/year dropdowns
I am trying to use three dropdowns to capture a date from the user, one
for day, one for month and one for year. Once the user has selected
from the boxes, how do I convert these values to a date variable? My
code below does work, strBriefReceived = '//'.
Dim strBriefReceived
Dim dtmBriefReceived
strBriefReceived = CStr(briefreceivedday) & "/" &
Cstr(briefreceivedmonth) & "/" & Cstr(briefreceivedyear) & " " &
"00:00:00"
dtmBriefReceived = CDate(strBriefReceived)
<%
Response.Write "<select name=briefreceivedday>"
for i=1 to 31
if len(i)=1 then
i="0" & i
end if
if (diaryDay = clng(i))then
Response.write "<option value="& i &" selected>"& i
&"</option>"
else
Response.write "<option value="& i &">"& i &"</option>"
end if
next
Response.write "</select>"
Response.Write "<select name=briefreceivedmonth>"
for i=1 to 12
if len(i)=1 then
i="0" & i
end if
if (diaryMonth = clng(i))then
Response.write "<option value="& i &" selected>"& i
&"</option>"
else
Response.write "<option value="& i &">"& i &"</option>"
end if
next
Response.write "</select>"
Response.Write "<select name=briefreceivedyear>"
for i=2007 to 2015
if (diaryYear = i)then
Response.write "<option value="& i &" selected>"& i
&"</option>"
else
Response.write "<option value="& i &">"& i &"</option>"
end if
next
Response.Write "</select>"
%>
*** Sent via Developersdex http://www.developersdex.com *** Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208369
"An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)"
Dear Googlers,
we recently installed the sourceforge forum system on our server (MS
SQL 2005) and were excited how well it worked.
However, after the most recent MS update, and using the compiler
Visual Webdeveloper Express, we are suddenly receiving the error
message:
"An attempt was made to load a program with an incorrect format.
(Exception from HRESULT: 0x8007000B)"
Can you help us?
Many thanks,
Robert "Bobby" Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208367
Run Script to change a password...
Help Pleaseeeeee!!!
Hi,
I made a script to change (or reset) the passwords of the domains users.
When I run the script using my domain admin account the script run
correctly, but when I use a user with only change password and reset password
permission the script donâ??t work, I receive a message "general deny access".
I use the delegate wizard in active directory to give access to manage users
password.
This is my script:
_____
strDomain = "domain.com"
strAccount = InputBox("User: ","Reset Password", "")
Set objUser = GetObject("WinNT://" & strDomain & "/" & strAccount & ",user")
objUser.SetPassword "newPassword"
Set objUser = Nothing
______
Thanks in advance, Walter. Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208362
Search does not recongnize french characters
Hi,
Our website has a internal search page that searches all pages in the
site and returns a list of pages containing the words used to search on.
The search is done entirely in vbscript using regular expressions.
However, on the french side of our website...it doesn't recognize any
french characters and nothing gets returned.
I know it has something to do with the charset and codepage but I'm not
exactly sure what it is. I've tried a few different things but nothing
worked.
One of the meta tags is:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
Is this right? Do I need to add anything in vbscript as well?
Thanks
Rob
*** Sent via Developersdex http://www.developersdex.com *** Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208358
Script to perform AD operation
Hi
Can any one suggest me script to perform the following Active Directory task
1. Domain Account User Logon Names
2. Domain Accounts with password aging greater than 4 months from the day
of the report (password will expire withing two months)
3. Date password expires
4. Domain Account Disply name
5. Domain Account Manager Name
6. First Name
7. Last Name
8. Company Name
I need to schedule these tasks on a weekly basis.
Please suggest at the earliest.
Thanks in advance
Regards Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208356
fetching conversation content from mesanger
Hi,
After closing my Messenger chat with my friend, a log file is generated with
the conversation history in it.
I would like that a program which I develop will use the text which was
written and send to me, but I want to do it as much as can be done on real
time.
If the logfile is generated after the conversation was closed, I guess that
there is some sort of access to the data itself (before the conversation is
closed)?
Thanks,
Hanan. Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208353
Hiding a user password in VB Scripting
This may be an FAQ but if it is then I have not been able
to find an answer. The question is: Is it possible to create
something similar to the InputBox function that hides the
user's password as he enters it? If so, how? Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208349
Run batch\exe on remote PC
Hi all,
Is there a way to run exe on remote PC? I have two PCs connetcted in
LAN.
I want 1 PC to copy a batch\exe file to a remote PC and than run it.
thanks for the help. Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208339
Problem w/ VBScript running against SQL Server 2000
I have been getting the following error when I run some VBScript code on an
ASP page that modifies values in a SQL Server 2000 database:
Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 3: Incorrect syntax near
','. /manProds.asp, line 185
POST Data:
bayID=105700112&bayName=Another+New+Test+Today&baycat=Laptops&baysubcat=Database+SW&bayPicture=Illustration+Not+Available&bayPrice=35.58&bayBriefDesc=another%0D%0A%09%09%09&bayFullDesc=Product+Descrip . . .
This same code worked fine w/ SQL7, but for some reason won't work w/
SQL2000. The code is as follows:
<%
IF addProduct <> "" THEN
sqlString = "INSERT INTO bayServ " &_
"( bay_name, bay_cat, bay_subcat, bay_picture, " &_
"bay_price, bay_briefDesc, " &_
"bay_fullDesc, bay_status ) VALUES ( " &_
" '" & fixQuotes( bayName ) & "', " &_
" '" & ( bayCat ) & "', " &_
" '" & ( baySubCat ) & "', " &_
" '" & fixQuotes( bayPicture ) & "', " &_
bayPrice & ", " &_
" '" & fixQuotes( bayBriefDesc ) & "', " &_
" '" & fixQuotes( bayFullDesc ) & "', " &_
bayStatus & " )"
bayDB.Execute sqlString
%>
...(redacted web code)
<%
END IF
IF updateProduct <> "" THEN
sqlString = "UPDATE bayServ SET " &_
"bay_name='" & fixQuotes( bayName ) & "'," &_
"bay_picture='" & fixQuotes( bayPicture ) & "'," &_
"bay_price=" & cCUR( bayPrice ) & "," &_
"bay_cat='" & fixQuotes( bayCat ) & "'," &_
"bay_subcat='" & fixQuotes( baySubCat ) & "'," &_
"bay_briefDesc='" & fixQuotes( bayBriefDesc ) & "'," &_
"bay_fullDesc='" & fixQuotes( bayFullDesc ) & "'," &_
"bay_status=" & bayStatus &_
"WHERE bay_id=" & bayID
bayDB.Execute sqlString
%>
The last bayDB.execute.sqlString is line 185. I've included the addProduct
snippet because it works just fine, but maybe the problem is passed from
there--I don't know. From what the error notes, I'm guessing the problem
might be w/ the variable bayPrice, which is defined as type 'money.' But
everything I've done to try to fix it returns the same error. The post data
string suggests it might be a problem w/ bayBriefDesc, but I can't see any
problem w/ how I have it set up in the code (and after all, it works fine in
fine in addProduct). The FixQuotes function is as follows:
FUNCTION fixQuotes( theString )
fixQuotes = REPLACE( theString, "'", "''" )
END FUNCTION
I can't figure out what exactly the problem is, and would much appreciate it
if someone could review my code and let me know what I might have done wrong
or what I could possibly do to fix it. TIA...
ba Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208327
Enabling Delegated Authentication
Hi,
I am trying to install printer to a remote machine using vbs scripts. I can
install on local machine, but not on remote machine under domain setting.
Here is my script:
cscript prndrvr.vbs -a -m "HP LaserJet 4240 PCL 6" -s hptest.domain.com -h
"C:\HP4240\english\Drivers\Win32_2000_XP_S2003\PCL6" -i
"C:\HP4240\english\Drivers\Win32_2000_XP_S2003\PCL6\hpc4x50c.inf" - username
-w pwd
I get the following error messsage:
Unable to add printer driver HP LaserJet 4240 PCL 6 Win32 error code 87
Alan from Microsoft says it has to do with "Enabling Delegated
Authentication". If I delegate using GPO, it might compromise our network
security since the delegation is also for a computer account. I've read
another article to "Enable Constrained Delegation" which may work better.
However, which services do we add to be trusted for delegation for me to
install printer on remote machine? Any suggestions or comments greatly
appreciated. Thanks! Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208322
Outlook-Script which reads E-Mail Header and put it into a new email
Dear guys,
Is it possible, to build a script for MS Outlook (2003), which reads the
E-Mail Sender, Subject and Time-Stamp from any E-Mail which comes in, and
forward it automatically as an Text-Email to another E-Mail address (this
address reads the text and send it via SMS, but this part is tested and
working)?
Best Regards
Wolfgang Bauer Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208320
Determing if something is plugged into a com port.
I am trying to access a com port through vbscript. All I need to do is
verify that something is plugged into the com port- the only thing
that will be plugged in is a handheld barcode scanner. I don't have
mscomm licensing so I would prefer to not have to go down that route.
Any help at all would be great... code examples would be stupdendous!
Thanks.
-James Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208317
combining isMember and next available drive
This is getting a bit complex for me (I think). I'm trying to incorporate a
section in my logon script that will determine which department(s) (i.e.
global groups; math, social, science, English...) a user is a member of and
will then map the S drive to that department's share. The initial drive
letter needs to be S. And if users are a member of 2 or 3 departments, they
may recieve a T and U drive too. Below is my code for the 'map the next
available drive' part. Then I try to add the isMember part and I'm getting
a bit confused (or maybe timid is a better word!) Would my best route be to
add a 'for each loop' that surronds the 'next available drive' code. And
loop would enumerate if the user was a member of each group listed in the
'for each loop' and assign a drive accordingly?
CODE
___________________________________________________
'Map S (departmental) drives
'Will also get a T drive if they're a member of 2 departments
'Will also get a U drive if they're a member of 3 departments
objNetwork.RemoveNetworkDrive "S:"
objNetwork.RemoveNetworkDrive "T:"
objNetwork.RemoveNetworkDrive "U:"
' This sections creates two objects:
' objShell and objNetwork and then counts the drives
Set objShell = CreateObject("WScript.Shell")
Set objNetwork = CreateObject("WScript.Network")
Set CheckDrive = objNetwork.EnumNetworkDrives()
' This section operates the For ... Next loop
' See how it compares the enumerated drive letters
' With strDriveLetter
On Error Resume Next
DriveExists = False
' Sets the Outer loop to check for 3 letters in strAlpha
For intCount = 1 To 3
DriveExists = False
' CheckDrive compares each Enumerated network drive
' with the proposed drive letter held by strDriveLetter
For intDrive = 0 To CheckDrive.Count - 1 Step 2
If CheckDrive.Item(intDrive) = strDriveLetter _
Then DriveExists = True
Next
intAlpha = intAlpha + 1
' Logic section if strDriveLetter does not = DriveExist
' Then go ahead and map the drive
If DriveExists = False Then objNetwork.MapNetworkDrive strDriveLetter,
strRemotePath
' Appends a colon to drive letter. 1 means number of letters
strDriveLetter = Mid(strAlpha, intAlpha,1) & ":"
' If the DriveExists, then it is necessary to
' reset the variable from true --> false for next test loop
If DriveExists = True Then DriveExists = False
Next Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208315
Constrain TABLE elements dimentions.
I'm trying to organise the content on a web page as a table in 3 rows.
1st row and 3rd row = header and footer should always be visible.
2nd row (this is where the entire web-page content will be) should have
scrollbars displayed when needed. The BODY of the HTML page should not have
any scrollbars.
The following code works in InternetExplorer 7 exactly as I wanted. But in
Firefox 2, the scrollbars are displayed in the page BODY, instead of the DIV
element. How do I constrain the size of that TABLE and the DIV inside it? I
want to force Firefox to display the scrollbars in the DIV, and not in the
BODY?
<table style="height:100%; width:100%; table-layout:fixed;">
<tr style="height:24px;">
<td style="background-color:Gray;">
header
</td>
</tr>
<tr>
<td>
<div style="overflow:auto; height:100%; width:100%;
background-color:Orange;">
content<br />content<br />content<br />content<br />
content<br />content<br />content<br />content<br />
content<br />content<br />content<br />content<br />
content<br />content<br />content<br />content<br />
content<br />content<br />content<br />content<br />
content<br />content<br />content<br />content<br />
content<br />content<br />content<br />content<br />
content<br />content<br />content<br />content<br />
content<br />content<br />content<br />content<br />
content<br />content<br />content<br />content<br />
content<br />content<br />content<br />content<br />
</div>
</td>
</tr>
<tr style="height:24px;">
<td style="background-color:Gray;">
footer
</td>
</tr>
</table>
Thank You for any links and examples!
Or if there's a better news group for that question, please let me know!
George Valkov Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208309
What MS operating systems have VBS installed?
I have a couple of VBS scripts that I'd like to share with others on
my web site. I'm putting together some instructions for their use and
realize that I don't know which MS OSs have the necessary scripting
engine in place by default.
I've only ever developed with VBScript on Windows XP Pro, so that's
the only platform I know for certain includes it.
Can anyone help me out? Thanks. Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208307
verify users in XL spreadsheet exist in AD
Hi,
I have a spreadsheet where I want to search against the AD to verify if
users exist in the AD.
I have used the "set objRecordSet = obcommand.Execute" but that only return
all of the users it could find from my search string but it does not return
the failed search users.
Can I use objcommand.properties("Cache Results") = True and list the results
that way?
Thanks,
NT Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208299
Why is this file copy/delete code failing?
Below is VBS code to copy a file from one folder to another, and then delete
it. I've stripped it out of a larger function just to isolate the problem
pieces. The folders are referenced in UNC format because the longer-term
goal is to use it across the network.
If I run it from scratch, the file copy works fine, but the file delete
fails. If I then run the script again, the file copy fails. It seems the
file copy will only succeed if the file doesn't already exist in the target
folder, so it would sound like a permissions issue. However, I have full
Change permissions on both source and destination folders, and if I attempt
the same thing from the same command line using DOS, it succeeds. Anyone
have a pointer as to what I might be doing wrong? Thanks.
If you try to run this yourself, change the sSourcePath and sResultsFN
values in the main script, and the oFolder path value in the Function to
something that will work on your computer.
Option Explicit
Dim sTargetPC, oNet, oFSO, oShell
Public sSourcePath, sResultsFN
sSourcePath = "\\127.0.0.1\d$\work\Temp\"
sResultsFN = "Results!.txt"
Set oNet = CreateObject("WScript.Network")
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")
sTargetPC = "127.0.0.1"
Call subDeleteTempFiles(sTargetPC)
Sub subDeleteTempFiles(sComputer)
Dim oFSO1, oFolder
Set oFSO1 = WScript.CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO1.GetFolder("\\" & sComputer & "\d$\Work")
On Error Resume Next
oFSO1.CopyFile sSourcePath & sResultsFN, oFolder.Path & "\"
If Err.Number <> 0 Then
MsgBox Now & vbTab & "Halt: Can't copy " & sSourcePath & sResultsFN & "
to " & oFolder.Path
WScript.Quit
Else
Err.Clear
msgbox "File should be copied now."
End If
On Error Resume Next
oFSO1.DeleteFile(oFolder.Path & "\" & sResultsFN)
If Err.Number <> 0 Then
MsgBox Now & vbTab & "Halt: Cannot delete " & oFolder.Path & "\" &
sResultsFN
WScript.Quit
Else
Err.Clear
msgbox "File should be gone now."
End If
End Sub Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208293
Need reference for Excel object functions
Hello,
I'm trying to incorporate an Excel object into my script and need a
reference for the available functions. Thus far I have not been able to find
a comprehensive reference. I have found a few samples here and there, but I
need more. In a nutshell I need to do the 4 steps below and need help with
#1 and #4. Thanks.
1. Create a new Excel workbook. << How do I do this?
2. Add data to it.
3. Sort the data in descending order by A1.
4. Save the workbook. << How do I do this?
--
Regards,
Martin X.
MCSA: M Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208290
Hide UNC in path under mapped drive?
I want to map my users directly to a folder within in a shared folder and
hide the unc path on the drive mapping under my computer.
Can anyone tell me how to do that? Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208283
wmi or vbscript help
Hi, I'm not a coder by any means, but I'm slightly wet behind the ears.
What I'm looking to do is the following:
I am responsible for imaging several desktop and laptop computers in our
school district, and one of the mundane tasks I must do after each machine
has been imaged is to remove the 2 checkmarks under startup and recovery
options in windows xp (time to display list of operating systems and time to
display list of recovery options...) It get's to be a hassle to do this
every time I image a machine, and was hoping that this could be done via a
script. Unfortunately, I've not been able to find any info on how to do
this with either wmi or vbscript. I was able to find info on setting the
timeout, but I really need to be able to disable both of these options
alltogether.
So, any ideas, sample scripts, things to look for, etc???
Thanks,
Doug Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208272
problems delete files and folders from desktop for domain user
We have a script that will delete files and folders from the desktop
on login. However, the users logging in have their profiles as
user.domain and not user so when the script runs it is deleting things
from c:\documents and settings\user\desktop instead of c:\documents
and settings\user.domain\desktop. I forget what to add. Part of the
script is below. Thanks.
strDesktop = objWSH.ExpandEnvironmentStrings("%UserProfile%\desktop\")
'*******Delete Files and Folders from desktop*******
Set Shell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
DesktopPath = Shell.SpecialFolders("Desktop")
objFSO.DeleteFile (DesktopPath & "*.*")
objFSO.DeleteFile(strDesktop & "*.*")
objFSO.DeleteFolder(strDesktop & "*.*") Tag: Display: "Can't find "VB Script" forC:\Program Files \Support.com Tag: 208270