Configuring Error Handling with in this Script
Below is a copy of my script that I'm using to set a random password to the
local administrator.
I would like to improve but would like some help doing it.
I would like to put some error handling in so that I can control an error
and take approrate action if it fails, because at the moment if it fails say
user not found the program just stops.
Also I didn't know if there was a way to query the name of the default local
administrator.
Be honest if needs completly rewriting then say so.
TIA
Gary
Option Explicit
Dim Title, NumChar, Count, strRdm, intRdm, wshShell, oWshNet, sUserName,
sComputerName, oUser
NumChar = 127
Randomize Timer
Do Until Count = NumChar
Count = Count + 1
GetRdm
strRdm = strRdm & Chr(intRdm)
Loop
Sub GetRdm
intRdm = Int((122 - 49) * Rnd + 48)
If intRdm > 57 And intRdm < 65 Or intRdm > 90 And intRdm < 97 Then GetRdm
End Sub
wscript.echo strRdm
Set oWshNet = CreateObject("WScript.Network")
sUserName = "localadmin"
sComputerName = oWshNet.ComputerName
Set oUser = GetObject("WinNT://" & sComputerName & "/"& sUserName & ",user")
oUser.SetPassword(strRdm)
oUser.Setinfo Tag: Script to copy groups to new OU Tag: 172726
I need help!!!!
Hi everybody,
I've got a very big problem with a VBScript. I've got a ActiveX DLL
compiled with Visual Basic 6.0. In that DLL I've got a Pulic Collection with
elements within, but when I do a reference to the objects in the collection,
the script returns an incredible error:
Error: Unknown runtime error: 'Cod_Collection.Item'
Code: 800A0062
Source: Microsoft VBScirpt runtime error
I've been debugging the DLL and it works fine. When I do a msgbox
Cod_Collection.Count, it returns ok the value. I need help!!!! Please!!!
Thanks,
Eider. Tag: Script to copy groups to new OU Tag: 172723
Scriptomatic
Any script I try to run from scriptomatic, fails at the
"For Each objItem In colItems"
I'm running the scrips, (and scriptomatic as well) from WinXP. I've
also tried on the scripts several other PC's with the same result. Is
there something I need to add to the scripts to make them function?
What I get back when running the scrips is something like..( I do have
to rem out the first line, on error resume next, in order to get a dos
shell with the following)
==========================================
Computer: Script-tester
==========================================
C:\Scripts\Scriptomatic2\temp_script.sm(17, 4) (null): 0x80041003
C:\Scripts\Scriptomatic2> Tag: Script to copy groups to new OU Tag: 172717
how can I read EXIF data from a JPEG file
I know windows can read the exif data out of jpeg files, but can I retrieve
that data with vbscript?
please help,
Rafael Tag: Script to copy groups to new OU Tag: 172710
ADO multiple field recordset search
This is a multi-part message in MIME format.
------=_NextPart_000_000C_01C53A0F.CEB7CE40
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hey there,
I have a script that writes to an Access database with the following =
columns.
ComputerName UserID ProfileSize LastModDate
I would like to perform a multiple field search in ADO rather than a =
single column recordset search. Is there anyway to do that. Below is =
what I currently have for single column searches.
****************************
PCName =3D "mycomputer"
ProfileName =3D "dabungis"
strSearchCriteria =3D "ComputerName =3D '" & PCName & "'"
objRecordSet.Find strSearchCriteria
If objRecordset.EOF Then 'if not found, then add new record
objRecordset.AddNew
End If
************************
I would like to perform a multiple field search such as below.
******************************
PCName =3D "mycomputer"
ProfileName =3D "dabungis"
strSearchCriteria =3D "ComputerName =3D '" & PCName & "' and UserID =3D =
'" & ProfileName & "'"
objRecordSet.Find strSearchCriteria
If objRecordset.EOF Then 'if not found, then add new record
objRecordset.AddNew
End If
******************************
However, I always receive an error like below.
"ADODB.Recordset: Arguments are of the wrong type, are out of acceptable =
range, or are in conflict with one another."
What's wrong?
-Jeff
------=_NextPart_000_000C_01C53A0F.CEB7CE40
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1492" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial>Hey there,</FONT></DIV>
<DIV><FONT face=3DArial></FONT> </DIV>
<DIV><FONT face=3DArial>I have a script that writes to an Access =
database with the=20
following columns.</FONT></DIV>
<DIV><FONT face=3DArial></FONT> </DIV>
<DIV><FONT face=3DArial>ComputerName =
UserID =20
ProfileSize LastModDate</FONT></DIV>
<DIV><FONT face=3DArial></FONT> </DIV>
<DIV><FONT face=3DArial>I would like to perform a multiple field search =
in ADO=20
rather than a single column recordset search. Is there anyway to =
do=20
that. Below is what I currently have for single column=20
searches.</FONT></DIV>
<DIV><FONT face=3DArial></FONT> </DIV>
<DIV><FONT face=3DArial>****************************</FONT></DIV>
<DIV><FONT face=3DArial>PCName =3D "mycomputer"</FONT></DIV>
<DIV><FONT face=3DArial>ProfileName =3D "dabungis"</FONT></DIV>
<DIV><FONT face=3DArial></FONT> </DIV>
<DIV><FONT face=3DArial>strSearchCriteria =3D "ComputerName =3D '" =
& PCName=20
& "'"<BR> objRecordSet.Find strSearchCriteria</FONT></DIV>
<DIV><FONT face=3DArial></FONT> </DIV>
<DIV><FONT face=3DArial> If objRecordset.EOF Then 'if =
not found,=20
then add new record<BR> objRecordset.AddNew<BR> =
End=20
If</FONT></DIV>
<DIV>
<DIV><FONT face=3DArial>************************</FONT></DIV>
<DIV><FONT face=3DArial></FONT> </DIV>
<DIV><FONT face=3DArial>I would like to perform a multiple field search =
such as=20
below.</FONT></DIV>
<DIV><FONT face=3DArial></FONT> </DIV>
<DIV><FONT face=3DArial>******************************</FONT></DIV>
<DIV><FONT face=3DArial>
<DIV><FONT face=3DArial>PCName =3D "mycomputer"</FONT></DIV>
<DIV><FONT face=3DArial>ProfileName =3D "dabungis"</FONT></DIV>
<DIV><FONT face=3DArial></FONT> </DIV>
<DIV><FONT face=3DArial>strSearchCriteria =3D "ComputerName =3D '" =
& PCName=20
& "' and UserID =3D '" & ProfileName & "'"<BR> =
objRecordSet.Find=20
strSearchCriteria</FONT></DIV>
<DIV><FONT face=3DArial></FONT> </DIV>
<DIV><FONT face=3DArial> If objRecordset.EOF Then 'if =
not found,=20
then add new record<BR> objRecordset.AddNew<BR> =
End=20
If</FONT></DIV>
<DIV>******************************</DIV>
<DIV> </DIV>
<DIV>However, I always receive an error like below.</DIV>
<DIV>"ADODB.Recordset: Arguments are of the wrong type, are out of =
acceptable=20
range, or are in conflict with one another."</DIV>
<DIV> </DIV>
<DIV>What's wrong?</DIV></FONT></DIV>
<DIV><FONT face=3DArial></FONT> </DIV>
<DIV><FONT face=3DArial>-Jeff</FONT></DIV></DIV></BODY></HTML>
------=_NextPart_000_000C_01C53A0F.CEB7CE40-- Tag: Script to copy groups to new OU Tag: 172709
how can I use IIS mail object?
Hi.
I have used rental space and used web mail there in ASP, like;
Set Mail = Server.CreateObject("Some.MailSender")
Mail.Host = somerHost
Mail.From = fromAddress
-----
Mail.AddAddress bccAdr
Mail.AddBCC bccAdr
Mail.Subject = "Some matter" ' message subject
Mail.Body = "Something to someone"
-----
Mail.Send ' send message
Then can I use the same method in IIS's built-in mail server?
Thanks.
M.M. Tag: Script to copy groups to new OU Tag: 172707
Add ISAPI filter throug script
Hi,
I was wondering if anybody know how to add a ISAPI filter into IIS 6.0
through script ?
thanks Tag: Script to copy groups to new OU Tag: 172703
Automation - CPL file
Hi,
I'd like to know if there's a way to create a vb script to launch and CPL
file and set some values.
For example, %windir%\system32\inetcpl.cpl file (this file brings up IE
"Internet Options" dialog) and I'd like to set some values on the dialog,
e.g. "home page address" on the "General" tab, "customs level" on "security"
tab, edit "web sites" list on "privacy" tab, etc. etc. etc.
Is it doable in vb script? If yes, how to? If no, any other way to
approach this?
Please advice, thanks!
-P Tag: Script to copy groups to new OU Tag: 172701
Build a hyperlink with user logon name in it
Hi there,
I have a simple HTML page.
I would like to create a hyperlink on it that points to the logon user's
home directory on a known server. For example:
<A HREF = "http://[Server name]/[Logon User name]/Info.html">Your info
here</A>
Basically I would like to construct the hyperlink on the fly. BTW, the
server name is known and it will be the same for all users.
Do you know if I can do that on a HTML page with VBScript?
Thanks.
Abel Chan Tag: Script to copy groups to new OU Tag: 172697
2 different dates returned
Hi,
I have written a generic script has successfully worked on all servers it
was deployed on.
Recently it was brought to my attention that not all the information was
being correctly gathered.
Through much testing I discovered that the same line of code returns
different values on 2 different servers each running windows 2003.
The line of code is:
strDate=cstr(date()-1)
On our server it returns 4/4/2005.
On the other w2003 server it returns 04/04/05.
Any idea as to why this may be?
Thanks in advance,
Rowland Tag: Script to copy groups to new OU Tag: 172693
Launch "printers and faxes"
How can I launch the PRINTERS AND FAXES window on W2K and WXP using
vbscript?
Thanks in advance.
Ian Matthews
MCSE2001 Tag: Script to copy groups to new OU Tag: 172690
is it possible to script a transparent IE window?
I have seen some cool .NET apps that use transparent windows and I
would like to know if anyone knows how to script a transparent window
in IE? I use IE to display output/interfaces for vbscript apps and I am
wondering if this is possible? Tag: Script to copy groups to new OU Tag: 172689
Schedule Task
Ok can anyone point me on how to use VBScript to schedule a task? I am
clueless on this....thanks. Tag: Script to copy groups to new OU Tag: 172687
=?Utf-8?Q?ActiveX_component_cant=E2=80=99t_create_?=
I am trying to learn VB scripting by following the Windows 2000 Scripting
guide. Following along in the book (printout) using a script that reports
back free space on the c drive.
Const CONVERSION_FACTOR = 1048576
Set objWMIService = GetObject("winmgmts:")
Set objlogicalDisk = objWMIservice.Get("win32_LogicalDisk.DeviceID='C:â??â??)
FreeMegBytes = objLogicalDisk.freespace / CONVERSION_FACTOR
Wscript.Echo Int(FreeMegBytes)
When I add the line to access a remote computer ("winmgmts://" & Computer)
Const CONVERSION_FACTOR = 1048576
Computer = "billy"
Set objWMIService = GetObject("winmgmts://" & Computer)
Set objLogicalDisk =
objWMIService.Get("win32_LogicalDisk.DeviceID='C:â??â??)
FreeMegBytes = objLogicalDisk.freespace / CONVERSION_FACTOR
Wscript.Echo Int(FreeMegBytes)
I get a VBScript runtime error
Script: c:\vbstestarea\t1.vbs
Line: 3
Char: 1
Error: ActiveX component cantâ??t create object: â??GetObjectâ??
Code: 800A01AD
Source: Microsoft VBScript runtime error
Any help would most helpful Tag: Script to copy groups to new OU Tag: 172685
Retrieving Exit Code from Script executing using Exec command
I suspect I know the answer, but I want to confirm. If I have a controlling
script (script A) which calls another script (Script B) using Wscript.Exec
command, will the ExitCode always be 0 when I read ExitCode attribute on the
returned WshScriptExec object?
For example:
'Script A
Set objShell = CreateObject("WScript.Shell")
Err.Clear
Set objExec = objShell.Exec("%comspec% /c cscript //nologo c:\temp\test2.vbs")
Do While objExec.Status = 0
Wscript.Sleep(100)
Loop
Wscript.WriteLine("Error Code: (" & objExec.ExitCode & ") ")
'Script B
Wscript.Echo " Starting Test - Test2.vbs"
Wscript.Sleep(4000)
Wscript.Echo " Ending Test - Test2.vbs"
Err.Raise vbObjectError+3,"","Testing Failure Code 3"
Wscript.Quit(3)
I would expect that the last line in Script A would print "Error Code: (3)",
but rather I get a 0. Tag: Script to copy groups to new OU Tag: 172682
How to get a second IE window right after closing the first one
Hi,
I'm trying to open another IE window with VBS right after
the previous one has been closed.
Playing around with the OnQuit event helps, but somehow the
first IE windows crash.
Could anybody help me, please? Thanks.
Stefan
##############################
Option Explicit
Dim objIE
Dim Counter, Max
Counter = 0
Max = 5
Call ShowIE
Sub ShowIE
Set objIE = WScript.CreateObject("InternetExplorer.Application", "IE_")
objIE.Visible = True
objIE.navigate "http://www.yahoo.com"
While True
WScript.Sleep 5
Wend
End Sub
Sub IE_onQuit
Counter = Counter + 1
If Counter <= Max Then
Call ShowIE
End If
End Sub Tag: Script to copy groups to new OU Tag: 172675
change directory and then type text
Hi all,
I am a newbie to VBS and get stuck with my script when I want to type
a string after a prompt. My script looks as follows:
Set objshell = CreateObject("WScript.Shell")
objshell.Environment("process")("prompt") = "$V$_$T$_$P$G"
objshell.CurrentDirectory = "C:\Programme\PostgreSQL\8.0\bin\"
objshell.Run "%comspec%"
--> so far everything works fine
WScript.StdOut.Writeline "String I want to issue"
--> Message "invalid handle"
Any idea?
thanks in advance
Francois Tag: Script to copy groups to new OU Tag: 172673
Simple Script Returns No Entries
How can I filter a query to printers that are on a specific print server?
When I run the following script I get no hits.
________________
strComputer = "."
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery ("Select * from
Win32_Printer Where ServerName='\\print_server'")
For Each objItem in colInstalledPrinters
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "ServerName: " & objItem.ServerName
Wscript.Echo "Shared: " & objItem.Shared
Wscript.Echo "ShareName: " & objItem.ShareName
Wscript.Echo "Status: " & objItem.Status
Next
________________
The script was built with script-o-matic except I added -- Where
ServerName='\\print_server'") -- which I am pretty sure is the correct
syntax. Of course I substituted my real printer servers name for
\\print_server .
Any suggestions would be appreciated.
Ian Matthews
MCSE2001 Tag: Script to copy groups to new OU Tag: 172672
example of how to append all txt files in a directory into one file
Can someone post an example of how I can merge (append) a list of text
files (all in same directory) into one big text file? This would be
easy in unix shell scripting, but I cant figure it out with vbscript.
If it cant be done, I would take a DOS solution if someone knows how.
-thanks! Tag: Script to copy groups to new OU Tag: 172668
map drive names ?
Is there any way to customize the drive names when i map , i mean i have
vbscript as follows
Dim objNet
Set objNet = CreateObject("Wscript.Network")
objNet.MapNetworkDrive "H:", \\main\share
WSCript.Quit
this creats a Network Drive called share on 'main' drive letter H i want it
to look like Managment, Sales or things like that ?
is it possible ?
thanks Tag: Script to copy groups to new OU Tag: 172665
Default page size ?
Here is a script that i use to set default printer for my clients @ logon ,
Dim net
Set net = CreateObject("WScript.Network")
net.SetDefaultPrinter "\\itzkhi\NRgd4452"
i am facing a problem which is we use A4 page size on printer & this script
sets it to Letter size , can we also set the default page size to A4 with
vbscript ?
please guide me ..
thanks Tag: Script to copy groups to new OU Tag: 172664
VBScript on Intranet webpage works on only some PCs.
Hi!
I've been using the code below to send the results of a form on our intranet
using the users Outlook installation. I've recently learned that it's not
working on all machines. Normally, the user would complete the form, click
SUBMIT, and there would be a security popup warning that another application
was trying to use Outlook. The uesr would click YES and the message would be
sent.
The error is "ActiveX component can't create object: 'Outlook.Application'
I believe that one of two things might be causing this (please correct me if
I'm wrong)...
1) The security settings in IE or an IE security update is preventing the
VBScript to work. I've set the Intranet and Internet settings as low as
possible and still get the error. My development machine may not have all
the updates that the problem machine has.
2) The machine with the error is running Outlook 2003. My development
machine runs Outlook 2002 and has no issues. Do I need to use a different
object to make this 2003 compatible? Is there a setting in Outlook 2003 that
would allow this to work?
3) ... Any other ideas???
All machines are running WinXP Pro with SP1.
Any help is appreciated.
'*************************************************
'*
'* Send an HTML email message using users Outlook
'*
'* strTo = List of addresses to send to
'* strFrom = Senders name/address
'* strSubject = Subject line of message
'* strMsg = Message content - HTML formatted
'*
'*************************************************
sub OutlookHTMLSend( strTo, strFrom, strSubject, strMsg )
Set objOlApp = CreateObject("Outlook.Application")
Set objMsg = objOlApp.CreateItem(olMailItem)
objMsg.To = strTo
objMsg.Subject = strSubject
objMsg.HTMLBody = strMsg
objMsg.Save
'Show message and let user edit and send manually.
' !! Formatting is messed up if user has Word set as their email editor. !!
'objMsg.Display
'Just send message. User may get security warning
objMsg.Send
'Destroy object
set objMsg = Nothing
set objOlApp = Nothing
'Send user to index page
document.location ="default.asp"
end sub Tag: Script to copy groups to new OU Tag: 172657
send a mail include an attachment with CDO, if the attachment is in the DataBase, How to do it?
Dim MyMail
Set MyMail = Server.CreateObject("CDO.Message")
MyMail.From = "justme@myaddress.com"
MyMail.To = "friend1@address1.com;friend2@address2.com"
MyMail.Subject = "Sending Mail via CDOSYS for Windows 2000/XP"
MyMail.TextBody = "Sending email with CDOSYS Message " &_
"objects is easy! Try it!"
MyMail.AddAttachment "c:\path\smiley.gif"
MyMail.Fields("urn:schemas:httpmail:importance").Value = 2;
MyMail.Fields.Update()
MyMail.Send()
Set MyMail = Nothing
If the "smiley.gif" is in the database(e.g. sql server),how to do it? Tag: Script to copy groups to new OU Tag: 172655
Schedule + VBScipt
Hi this might be the wrong place to put this but I am currently trying to
find out how I would use vbscript to schedule a .bat file to run two weeks
after I restore certain files. It's basically a backup restore bat file that
I run to take stuff up and down on the network. What I want to do is set it
up after I restore the files that it run a vbscript that would schedule a
task two weeks from the restore date. The AT command is great but I want to
be able do the two week thing instead of next day. Any help or direction
would greatly be appreciated as I am new to VBScipt. Thank you,
Rob Tag: Script to copy groups to new OU Tag: 172652
Open a console window
Hello world,
I'd like to make a VBScript to...
1. open a console window,
2. execute a few commands within the console (such as cd D:\mydir),
3. then terminate, but leave the console window open
I couldn't find helpful infos in the documentation, so I wonder if this is
possible.
Could anyone please give me a push how to go?
Cheers, Jens Tag: Script to copy groups to new OU Tag: 172647
Copy file from specific https url to local drive
Hi,
Not sure if i got the right forum, i want to do this with a vbs file
anyways, or dos cmd.
I have a specific https url that points to a .xls file:
ie. https://url/test.xls
When i enter the url into a web browser, i firstly get the 'single sign on'
authentication box (entering my username and password for https access) and
then i get a save dialog box where i can save the file.
I want to automate this using the easiest method possible. I dont know where
to look, what would be the best approach?
Thanks heaps,
Josh Tag: Script to copy groups to new OU Tag: 172627
del Reg Key Value and stop and start service
I am new to this and I am trying to get the code below to:
1) delete a reg key value
""SOFTWARE\Intel\LANDesk\Virusprotect6\CurrentVersion\GUID
2) stop the SAV client servuce
3) Start the SAV client service
To a list of 2003 and 2000 servers. I am not sure how to consolidate the
three parts
Thanks
' Delete reg value
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Intel\LANDesk\Virusprotect6\CurrentVersion"
strStringValueName = "GUID"
oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,strStringValueName
'Stop all service and dependents
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery("Associators of " _
& "{Win32_Service.Name='NetDDE'} Where " _
& "AssocClass=Win32_DependentService " & "Role=Antecedent" )
For Each objService in colServiceList
objService.StopService()
Next
Wscript.Sleep 20000
Set colServiceList = objWMIService.ExecQuery _
("Select * from Win32_Service where Name='NetDDE'")
For Each objService in colServiceList
errReturn = objService.StopService()
Next
'start service and dependecies
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery _
("Select * from Win32_Service where Name='NetDDE'")
For Each objService in colServiceList
errReturn = objService.StartService()
Next
Wscript.Sleep 20000
Set colServiceList = objWMIService.ExecQuery("Associators of " _
& "{Win32_Service.Name='NetDDE'} Where " _
& "AssocClass=Win32_DependentService " & "Role=Dependent" )
For Each objService in colServiceList
objService.StartService()
Next
--
Thank You Tag: Script to copy groups to new OU Tag: 172622
Launch a Microsoft Access Macro
Hi....Is there a way to automatically launch a Microsoft Access 97
Macro using vb script. Any help would be greatly appreciated.
Thanks!!! Tag: Script to copy groups to new OU Tag: 172619
Ldap property
Hi ,
I'm developing a vbs program that access to a Active Directory.
I'm getting an object and I want to know if the property value is null or
have a value
What I'm doing is the next
While Not objRecordSet.EOF
strMsExchHomeServerName = objRecordSet.Fields.Item("msExchHomeServerName")
if err.number <> 0 then
hasmb = false
else
WriteLog logfile, "msExchHomeServerName = " & strMsExchHomeServerName
End if
wend
Always returns code = 0.
Please, help me
Thank in advance
olivarbudia Tag: Script to copy groups to new OU Tag: 172618
using vbscript to transfer/move files
I'm looking for some code example on how to move a folder/file from one
server to another inside the same domain. I have code to move a folder from
on location to another on the same server, but when I try to move a
folder/file from one server to another, I get a permission denied error. Any
help would be greatly appreciated.
Ron Tag: Script to copy groups to new OU Tag: 172616
A couple of questions about VBScript
I've got a couple of questions WRT VBScript. I am using VBScript with
Windows Script Host on Windows XP and incorporating the scripts into a WSF
file.
My questions are as follows:
1. Do classes allow for public or private Const declarations? I've tried,
but I can't seem to find a way to do this. I have been able to duplicate
the behavior by using properties with only a Get accessor, but this seems to
be a bit of a hack. I have several constants that are only needed internal
to the class and several that are helpful as arguments to methods. The
amount of code needed for the property hack seems wasteful and the
initialization of private data members is cumbersome.
2. Does VBScript allow Enums? The documentation doesn't appear to disallow
it, but I am unable to code them without getting a runtime error. I've
likely missed something in the documentation, but I thought that I would
ask.
3. Is it possible to have some sort of class constructor that takes an
argument as opposed to Class_Initialize which does not allow arguments? I
have several classes where it makes sense to only have single step
contruction as the class is in an indeterminate state unless several
properties are known at class instantiation time. Two-step construction
would require the user of the classes to know that the second method call is
required.
Thanks in advance..
-Pete Tag: Script to copy groups to new OU Tag: 172611
IExplore.exe
Below is a vb script that will destroy any Iexplore.exe processes. It works
fine but is there a way to determine which ones not destroy.
For example, lets say the following websites are currently open.
www.google.com
www.yahoo.com
www.microsoft.com
Is there a way to destory yahoo and google but leave the microsft site open.
We have a webapplication that is menu enabaled that launches several
websites. I want to be able to see if a website is open before intiaiting
another instance.
strWMIMoniker = "winmgmts:!//posdtdc357407b"
strQuery = "select * from Win32_Process where Name='iexplore.exe'"
WScript.Echo(strQuery)
For Each wmiProcess in GetObject(strWMIMoniker).ExecQuery(strQuery)
WScript.Echo wmiProcess.Name & " (" & wmiProcess.ProcessId & ") is being
terminated"
wmiProcess.Terminate
Next Tag: Script to copy groups to new OU Tag: 172609
Enable / Disable 802.1x with some script
Hi everyone,
I have been searching the answer to my question for a very long time now,
but there is no solution in sight. So here is my problem:
I want to enable / disable 802.1x Authentication on network adaptors using
some sort of automation (some script / program). Does anyone out there knows
a solution for that?
I'll highly appreciate any helpful suggestions or pointers. Thanks in
Advance.
T. Shafi Tag: Script to copy groups to new OU Tag: 172601
Editing the nth byte of a BINARY Registry Value
Hello
I'm trying to edit a Binary Registry value which I can do by doing a full
replace of the data, but because the data could be different from machine to
machine and only specific bytes change I was trying to write a script that
would allow me just edit specific bytes for example byte 6 and 63, but I
don't know the best way to go about it.
Could I use to the Replace function in this example?
Replace(reg_string, "00", "01", 63, 1, 0)
If so would someone be able be able to help me read in a binary registry
value that I could run the replace on.
I really don't have any preference how I get to how I get this to work, my
programming knowledge is limited so any advice or help would be most
appreciated.
Thanks for time
Gary
PS My reference to a byte is if you export out from the registery a binary
value
eg "1"=hex:03,00,00,00,00,00,00,
I'm asuming that the number inbetween the coma's represets a byte and I've
worked out byte's that I would need to change.
Please feel free to tell me if i'm being a doughnut Tag: Script to copy groups to new OU Tag: 172598
Scripting for local user admin
I am looking for a script that I can run that will search
all computers in my windows 2000 domain, display the
username logged on and see if that user has local admin
rights to his local machine
Any help?
Thanks Tag: Script to copy groups to new OU Tag: 172595
Removing "File Extension Assoication"
Hi all,
I wonder if anyone knows how to remove a "file extension assoication"
programmatically with VBScript/WSH/WMI or maybe simply with a ".reg" file?
Thanks in advance.
T. Tag: Script to copy groups to new OU Tag: 172593
same script ok on 2K but return nothing on NT4
This is a multi-part message in MIME format.
------=_NextPart_000_0029_01C5394E.45CFB640
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi,
I have the vbscript abstract to query installed software information =
from registry, the script runs perfect on Win2k/2k3, however returns =
nothing on NT4, even though I have already installed WMIcore for NT4. =
There is no error msgs, the output file is still created, but no =
installed software is enumerated.
I checked NT registry and it seems the software list is in the same =
location =
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"=
, the users account used to run the script is under administrators =
group.=20
Any ideas?=20
Thanks
Frank
This is part of the script:
-------------------------------------------------------------------------=
-------------------------------------------------------------------------=
--
' To enumarate installed software from the reg key which will also =
appear on add/remove programs
' to enumurate the UninstPath for subkeys using EnumKey method,=20
' then Get correponding value from the key Path using GetStringValue =
method for string keys
' In order to remove invalid output, check the display name of the reg =
key is not Null.
' Then check the version and Installed date which if null set to empty =
so that output correctly
Const HKEY_LOCAL_MACHINE =3D &H80000002
Const UnInstPath =3D =
"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
Set objReg=3DGetObject("winmgmts:{impersonationLevel=3Dimpersonate}!\\" =
& _
strComputer & "\root\default:StdRegProv")
objReg.EnumKey HKEY_LOCAL_MACHINE, UnInstPath, arrSubKeys
objFile.WriteLine ()
objFile.Writeline("-------------------Installed Software =
Information------------------------")
For Each subkey In arrSubKeys
strKeyPath =3D UnInstPath & "\" & subkey
objReg.GetStringValue =
HKEY_LOCAL_MACHINE,strKeyPath,"DisplayName",strValueDisplayName
objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath , =
"DisplayVersion",strValueDisplayVersion
objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath , =
"InstallDate",strValueInstallDate
If Not IsNull(strValueDisplayName) Then
strSoftwareName =3D strValueDisplayName
End If
If Not IsNull(strValueDisplayVersion) Then
strSoftwareVersion =3D strValueDisplayVersion
Else=20
strSoftwareVersion =3D Empty=20
End If
If Not IsNull(strValueInstallDate) Then
strSoftwareInstallDate =3D "Installed on " & =
WMIDateStringToDate1(strValueInstallDate)
Else
strSoftwareInstallDate =3D Empty
End If
If Not IsNull(strValueDisplayName) Then
objFile.WriteLine(strSoftwareName & " " & strSoftwareVersion & " " =
&strSoftwareInstallDate)
End If
------=_NextPart_000_0029_01C5394E.45CFB640
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1491" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV>
<DIV> </DIV>
<DIV>I have the vbscript abstract to query installed software =
information from=20
registry, the script runs perfect on Win2k/2k3, however returns nothing =
on NT4,=20
even though I have already installed WMIcore for NT4. There is no error =
msgs,=20
the output file is still created, but no installed software is =
enumerated.</DIV>
<DIV> </DIV>
<DIV>I checked NT registry and it seems the software list is in the same =
location=20
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"=
, the=20
users account used to run the script is under administrators group. =
</DIV>
<DIV> </DIV>
<DIV>Any ideas? </DIV>
<DIV> </DIV>
<DIV>Thanks</DIV>
<DIV>Frank</DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV>This is part of the script:</DIV>
<DIV>--------------------------------------------------------------------=
-------------------------------------------------------------------------=
-------</DIV>
<DIV><FONT face=3DArial size=3D2>' To enumarate installed software from =
the reg key=20
which will also appear on add/remove programs<BR> ' to enumurate =
the=20
UninstPath for subkeys using EnumKey method, <BR> ' then Get =
correponding=20
value from the key Path using GetStringValue method for string =
keys<BR> '=20
In order to remove invalid output, check the display name of the reg key =
is not=20
Null.<BR> ' Then check the version and Installed date which if null =
set to=20
empty so that output correctly</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><BR> Const HKEY_LOCAL_MACHINE =3D=20
&H80000002<BR> Const UnInstPath =3D=20
"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"<BR> Set=20
objReg=3DGetObject("winmgmts:{impersonationLevel=3Dimpersonate}!\\" =
&=20
_<BR> strComputer &=20
"\root\default:StdRegProv")<BR> objReg.EnumKey HKEY_LOCAL_MACHINE,=20
UnInstPath, arrSubKeys<BR> objFile.WriteLine=20
()<BR> objFile.Writeline("-------------------Installed Software=20
Information------------------------")<BR> For Each subkey In=20
arrSubKeys<BR> strKeyPath =3D UnInstPath & "\" =
&=20
subkey<BR> objReg.GetStringValue=20
HKEY_LOCAL_MACHINE,strKeyPath,"DisplayName",strValueDisplayName<BR> =
=20
objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath ,=20
"DisplayVersion",strValueDisplayVersion<BR> =20
objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath ,=20
"InstallDate",strValueInstallDate<BR> If =
Not=20
IsNull(strValueDisplayName) =
Then<BR> strSoftwareName =3D=20
strValueDisplayName<BR> End If<BR> If =
Not=20
IsNull(strValueDisplayVersion)=20
Then<BR> strSoftwareVersion =3D=20
strValueDisplayVersion<BR> Else=20
<BR> strSoftwareVersion =3D=20
Empty <BR> End If<BR> If Not=20
IsNull(strValueInstallDate)=20
Then<BR> strSoftwareInstallDate =3D "Installed on =
" &=20
WMIDateStringToDate1(strValueInstallDate)<BR> Else<BR>&n=
bsp; strSoftwareInstallDate=20
=3D Empty<BR> End If<BR> =
If Not=20
IsNull(strValueDisplayName)=20
Then<BR> objFile.WriteLine(strSoftwareName & =
" "=20
& strSoftwareVersion & " "=20
&strSoftwareInstallDate)<BR> End=20
If<BR></FONT></DIV></FONT></DIV></BODY></HTML>
------=_NextPart_000_0029_01C5394E.45CFB640-- Tag: Script to copy groups to new OU Tag: 172591
Passing arrays as DialogArguments.. ?? VBS to JS
Hi
Passing objects from Javascript via the DialogArgs works fine.
Creating an Obj in VBScript to pass...??
but Real Question is
Having created a dynamic array in VBscript, populated with the values 1 to 10
ie
dim Arr()
.. // Set the values redim preserrve etc in a loop
..
I call the window.showModalDialog("XXX.htm", arr, "....")
and the receiving XXX.htm dialog window
receives the dialog args as (in JavaScipt )
var oMyObject = window.dialogArguments;
and fails as Type MisMatch
Is this maybe because of slightly different implementations in the languages
of the dialogArguments or ..?
Nonetheless, how do I resolve this ? (I have about 3 days of scripting total
to my name... (years of VB proper though))
TIA
Neal
Neal Rogers
University of Cape Town Tag: Script to copy groups to new OU Tag: 172587
Calling VBS function
Hi all,
is there a way to call froma a vbs file a function that resides into another
vbs file ?
Thanks, bye
--
SM Tag: Script to copy groups to new OU Tag: 172580
VBScript to Move Ex2003 Mailbox
Hello,
I want to use a VBScript to move a 2003 mailbox from one server to another.
I would prefer to not have to rely on third party software.
This seems like an obvious one but I just can't work it out.
Thsnk you
Shaun Tag: Script to copy groups to new OU Tag: 172579
Hiding the source code
How do i hide the source code of my page such that it can't be viewed on a
web browser
regards earnie Tag: Script to copy groups to new OU Tag: 172568
"Can't find script engine VBScript for script"
I got the following error "Can't find script engine VBScript for script". I
then download and tried to reinstall Windows Script 5.6 for Windows XP. Then
I got the following error?
Error registering the ocx C:\windows\system32\vbscript.dll
What can I try next? Tag: Script to copy groups to new OU Tag: 172567
Rename pc
Hi. Has anyone figured out a way of renaming multiple pc's in an active
directory domain? I have approximately 400 machines in different OU's that
need to conform to the new naming convention we are implementing. I have
found some scripts on how to rename a computer name and some scripts on
renaming the actual account in AD but I have not been able to combine the two
and to create a script that can rename the pc as well as it's account in AD.
Any help would be greatly appreciated.
Thanks,
Morne Tag: Script to copy groups to new OU Tag: 172566
reload the vbscript itself within a vbscript
Hi,
What I am trying to achieve is to reload the vbscript within the vbscript,
eg, below code promopt for input, then checks for user input and if the
input is less than 1 character long, the script will reload.
However, the problem is that it is sub procedure, the sInputUserDept is not
global, so the the last line of echo becomes 0. How can I overcome this?
Thanks
Frank
Set objShell = WScript.CreateObject("WScript.Shell")
Call subRepeatInput
sub subRepeatInput
sInputUserDept = CStr(InputBox("Please Enter the Department Name:"))
sInputUserName = CStr(InputBox("Please Enter the PC Owner's Name:"))
If Len(sInputUserDept) = 0 Or Len(sInputUserName) = 0 Then
WScript.Echo "You must enter a PC owner's Department and Name"
objShell.Popup "You must enter a PC owner's Department and Name"
Call subRepeatInput
End If
End Sub
WScript.Echo sInputUserDept + sInputUserName Tag: Script to copy groups to new OU Tag: 172564
error 80041004: Provider Failure in accessing CD-Rom
ello,
I am writing a vbscript to access/write to the cdrom drive. The script
fails with the above number/message.
I have also ran <wbemtest.exe> in a command windown, used the root\cimv2
namespace to lookup the W32_CDROMDrive class and after selecting the class
(double clicking on it), if I then 'interrogate' any of the properties using
the buttons: 'Refresh Object' and then 'Instances", I again
get the same error message.
"all" xp methods to view/interrogate the CD *see* the drive and state that
it is functioning correctly (computer management & control
panel-Hardware-Device manager)
I'm stumped, any suggestions? Is WMI broke, or cimv2, or some key in the
registry or is it a case of pilot error???
Thanks,
Thomas Tag: Script to copy groups to new OU Tag: 172561
How do we execute or modify this link in asp server side?
HI! I want to execute a link witch is in JavaScript, How do we execute this
in asp server side if possible?
Basically I don't want anyone to see this link in the code view.
this is the link code. below---------------
<script TYPE="text/JavaScript" LANGUAGE="JavaScript"
src='http://www.site1.com/ffff/jjjgtr.php?a=blahlablah&bgcolor=%23FFFFFF&tuck=aaa&sp=0&ft=4&ftt=1&iw=178&ih=198>=yes&hj=rn&src=yes&nt=no'>
</script>
Thanks in advance :) Tag: Script to copy groups to new OU Tag: 172556
IP Address Reporting and MAC address
Ok, I finally got the IP addresses for a machine to list out via the
following code...
Next
'IP Address
Wscript.Echo " "
Wscript.Echo " "
Wscript.Echo " IP Addresses "
Wscript.Echo " "
Wscript.Echo " "
Set IPConfigSet = objWMIService.ExecQuery("Select IPAddress from
Win32_NetworkAdapterConfiguration ")
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
WScript.Echo " IP ADDRESS: " & IPConfig.IPAddress(i)
Next
End If
Next
I would now like to get the MAC Addres and I have tried selecing * from the
WIn32_NetworkAdapterConfig and listing the mac's but I get all the macs for
all the nics, even if they have no IP associated to them... I would like my
output to be IPADDRESS: 0.0.0.0. MAC ADDRESS: xxxxxxxxxxx
Any suggestions on how to change the above code to reflect that? Tag: Script to copy groups to new OU Tag: 172553
how to continue running the script
Hi,
I have a while loop which grap computer names from a data file to see if
they are online.
How can i write a code for a senario whereby the script will move on to the
next computer name in the list if error is encountered?
currently it just stops there when error is encountered.
thanks Tag: Script to copy groups to new OU Tag: 172551
I need a script to copy a group to a new OU and then rename it as i want to
keep the original groups aswell. can anyone help.
--
TDS