Internet Connection Check
This has probably been asked before but anyway, Is it possible, using
VBScript, to check whether a connection to the internet is connected? Also,
what is the best way to start a connection to the internet using VBScript?
Thanks in advance!!! Tag: LDAP Script Tag: 160716
Event Logs Backup ans save
Hello. Using some of the scripts from Microsoft Technet I
am able to clear and backup the event logs on server then
copy them to a folder on a remote share. This is ok but
to run this script on other servers I would need to edit
the script each time by putting in the server name. I
would like the server event logs to backup to a folder
the same as the computer name ie: "Server A" would backup
to a folder on the remote share called "Server A". I
would like this to happen without having to put the
computer name into the script, so that if the script is
run on "server A" then it would create and backup to a
folder called "Server A" on the remote share. I really
hope this makes sense. Here is the script.
dtmThisDay = Day(Now)
dtmThisMonth = Month(Now)
dtmThisYear = Year(Now)
strBackupName = dtmThisYear & "_" & dtmThisMonth & "_" &
dtmThisDay
strComputer = "SERVER A"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Backup)}!\\" & _
strComputer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile where
LogFileName='system'")
For Each objLogfile in colLogFiles
objLogFile.BackupEventLog ("c:\Install\Event Logs\" &
strBackupName & _
"_system.evt")
objlogFile.ClearEventLog()
Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Install\Event
Logs\*.*" , "\\remoteserver\elogs$\ServerA\" ,
OverwriteExisting
Next Tag: LDAP Script Tag: 160714
CDO, MAPI VBScript just stops
Hi
I have a VBSCRIPT which scans through a Public folder called
AUTO-RESPONSE. Under AUTO-RESPONSE, there are 20 or so Sub folders
with POSTS in them. Each item as a User-Defined Folder variable called
DAYS.
I have three scripts. The first one increments the DAYS value by one
each day. There are probably 7000 items which it updates in 5
minutes.. No problems here.
The other two scripts run at each day and looks for 3 day or 6 day
items, then sends an email to the recipient, then if it is a 6 day
email, deletes the email.
Ok... both scripts are exactly the same, except the 3 or 6 day check
and the message delete. Both scripts behave the same. That is:
They start processing, looking at each subfolder and if it finds the
3/6 in the DAYS field processes the message. This works fine for a
short time, then the script just stops as though it has finished. The
script is not hanging, the wscript just disappears from the w2k
process list. It seems to have only prcessed about 20 mail items,
sometimes 50, but always less than 60. If I run the script again (say
for the 6 day which has deleted the previous emails as required) it
starts where it "left off" in the previous run, might go 10, 20 items
then again disappears/stops.
I have a debug log being written at every crucial area that could
cause an error, but an error is never generated.
Has anyone seen this behaviour? I have included the whole subroutine
for your scrutinization.. (Variables not defined in the sub are Global
Vars and have the correct valuse loaded before calling the routine.) I
hope that you can either see the issue,or offer a better way of doing
the process...
Thanks Robert
Sub DoSubFolders
Dim nLoop
Dim iLoop
'Loop through each folder, check it has a * in the first column and
process each message.
for nLoop = 1 to objFolder.Folders.count
set objSubFolder = objFolder.Folders(nLoop)
if err.number <> 0 then
' Write debug info
If blnLogFileOpen = True Then
objFile.WriteLine "Folder error (" & objSubFolder.name & ") -
Error: " & err.Description
End If
end if
err.Clear
if left(objSubFolder.name,1) = "*" then
' Write debug info
If blnLogFileOpen = True Then
objFile.WriteLine "Folder: " & objSubFolder.name & ", messages to
check: " & objSubFolder.Messages.count
End If
'Find All messages in the Folder and send response to recipient
if objSubFolder.Messages.count > 0 then
set objMessages = objSubFolder.Messages
For iloop = 1 to objMessages.count
err.Clear
numDays = 0
Set objMessage = objMessages.Item(iLoop)
set objFields = objMessage.fields
if err.number <> 0 then
' Write debug info
If blnLogFileOpen = True Then
objFile.WriteLine " Message Field Error - Error: " &
err.Description
End If
end if
err.Clear
set objField = objFields.item("Days")
numDays = cint(objField)
if err.number <> 0 then
' Write debug info
If blnLogFileOpen = True Then
objFile.WriteLine " NumDays Error - Error: " &
err.Description
End If
end if
err.clear
'If numDays = 6 then we need to send the email
if numDays = 6 then
Set objSMail = CreateObject("Redemption.SafeMailItem")
objSMail.Item = objMessage
strType = objSMail.Fields(PR_SENDER_ADDRTYPE)
Set objSenderAE = objSMail.Sender
If Not objSenderAE Is Nothing Then
If strType = "SMTP" Then
mailTO = objSenderAE.Address
ElseIf strType = "EX" Then
mailTO = objSenderAE.Fields(PR_EMAIL)
End If
mailSUB = objsMail.Subject
End If
Set objSenderAE = Nothing
Set objSMail = Nothing
if err.number <> 0 then
' Write debug info
If blnLogFileOpen = True Then
objFile.WriteLine " Message Error - Error: " &
err.Description
End If
end if
err.Clear
'OK.. Got Email Body, send email
set objMail = CreateObject("CDONTS.NewMail")
objMail.BodyFormat=1
objMail.MailFormat=0
objMail.To = mailTO
objMail.From = mailFROM
objMail.Subject = mailSUB
objMail.Body = MailBody
objMail.Send
set objmail = nothing
if err.number <> 0 then
' Write debug info
If blnLogFileOpen = True Then
objFile.WriteLine " Send Message Error - Error: " &
err.Description
End If
else
' Write debug info
If blnLogFileOpen = True Then
objFile.WriteLine " Email sent to: " & mailTo & ", Subject:
" & mailSUB
End If
end if
'Delete Mail Message
objMessage.delete
if err.number = 0 then
If blnLogFileOpen = True Then
objFile.WriteLine " 6 Day Email deleted"
End If
else
If blnLogFileOpen = True Then
objFile.WriteLine " Could not delete email. Err: " &
err.Description
End If
end if
err.Clear
Set objMessage = nothing
set objFields = nothing
set objField = nothing
err.Clear
end if
Next
end if
end if
next
End Sub Tag: LDAP Script Tag: 160713
"generic" code to retrieve any type of WMI info - possible in VBScript?
Hello all--
After a few hours of playing around ... and many, many hours of
searching ... I am not able to find an answer to my problem -- so I'm
hoping that the bright minds here might be able to help.
I'm working on a project to monitor various components of our
enterprise network via WMI. Being that VBScript/ASP are my primary
programming skills these days, I was planning on writing an interface
in ASP that would write items to an Access or SQL database, and then a
VBScript process which could query the database and submit WMI lookups
against hosts and log the data returned.
I know how to do all of the pieces required except one -- making a WMI
query mechanism that is "generic" enough to handle any type of data I
might want to retrieve (or at least typical sets such as numeric,
string, boolean, etc.) The problem that I have, is that the values
must be called specifically depending on what the data is. So, for
instance, if I want to get the temperature out of the system I have to
specifically call the ".CurrentTemperature" property within the code.
For example....
strComputer = "localhost"
set wbemServices = GetObject("winmgmts:\\" & strComputer &
"\root\wmi")
set wbemObjectSet =
wbemServices.InstancesOf("MSAcpi_ThermalZoneTemperature")
For Each wbemObject In wbemObjectSet
WScript.Echo "InstanceName : " & wbemObject.InstanceName
WScript.Echo "Current Temperature: " &
wbemObject.CurrentTemperature
Next
This works great - but it's just not generic for the several hundred
types of queries I can imagine running. I can't define a variable of
"CurrentTemperature" and call it at the end of the wbemObject. - it
just doesn't work that way (nor did I expect it would). Therefore, I
need something generic. I want to be able to create an Access
database record which would simply define the object set
(MSAcpi_ThermalZoneTemperature) and the property within that set
(CurrentTemperature) to check, and then handle that with generic
variables which can then post the data to Access, analyze it for
violating a threshold, etc.
(Apologies if I don't have the lingo quite right - I haven't actually
"officially" been a programmer for over a decade)
Hopefully I've gotten my point across and you might understand where
I'm headed with this. I'd moat likely make the framework an
open-source project as a simple and easy-to use network monitoring
system.
Thanks in advance!
-Douglas Toombs Tag: LDAP Script Tag: 160705
writing to an .ics file
How can I write to an .ics file in this format. It is pulling
information from a database
FirstName:John
LastName:Doe
City:Philadelphia
State:PA
ZipCode:19104
FirstName:Jane
LastName:Dorris
City:Lakewood
State:NJ
ZipCode:08701 Tag: LDAP Script Tag: 160703
A few questions for you VBScript Gurus!!!
Hello All,
I am new to VBScript and was hoping for some pointers. Basically, I created
a DOS batch file at work that allows us to install several software packages
in order after we tell it which drive to launch the packages from. The DOS
batch file works like a dream, however, I would like to use VBScript to take
this to the next level. I have figured out how to do certain things like
display system specs and stuff like that, but some of the basic concepts are
giving me problems. Here are the questions I have:
1. After setting up an Input Box that has the buttons OK and Cancel, how
can I program the script to exit the program if the button Cancel is
pressed? As it stands right now, regardless if the OK or Cancel button is
pressed, the script will carry on to the next line of code.
2. In the DOS batch file, I was easily able to set up labels and tell DOS
if a certain condition was met, goto label, If condition wasn't met goto
this label. Basically, I was easily able to direct my script to jump to
different parts of my code just by using the goto xxxx. Can I do this in
VBScript? Right now, it seems like the Select Case and Do Loops just
doesn't fit my needs but that is probably because I don't know how to use
them properly for what I am trying to do.
3. I am currently using NotePad to develop my scripts and it is ok for the
most part. However, if I run the program and receive an error in line 77, I
have to count all the way down just to find out the line. Please tell me
there is a better way! Right now I have decided to break my code down into
sections and run one part at a time in seperate scripts just to see if it
works.
4. Is there a way that I can display colored text in a message box? The
goal is to have the system specs displayed and if any part of the system
specs doesn't meet my software requirements, then I want it to display
additional text (that is red) pointing this out.
Any help or advise would be appreciated. Thanks in advance! Tag: LDAP Script Tag: 160699
HELP: Mapping Network Drives and Trapping Errors to Return Success
Hello,
I wonder if anyone can help me. I want to be able to use VBScript as
part of a logon script to map a network drive and to return a error on
the basis of weather the mapping was successful or not.
Does anyone know how to do this?
I'm using the MapNetworkDrive function of the WScript.Network object to
do the mapping.
I've enabled "On Error Return Next" and getting the value in Err.Number
however I do not know what codes are returned on success or failure.
Any ideas?
If i can't map drives
Hardeep. Tag: LDAP Script Tag: 160696
Cannot use win word in IE
Dear all,
I try to write a vbscript to open the word2000 in IE from some clients'
computers; however, IE always report the error "The client has refused this
request" from the line "set abc = createobject("Word.Application")" . I
have checked the Task Manager and I found that the word has been called in
the task manager. Can anyone help me to solve this problem? Thank you for
all of your help. Thank you.
Alex Tag: LDAP Script Tag: 160693
Variable redefine
Hi everybody,
In an ASP page, I need to load twice an include file that contains
variables. So I get an error message "variable redefine" I tried to test
with VarType before to define the variable (dim) with no success. Is it
faisable with VBScript to define a variable (dim) under condition.
' this code gives an error
if VarType("MyVar") = vbNull then
dim MyVar
end if
many thank's
serge Tag: LDAP Script Tag: 160692
Accessing WSH objects from within IE
The code works fine in the W2K pro environment but why won't it work within
a web page. I keep getting a cannot create object error. Is there a
workaround so you can access Active Directory from within IE6?
Thanks,
Jim
Option Explicit
Dim oNetwork, UserName
Set oNetwork = CreateObject("WScript.Network")
username = oNetwork.username
MsgBox username Tag: LDAP Script Tag: 160690
VBS Logoff disconnected user
This must have been asked before, but I can't find it in groups, the
web, or msdn. Is there a way to log off a disconnected user (XP via
fast user switching) through .vbs? I can logout the currently logged
in and active user, but I want to log out everyone who isn't running a
console session. Any idea?
Josh Tag: LDAP Script Tag: 160689
Frame="All" Not Working
I have taken over a Web Site. The Default Page is in two frames. When I go to display the page below, it will not display as a full page (or frame). Been at this four days and for the life of me I do not know what is wrong. This works with two other pages, but not this one!
<Html>
<Head>
<Title> Information for Parents </Title>
</Head>
<Form Name="Default" Method="GET" Action="../Default.htm">
<Body bgcolor="#FFFFFF">
<Font Face="Courier New" size="3"><Strong>
<Center>
<Table Border="3" Frame="All" CellPadding="1" CellSpacing="2">
<Caption Align="Top"><B>Parents</B></Caption>
<tr>
<td>Parents
want the best education for their children. We understand that each school community has
its unique needs. Our goal is to provide your family with a positive learning environment,
the finest educational programs, and services that promote outstanding student
achievement.
Parents are children's first and life-long teachers. We value the partnership between home
and school and recognize that parental involvement is the key to success in school. You can
be involved by helping your child with homework, volunteering in our schools, or joining a
school council. By welcoming and providing opportunities for you to be involved, we can
work together to ensure that children receive the very best education.<BR></font></td></Tr>
<BR>
</Table>
<A Href="../Hatch.htm">RETURN</A>
</Form>
</Body>
</Html>
Any help would be greatly appreciated.
Thank You in Advance
Len Tag: LDAP Script Tag: 160687
Will Not Display Page as Full Frame
The Web Site I am taking over is split into two frames.
The code below will not display as a full Page (Frame). This works on two other pages fine, but will not work on this one. Guess I need help, I have been at it for four days!
<Html>
<Head>
<Title> Information for Parents </Title>
</Head>
<Form Name="Default" Method="GET" Action="../Default.htm">
<Body bgcolor="#FFFFFF">
<Font Face="Courier New" size="3"><Strong>
<Center>
<Table Border="3" Frame="All" CellPadding="1" CellSpacing="2">
<Caption Align="Top"><B>Parents</B></Caption>
<tr>
<td>Parents
want the best education for their children. We understand that each school community has
its unique needs. Our goal is to provide your family with a positive learning environment,
the finest educational programs, and services that promote outstanding student
achievement.
Parents are children's first and life-long teachers. We value the partnership between home
and school and recognize that parental involvement is the key to success in school. You can
be involved by helping your child with homework, volunteering in our schools, or joining a
school council. By welcoming and providing opportunities for you to be involved, we can
work together to ensure that children receive the very best education.<BR></font></td></Tr>
<BR>
</Table>
<A Href="../Hatch.htm">RETURN</A>
</Form>
</Body>
</Html>
If someone can tell me why this does not display as a full page I would really appreciate it.
Thank You in advance
Len Tag: LDAP Script Tag: 160686
What shoudl I use, VB or batch or other
I have seen some instances of what I am trying to do, but still can't find exactly what I need, and I am new to vbs.
I would like to create user shares, and point users to these shares, say via GP or login script. I have 2 files, one for the share, and one for the actual location. When I run the batch it gives me an error, so I figured I would try vbs. The file is just a text file, and i have tried to pump it into the batch with variables, but to no avail. ANY help, push, prod in a direction, would be great. Tag: LDAP Script Tag: 160679
Access Denied while installing Printers in Windows Server 2003
Hi,
I have been banging my head against the wall all day trying to figure this out. We are migrating our Print Server from Windows 2000 Server to Windows Server 2003. I found some cool scripts that run on Windows XP and Windows Server 2003 that I thought would make my life easier. Silly me!
I developed my script on XP and everything seems to work. I create over 300 printers in a few minutes. I went over to my 2003 Server and it won't run.
I get an Access Denied message. The Error Code is 80041003. The Source is SWbemObjectEx.
First off, I am using the local Administrator account on the server.
Second, I thought it was some sort of policy setting that our Domain was applying. So I rebuilt the server and did not join it to a domain. It has all default security settings applied.
This code is a sample to create an IP Printer Port. I got it from microsofts site. It does not work on Server 2003.
Set objWMIService = GetObject("winmgmts:")
Set objNewPort = objWMIService.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_
objNewPort.Name = "IP_169.254.110.14"
objNewPort.Protocol = 1
objNewPort.HostAddress = "169.254.110.14"
objNewPort.PortNumber = "9999"
objNewPort.SNMPEnabled = False
objNewPort.Put_
The line the program aborts on is the last line. objNewPort.Put_
According to Microsofts website this should work on Server 2003. But I can't figure it out.
I am hoping I am just missing something simple.
Any help would be greatly appreciated. Tag: LDAP Script Tag: 160669
read each line of variable (like readline method)?
I have a variable that has multiple lines of text - I want to go through
each one, line by line and perform an action with the information.
I know how to get line information from a text file using the readline
method, but am unsure of a way to easily do this with a variable. Any
ideas?
Thanks in advance, everyone!
Rob Tag: LDAP Script Tag: 160668
Have user run a script with admin credentials
Hi Guys,
I have a remote site that we need to change some Network settings for. I
do not want to have to send someone out there. I can copy the script to
the remote computer, but my script will need to run with admin
privileges. I do not wish to give the end (l)users the local admin password.
· I know I can specify a username and password for the Task Scheduler,
GUI only, the AT command does not seem to support this
· I found a news group article where Torgeir Bakken says, WMI
does not support connecting to the same computer you are running
the script from with another user credentials.
I?d simply do this remotely but I am setting a static IP on these PCs
among other network settings
Can someone throw me a link or something?
Thanks Tag: LDAP Script Tag: 160665
Delete Reg Key
Hey everyone,
I want to know the cleanest way to look for a regestry key and if it i
there delete it. The key in question is QuickTime Task key in th
HKLM\software\microsoft\windows\currentversion\run. I want to firs
check if the key exists and if it does remove the key. This will b
placed in a login script for all users logging into the domain.
Thanks in advance
-
Kewl
-----------------------------------------------------------------------
Posted via http://www.codecomments.co
----------------------------------------------------------------------- Tag: LDAP Script Tag: 160664
Request.ServerVariables("HTTP_REFERER")
Hi All,
I'm trying to get the Referer URL by using
Request.ServerVariables("HTTP_REFERER") but all I got back is the Server or
Host Name not the whole Referer URL. Is there any way to get the entire
Refering URL that including path, querystrings....?
Thanks
Henry Tag: LDAP Script Tag: 160655
Message Box (default button selection)
I am using VBScript to display a message box to verification operators under certain condistions. Most of the boxes are simple vbYesNo. The question I have is that the button that is highlighted (has focus) is not the button I want to be highlighted. Being a rookie is there a way to change the button default from Yes to No?
Thanks,
Ben
**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources... Tag: LDAP Script Tag: 160647
VB Automation Error
Hello
I am unable to access my VB COM+ component due to the following error:
CODSearchBusServices error '80070002'
Automation error The system cannot find the file specified.
I know that the DLL works and is accessible from another server.
However, on thecurrent server, it won't work. I have tried all the
forums and help sites available but no joy.
Please can you help?
Thanks
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! Tag: LDAP Script Tag: 160628
Run method, 16-bit application, sound
I have written a wrapper in VBScript that maps a drive, runs a 16-bit application from that drive using the Run method, and then unmaps the drive.
My problem is that when the script runs the application, there is no sound. The commentary is a vital part of the application, and is audible when the application is run "straight". So why can't I hear anything when I run it from VBScript?
Andrew Good
Barefoot Boy Tag: LDAP Script Tag: 160627
Problem when retrieving data from Web Page
Dear All,
I try to use sample code found on script center to retrieve the value
property of text object. And this works when i try to retrieve data from a
htm file on my disk. But, after i put this htm file onto my web server, i
can't retrieve any data, even on my local web site. Any ideas? Any
suggestion or feedback will be greatly appreciated. Thanks for your time.
best regards,
Eric Wu
Content of Script:
Set objExplorer = WScript.CreateObject _
("InternetExplorer.Application", "IE_")
'objExplorer.Navigate "file:///c:\scripts\password.htm" 'This works fine
objExplorer.Navigate "http://localhost/password.htm" 'This not works
objExplorer.Visible = 1
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width=400
objExplorer.Height = 250
objExplorer.Left = 0
objExplorer.Top = 0
intItems=objExplorer.Document.body.all.Length -1
Set colItems=objExplorer.Document.body.All
For i = 0 to intItems
strInfo=strInfo & "Name is: " & colItems.item(i).Name & Chr(13) &_
"Id is: " & colItems.item(i).Id & Chr(13) &_
"Value is: " & colItems.item(i).Value & vbtab & Chr(13)
Next
Wscript.Echo strInfo
Content of Passwor.htm is:
<html>
<body>
<input type=text id="OKClicked" name="OKClicked" value="12345">
<input type=text id="PasswordBox" name="PasswordBox" value="1234">
<input type=button id="butOK" name="butOK" value="OK"
onClick="document.all.OKClicked.value=this.value">
</body>
</html> Tag: LDAP Script Tag: 160626
Read Public Folder items from script
Hi,
I need to get metadata from mail items stored in a public folder into an
Excel spreadsheet. I'm running Exchange 2003 with Outlook 2003 on the front
end. I have managed to pull the information required from my Inbox, but
cannot find any way to access the Public Folder store.
Any help appreciated. Tag: LDAP Script Tag: 160624
Scope Issue - Call global function from inside class function
ex)
Public Function Join(delim)
Dim str
Dim istop
istop = stopIndex
ReDim Preserve aData(istop)
str = Join(aData,delim) ' this should be the built in VBScript join
Join = str
End Function
Basically I'm looking for the :: C++ operator equivalent. I ended up
renaming the function to get around it, but I'd like to know if it's
possible for the future.
Alec Tag: LDAP Script Tag: 160623
Script fails on a W2K Advanced server cluster
When I run a WMI script against my W2K Print server it works fine. I am
using WMI to return all the printers defined on the server using
Win32_printer. When I run it agains my cluster it fails. I am not getting
any kind of error the script just doesn't return any data. Any ideas? Tag: LDAP Script Tag: 160615
red screen of death
Does anyone know how to script this red screen of death when a user does
not have the right security patch or anti-virus software on their systems. I
want to enable this at a login script, but cannot find any information on
how to implement this.
thanks in advance. Tag: LDAP Script Tag: 160614
Delete unwanted subfolders
Shadrach wrote:
> *Here is what I have figured out so far..
>
> Set oFS = CreateObject("Scripting.FileSystemObject")
> Set oFolder = oFS.GetFolder("C:\Somefolder\Programs\")
> For Each oFolder In oFolder.SubFolders
> WScript.Echo oFolder.name
> If oFolder.name <> "FolderA" Then
> End If
> If oFolder.name <> "FolderB" Then
> End If
> If oFolder.name <> "FolderC" Then '
>
> Else filesys.DeleteFolder "c:\Somefolder\Programs\"
> oFolder.name
> End If
>
> Next *
Still looking for a solution to this.. c'mon coders
-
Shadrac
-----------------------------------------------------------------------
Posted via http://www.codecomments.co
----------------------------------------------------------------------- Tag: LDAP Script Tag: 160613
retrieving SQL-server data
Hi,
I have several .vbs script to inspect my database with queries like
select count(*) as 'count' from tb_data where err_count > 0
select id, folder from tb_data where date > '2004-07-01'
I always use an ADODB.Connect en .Recordset to get the information. But
now I want to query
select e.id, e.folder, d.folder from tb_error e, tb_data d
where e.id = d.id
Works in ISQL, but I could not find any information in the SQL-server
books-online except for ASP programming. I don't have a webserver.
Any hints on how to use ADODB.Connect (or maybe ADODB.Command)??
Tnx
Rob Tag: LDAP Script Tag: 160612
computers showing up in "User List"
I cobbled together a script that writes to an Excel spreadsheet with the
users name,
logon ID, OU, and logon script, naming each page with the main OU name. I
know
that it is ugly, but it works. The main problem I am having is that it also
puts the
computer and group names on the sheets, and I only want users. Obviously I
need to
filter it better, but I am having trouble finding the proper information.
Anyone able to
help? Thanks much in advance! And, thanks to Richard Mueller for the base
script!
Randy Reimers
' CreateUserList3.vbs
' VBScript program to create a Microsoft Excel spreadsheet documenting
' all users in the domain.
'
' ----------------------------------------------------------------------
' Copyright (c) 2002 Richard L. Mueller
' Version 1.0 - November 12, 2002
' Version 1.1 - February 19, 2003 - Standardize Hungarian notation.
' This program enumerates all users in the domain and writes each user's
' LDAP DistinguishedName to a Microsoft Excel spreadsheet.
'
' You have a royalty-free right to use, modify, reproduce, and
' distribute this script file in any way you find useful, provided that
' you agree that the copyright owner above has no warranty, obligations,
' or liability for such use.
Option Explicit
Dim strExcelPath, oDomain, oContainer, strName, strScriptPath, strSam, usr,
usrDN
Dim objRecordSet, strDN, objExcel, objSheet, oObj, sClass, subPath,
NTDomain
Dim intIndex, k, sheet, strSheet, objWorkBook, i
k = 2
sheet = 1
' Spreadsheet file to be created.
strExcelPath = "F:\UserList.xls"
' Bind to Excel object.
Set objExcel = CreateObject("Excel.Application")
Set objWorkBook = objExcel.Workbooks.Add 'new
If objWorkBook.Sheets.Count < 25 then
For i = objWorkBook.Sheets.Count to 25
objWorkBook.Sheets.Add()
Next
End if
Set oDomain = GetObject("LDAP://ou=cc,dc=corp,dc=tcc,dc=inet")
EnumOU(oDomain)
' Save the spreadsheet.
objExcel.ActiveWorkbook.SaveAs strExcelPath
objExcel.ActiveWorkbook.Close
' Quit Excel.
objExcel.Application.Quit
' Clean up.
Set objRecordSet = Nothing
Set objSheet = Nothing
Set objExcel = Nothing
MsgBox "Done"
Wscript.Quit
Function EnumOU(oContainer)
For Each oObj In oContainer
For Each sClass in oObj.ObjectClass
If LCase(sClass) = "organizationalunit" Then
subPath=oObj.AdsPath
Call newSheet(subPath, sheet)
getUser(subPath)
EnumOUT(oObj)
sheet = sheet + 1
If k = 2 Then
sheet = sheet - 1
End If
k = 2
End If
Next
Next
End Function
Function EnumOUT(oContainer)
For Each oObj In oContainer
For Each sClass in oObj.ObjectClass
If LCase(sClass) = "organizationalunit" Then
subPath=oObj.AdsPath
getUser(subPath)
EnumOUT(oObj)
End If
Next
Next
End Function
' Enumerate all users. Write each user's information to the
' spreadsheet.
Function getUser(subPath)
Set NTDomain = GetObject(subPath)
NTDomain.Filter = Array("user")
For Each usr In NTDomain
strName=""
strScriptPath=""
strSam=""
usrDN = ""
On Error Resume Next
usrDN = usr.distinguishedName
intIndex = InStr(usrDN, "OU=")
usrDN = Mid(usrDN, intIndex)
' wscript.echo usr.name
strName = Mid(usr.name,4)
strName = Replace(strName, "\,", ",")
' wscript.echo usr.sAMAccountName
strsam = usr.sAMAccountName
' WScript.Echo usr.LoginScript
strscriptpath = usr.LoginScript
objSheet.Cells(k, 1).Value = strName
objSheet.Cells(k, 2).Value = strSAM
objSheet.Cells(k, 3).Value = strScriptPath
objSheet.Cells(k, 4).Value = usrDN
k = k + 1
Next
End Function
'Create, set up new page in spreadsheet
Function newSheet(subPath, sheet)
strSheet = Mid(subPath,11)
intIndex = InStr(strSheet, "OU=")
strSheet = Left(strSheet, intIndex - 2)
' Bind to worksheet.
wscript.Echo sheet & " " & strSheet
wscript.Echo sheet
Set objSheet = objExcel.ActiveWorkbook.Worksheets(sheet)
objSheet.Name = strSheet
objSheet.Cells(1, 1).Value = "User Distinguished Name"
objSheet.Cells(1, 2).Value = "Logon ID"
objSheet.Cells(1, 3).Value = "Logon Script"
objSheet.Cells(1, 4).Value = "User's OU"
' Format the spreadsheet.
objSheet.Range("A1:D1").Font.Bold = True
objSheet.Select
objSheet.Range("A2").Select
objExcel.ActiveWindow.FreezePanes = True
objExcel.Columns(1).ColumnWidth = 45
objExcel.Columns(2).ColumnWidth = 26
objExcel.Columns(3).ColumnWidth = 15
objExcel.Columns(4).ColumnWidth = 65
End Function Tag: LDAP Script Tag: 160610
Scripting solution needed for DHCP and trusted PDC/DHCP servers.
I have to obtain scope information from a large number of remote DHCP
servers that are also NT4 PDC servers. WMI is installed on each server but I
can't locate a method to get the scope information. I would really
appreciate someone's help to get this information.
Thanks in advance,
Scott Cooper Tag: LDAP Script Tag: 160607
Delete an application pool
Hi,
I want to delete the application pool I created using vbscript. How can i find it and how to delete it? Thanks.
Yang
**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources... Tag: LDAP Script Tag: 160606
Netscape LDAP directory
I would like to search a Netscape LDAP directory for information. I have a
SMTP address I would like to see if it exists in the LDAP directory. If it
does exists, then retrieve some information(name, address, userid,etc). I
don't know how to connect to the LDAP server. I know the server name and
even the base to start the search from. Can someone provide me with the
code to connect to the server/base?
TIA
Dave Tag: LDAP Script Tag: 160603
Query OU membership
Hi everybody,
I'm a newbie in scripting and i would like to know if i can query the
OU of a user to map the appropriated drives in his login script.
Eric Tag: LDAP Script Tag: 160601
Presence of Server 2003 DC?
How might one determine if a Windows 2003 domain controller has been
installed on a Windows 2000 network?
--
jbfields@msn.com www.jbfields3.com
"Dogs may have kept us company on the hunt, but it was the cats who insisted
we invent houses and discover fire." -- Khiem Tran
(Follow-up set to: microsoft.public.scripting.wsh,
microsoft.public.windows.server.networking,
microsoft.public.windows.server.scripting,
microsoft.public.windows.server.security ) Tag: LDAP Script Tag: 160598
Help with Registry Modification
I am trying to use the following script to adjust the mouse sensativity - we
want to include this on the desktop of all the laptops in the org so while
attached to the dockingstation w/ a external mouse the mouse sensativity is
20 - and when on the road a simple click will turn it down to 1, making the
mouse pointer easier to control..
Using regmon the only key that needs to be changed is MouseSensitivity; and
doing it via the cpl applet changes the key and immediatly adjusts the
sensativity.
I wrote the following script and it does change the key but a reboot is
required to commit the change - can someone point me in the direction that
will make the setting take effect when set in the script?
Set WSHShell = WScript.CreateObject("WScript.Shell")
RegKey = "HKEY_CURRENT_USER\Control Panel\Mouse\MouseSensitivity"
WSHShell.RegWrite RegKey,"1","REG_SZ"
WScript.Quit
Thanks
David Tag: LDAP Script Tag: 160596
Monitoring Script
Hi all,
I need to create a script to monitor the performance / state of a win 2003
server. The script must create a file with information about the CPU
(temperature, ..), HD (partitions, free space, ..) Memory (free memory,
...), Users connected, Opened files, Swap file use, precesses (and resources
used by each one) .... all useful information I can get from the system.
¿Do you know how can I make that ? ¿A link to a web page about that issue?
Thanks for your help. Tag: LDAP Script Tag: 160592
Problem in retrieving data from SQL server 2000
I use a SQL server 2000 to store data in local language (gb and Shift-JIS). I can successfully store the data into database, but when i retrieve back from database, i only get "?" in my asp program.
Is there any solution? Thx for help. Tag: LDAP Script Tag: 160590
ExecWB - Stop Print Prompt
FUNCTION VBprintItemMy(toFrame)
toFrame.focus
WebBrowser="<OBJECT ID='WebBrowser1' WIDTH=0 HEIGHT=0
CLASSID='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'>"
document.body.insertAdjacentHTML "beforeEnd",WebBrowser
document.body.insertAdjacentHTML "beforeEnd",WebBrowser
WebBrowser1.Silent = TRUE
WebBrowser1.ExecWB 6,2
WebBrowser1.outerHTML=""
END FUNCTION
Im Using the above function to Print a specified Div of frame....
Even i specified the parameter as 2 for WebBrowser1.ExecWB, still it
prompts
the print window to me to print...
Y is this and how can i avoid...?? Tag: LDAP Script Tag: 160584
string comparison to string array
How do I check if a given string is contained within either a string
array or a delimited list of strings?
eg:
strLevel = "red"
' i want to see if strLevel is one of the following, using either an array:
arrLevels = Array("red","yellow","blue")
' or a delimited list:
strLevels = "red,yellow,blue"
I just want to return a simple true/false or 1/0.
Cheers
Ben Tag: LDAP Script Tag: 160580
how to include other vbs file in one vbs file?
hi
I'm executing one vbs file (abc.vbs) and wanna inlucde
another vbs file (xyz.vbs) in abc.vbs file...
How can i do this?
thanx
dave Tag: LDAP Script Tag: 160579
OutlookExpress
How can I read the messages received via O.E. as well as its attachment via
code, i.e. from a script?
Thanks
Sandrobi Tag: LDAP Script Tag: 160577
Using Array as Argument in Custom Function
This should be straightforward, but ...
What is the correct way to pass an array as a function argument in
VBScript?
For example, I have a call in an ASP:
<!-- #include file = ../../../functions/dbps.inc -->
Dim strPjCode
Dim intVal
Dim arrValue(50)
intVal = ProjectSort(strPjCode, arrValue())
The custom function is:
Function ProjectSort(strPjS, arrV())
ProjectSort = 0
etc.
The ASP generates the following error:
Microsoft VBScript runtime error '800a0009'
Subscript out of range
If I remove the () after the array in the ASP and Function I get a
different error:
Microsoft VBScript runtime error '800a01f4'
Variable is undefined: 'ProjectSort'
Any suggestions? Thanks.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! Tag: LDAP Script Tag: 160574
Trying to backup Security Event Logs
I have this script that is running on a couple of servers on a daily basis.
It's supposed to check and see if the security event log is greater than
20MB and if so, back it up and clear the log if the backup was successful.
Otherwise do nothing.
It works fine on one of the computers, however on the other it only "kind
of" works. On the computer I'm having trouble with I will see a .evt file
that was backed up (and is over 20 megs), then after that there are several
more .evt files that are created on a daily basis which are 1KB in size. If
I open these in event viewer nothing shows up (although it will say there
are a couple hundred thousand events). Then after a few days of creating
these 1KB files there will be a successfully backed up .evt file which is
about 50 megs by this time.
I suspect the problem has something to do with the log not being "locked"
properly or what ever needs to be done. The server that is having this
problem can get dozens of events per second at times (mostly b/c it's the
domain controller and it's logging all the login/logout stuff).
At anyrate, here is the portion of my script that does the work. Any ideas
on how to make it backup correctly every time? Oh, and a small side note.
I have an If to test the size to see if it's big enough. I tried making a
constant variable for the comparison but that never worked, for some reason
I had to type the literal value into the if expression. I'd also appreciate
any insight on why that is.
-mike
--------------------
Set objWMIService =
GetObject("winmgmts:{impersonationLevel=impersonate,(Backup,Security)}!\\" &
Computer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
("SELECT * FROM Win32_NTEventLogFile WHERE LogFileName='Security'")
For Each objLogfile in colLogFiles
If (objLogFile.FileSize > 20000000) Then
errBackupLog = objLogFile.BackupEventLog(SavePath & Computer & "\" &
Computer & "Security" & Today(1) & Today(0) & Today(2) & ".evt")
If errBackupLog <> 0 Then
if (DEBUG) then
Wscript.Echo "The Security event log could not be backed up."
end if
Else
if (DEBUG) then
wscript.echo "Clearing Log"
end if
objLogFile.ClearEventLog()
End If
else
if (DEBUG) then
wscript.echo "Filesize not big enough: " & objLogFile.FileSize
end if
End If ' if filesize
Next ' for each objLogfile Tag: LDAP Script Tag: 160573
Enumerate Directory listings
I would like to run a script or batch file that will:\
for each directory go down two directory levels and print the full path
(\\servername\dir1\dir2\dir3) where dir3 matches a specific pattern....
This is how my file servers store user directories and I will need to
populate the HOME FOLDER field in AD.
Thansk
Carl Tag: LDAP Script Tag: 160557
Windows 2003 and WMI question
Hello All,
I have a script that utilize wmi to get the local Administrators group name
in different OS languages (Administrators group names differently in
different language).
The script works fine with Windows 2000/XP. However, the WMI call failed
without a trace when running on Windows 2003 box (english, german, sweden,
neitherland so far...).
Does Windows 2003 make WMI calls different than 2K/XP? Any help would be
greatly appreciated.
Here is a portion of my script which do the above mentioned.
sComputer = "."
sGroupSID = "S-1-5-32-544" ' Well Known SID of the local Administrators
group
' --- THIS IS WHERE IT FAILED ON WINDOWS 2003 ---
Set objWMIService = GetObject("winmgmts:\\" & sComputer & "\root\cimv2")
If Err.Number <> 0 Then
msgbox Err.Number
msgbox Err.Description
End If
Set colItems = objWMIService.ExecQuery ("Select * from Win32_Group WHERE
SID = '" & sGroupSID & "'")
If Err.Number <> 0 Then
msgbox Err.Number
msgbox Err.Description
End If
For Each objItem in colItems
sAdminGrp = objItem.Name ' Get local Administrators group name
Wscript.Echo "Name of the local Administrators group: " & sAdminGrp
Next Tag: LDAP Script Tag: 160556
Script to set Archive location in Outlook 2003
Does anyone know a way to set the default Archive location in Outlook
2003? Group policy allows you set the limits but not the location. We
want to change this from the local profile to a network location.
Right now the only way to do it is to manually configure each machine.
thanks
roger Tag: LDAP Script Tag: 160555
Does anyone know of/have a script that can be used in a web page for users
to change their own GAL details using LDAP?