Get list of users in an MS-Access MDB
Using Office 2003 and Windows XP;
1) Is it possible to obtain the network user name of each user currently in
an MS-Access file using a .vbs file?
2) If possible, could someone please post example script to accomplish this?
Thanks much in advance. Tag: t Tag: 204655
mouse / key recorder that writes vbscript?
Hey all. Anyone know if there are any products that will record mouse
actions and key strokes and save that as vbscript? I am looking for a
time saver to help do some simple automation, but all the macro
products I look at save the script into their own cusomt languages...I
really want the reusable output to be in vbscript! Tag: t Tag: 204654
Detect Active NIC on servers with more than one NIC
Hello everyone,
here's a little challenge I've been working on..
1. We are building our servers using a combination of WinPE and a
bunch of batch scripts.
2. When we boot into WinPE, launch an .HTA file that prompts the user
to enter some information, including
IP address, subnet mask and default GW.
3. That information should be applied to the active NIC (the one with
the cable plugged into it), a few scripts run
and then the system reboots and another HTA runs that brings up
additional information asking the type of
config, any additional software installed, etc.
Here's the issue:
The information entered into the initial boot info should be applied
to the active NIC. The active NIC should be enumerated correctly and
the IP address applied to that NIC and all is good. However,
occassionally with some of the newer Compaq servers with virtual
hardware, the NICs are enumerated backwards so the IP address
configured initially is applied to the wrong NIC.
So using this script (see below) doesn't always work because IP
enabled will return both NICs
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colAdapters = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=
True")
Most of the time the first one it returns is the correct one,
occasionally it's reversed though, and that creates the issue.
What I'd like to do is get the results similar to what is returned
when using the getmac.exe utility., so I can parse for the adapter
that DOESN"T return "media disconnected". This adapter will always be
the one that is active (plugged in) and I can then set the IP to that
adapter based on MAC address.
So the question is, is there a way to return MEDIA DISCONNECTED using
a WMI call?
Thanks in advance!!
Regards,
Christopher Rees
Palaestra Training
www.palaestratraining.com
1-800-324-0946 Tag: t Tag: 204650
Check Against Array and Select
Hello all. I'm at a bit of a roadblock that I'm likely just thinking
too hard about. Below is some code from my site. Basically I query a
database to populate a select box. I check that values against another
value in the database and if there is a match it writes the option as
"selected." :
<select name="vCat">
<% WHILE NOT rsPTM.EOF 'get all the values for the select box
IF rsPTM("ptmNo") = rsv("vCat") THEN %> 'check for a match
<option selected value="<%=rsPTM("ptmNo")%>"><%=rsPTM("ptmName")%></
option>
<% ELSE %>
<option value="<%=rsPTM("ptmNo")%>"><%=rsPTM("ptmName")%></option>
<% END IF
rsPTM.MoveNext
WEND %>
</select>
And now the problem. I need to actually check the value against an
array of values. I get my array just fine and then try to loop through
it to check the values, but I'm only getting it partially right. In a
multiple select box (not shown) it either selects only one value (even
though more should match) or it writes each value as many times as
there are items in my array. Any thoughts? Thanks all. Tag: t Tag: 204649
How could I get hard drive information?
Hello All!
I am writing VBScript to determine how many hard drives I have on the
local machine and do a disk defrag(Or just analyze) based on the
result return to me. I wanna do it automatically. Now I could start
disk management console and disk defragmentation console when i run
the scrip. I use winshell object and run method. That's kind of easy,
but this still need some manual configuration. Anyone knows how to
achieve my original goals?
Thanks!
Sincerely,
Ben Tag: t Tag: 204636
Script to detect new DHCP addresses created
Is there a script out there that can notify a network administrator when a
"new" computer has joined the network. I was thinking of querying the DHCP
server for information, but then the process got to be too big for my
abilities. If not a script, does anybody know a prog? Tag: t Tag: 204635
Check two or more folders for the same file
Hello,
I am looking for a way to check two different paths for the same file.
for example I have a script that looks for a file called pccnt.exe on
the entire computer and then runs the trend micro install program if
it does not find that file.
But I would like to speed this up since I already know that the file I
am looking for is always in C:\Program Files\Trend Micro\Officescan
client\ or in D:\Program Files\Trend Micro\Officescan client\.
I would like to know how to tell the script to check the C: path and
the D: path for this file and then run the install program if it does
not find it on either drive, however if it does find this file on D:
or on C: then to just quit.
Here is the script I am running now, and although it works great. It
seems to be slowing down log on time for some of my users.
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root
\cimv2")
Set colFiles = objWMIService.ExecQuery _
("Select * From CIM_Datafile Where FileName = 'pccnt' and
Extension = 'exe'")
Set objShell = CreateObject("Wscript.Shell")
If colFiles.Count > 0 Then
Wscript.Quit
Else
On Error Resume Next
objShell.Run "\\MYSERVERNAME\ofcscan\install_trend.cmd"
End If
Thanks for your input. Tag: t Tag: 204629
HTML date control
I want to implement simple but nice date control on my HTML/ASP page...are
there any such free date controls available...anybody knows it. I want very
simple control...nothing fancy ...it should work with IE, firefox and
netscape.
thanks Tag: t Tag: 204620
AD Search Filter
I'm trying to run an adsi query to output a list of all of our contractors.
We designate our contractors by the display name being capitalized. Is there
a way in say the "objCommand.CommandText =" to specify a displayName filter
be capitalized? Tag: t Tag: 204616
Move files by Date Modified...
I am trying to move all files from one folder to another by the date
modified... the script I am trying to use is
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder("C:\Test Files")
for each file in folder.files
if files.object.DateLastModified<Date() then file.MoveFile "C:\Test Files 2"
next
but I keep getting an error that reads...
Line: 4
Char: 2
Error: Object required: 'files'
Any help will be appreciated.
--
CipherTeKST
MCSE: Security 2003, CCNA, Security+ Tag: t Tag: 204610
If...then help please
Greetings,
I am writing a logon script for our domain users and have run into a
roadblock. I am trying to figure out how to use RemoveNetworkDrive in a Sub
rather than have it check every drive mapping. Here is what I have so far,
without a RemoveNetworkDrive entry:
Option Explicit
Dim objNetwork, objUser, CurrentUser
Dim strGroup, strDomain, strUser, strUNCPath
Dim bIsMember
Dim objGroup, objNet
'Map P: Drive (Public access share)
'Map H: Drive (Home Folder)
On Error Resume Next
If IsMemberOf("Domain Users") Then
MapDrive "P:","\\Test\Public"
End If
If IsMemberOf("Domain Users") Then
MapHomeDrive "H:","\\Test\Home"
End If
If Err <> 0 Then
MsgBox "Server not available; one or more drives were not mapped."
End If
On Error Goto 0
'------------------------------------------------------------------'
'FUNCTIONS '
'------------------------------------------------------------------'
Sub MapDrive(strLetter, strUNC)
Set objNet = WScript.CreateObject("WScript.Network")
objNet.MapNetworkDrive strLetter, strUNC
End Sub
Sub MapHomeDrive(strLetter, strUNCPath)
Set objNet = WScript.CreateObject("WScript.Network")
strUser = objNetwork.UserName
objNet.MapNetworkDrive strLetter, strUNCPath & "\" & strUser
End Sub
Function IsMemberOf(strGroupName)
Set objNetwork = CreateObject("WScript.Network")
strDomain = objNetwork.UserDomain
strUser = objNetwork.UserName
bIsMember = False
Set objUser = GetObject("WinNT://" & strDomain & "/" & _
strUser & ",user")
For Each objGroup In objUser.Groups
If objGroup.Name = strGroupName Then
bIsMember = True
Exit For
End If
Next
IsMemberOf = bIsMember
End Function Tag: t Tag: 204607
Run a *.vbs file from MS-Access or MS-Excel
Using Office 2003 and Windows XP;
Could someone please post generic example code that illustrates how to run a
stand alone *.vbs file from MS-Access and/or MS-Excel (I would presume the
same method would work for either)?
Thanks much in advance. Tag: t Tag: 204603
ADO Recordset vs Command and AD
I need to query AD for categories of user accounts with several thousand per
category, so I need "Page Size" adoCommand property set to enable paging. I
also want RecordSet.RecordCount to determine nonzero results and how many in
the result set, so I set cursortype=3. If I use adoRecordset.open to execute
the query I have the proper cursor, but not page size. If I use Set
adoRecordSet=adoCommand.Execute then paging is enabled and I get a record set
> 1000 but don't get the cursortype=3. How can I execute the query so that I
get both?
Thanks - Dave
'* use ADO to search Active Directory.
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
Set adoCommand.ActiveConnection = adoConnection
'* setting "Page Size" property enables paging, without which results are
limited to 1000 records
adoCommand.Properties("Page Size") = 1000
adoCommand.Properties("Timeout") = 120
adoCommand.Properties("Cache Results") = False
'* using recordset object allows forward and backward cursor movement
Set adoRecordset = CreateObject("ADODB.Recordset")
adoRecordset.ActiveConnection = adoConnection
adoRecordset.CursorType = 3
'* list of attributes to return
strAttributes = "sAMAccountName,department"
strPattern = strSearchPattern & "*"
strQuery = "SELECT " & strAttributes & _
" FROM 'LDAP://DC=blah,DC=blah,DC=com'" & _
" WHERE objectClass='user' " & _
" AND objectCategory='person' " & _
" AND sAMAccountName='" & strPattern & "'" & _
" OR sn='" & strPattern & "'"
'* search AD
' adoRecordset.source = strQuery
' adoRecordset.open
'* must use the adoCommand.execute in order for "Page Size" property to apply
adoCommand.CommandText = strQuery
Set adoRecordSet = adoCommand.Execute Tag: t Tag: 204601
Help debug File Not Found
I have the following code in a VBS file; it displays a file open dialog box
and returns the full path to the file chosen. The program should then open
the selected file, but I get an error that the file was not found; how can it
not be found if I just picked it?
The error occurs on the last line, char 1:
Set oDialog = CreateObject("UserAccounts.CommonDialog")
oDialog.Filter = "VBScript Scripts|*.vbs|All Files|*.*"
oDialog.FilterIndex = 2
iResult = oDialog.ShowOpen
If iResult = 0 Then
Wscript.Quit
Else
sTarget = oDialog.FileName
'Wscript.Echo sTarget
End If
Set oWSHShell = CreateObject("WScript.Shell")
oWSHShell.Run sTarget, 3, True Tag: t Tag: 204599
Determine if a file is open
Using Office 2003 and Windows XP;
Is there a way using a script (in a VBS script file) to determine if a file
is open?
If so, could someone please post example code?
Thanks much in advance. Tag: t Tag: 204587
Open an MS-Access DB
Using Office 2003 and Windows XP;
VBS is very cool! It makes me want to never look at another BAT file ever
again!
Could someone please post example code that would open a file? In
particular, an MS-Access front-end MDB. I was thinking that there was certain
code that would open the file in the correct application without having to
point to the app's exe; like a hyperlink works. Is this possible or am I
dreaming it up?
Please post example code; I'm still learning...
Thanks much in advance. Tag: t Tag: 204580
Vista and prnadmin.dll
Question about Vista security. I've got a script that we use for a
lot of printer administration. It relies on the prnadmin.dll
functionality from the windows resource kit tools. In order to
minimize the install time on the script I register the dll in the
script itself:
const PRNADMINPATH = "C:\Wherever\prnadmin.dll"
Dim objShell : Set objShell = CreateObject("WScript.Shell")
objShell.Run "regsvr32 /s """ & PRNADMINPATH & """",0,True
The script is only used by local administrators, so this route makes
it easy to send them a zip file and have them run the script with no
other installation. Works great in 2000/XP.
The question is, running the regsvr32 (even from start -> run) will
not work in Windows Vista since it needs to be elevated. What is the
proper Vista way of doing this type of thing? Will I need to create
an actual installation program for a script now if I want to use a
dll?
Thanks,
Jesse Tag: t Tag: 204570
Functionality Question
Greetings,
I am rather new to VBS and what it can do, but so far it has been a fun
experience. I currently am making a logon script via vbs and it is coming
along nicely. However, I am doing this in preparation of a move from mixed
Novell/MS environment to a pure MS environment.
Novell is currently used as the file server, but I have recently setup a MS
File Server and plan to migrate to it in a month or two. Novell allows for
the dynamic creation of the user home folder and rights assignment to that
folder whenever creating a new user account. My question is this: Is it
possible to mimic that functionalty in the MS environment using VBS, say
write a script to create a new user, user home folder and set permissions on
it. I would assume you would want input msgbox's for the unique naming and
so forth. Just wondering if this is workable? Thanks...
-Mac Tag: t Tag: 204563
Looking for a script to delete AD user accounts
Hi, does anyone have a script they could share that will prompt the user for
a computer name, search AD for the computer object and the delete the
computer object? Our computer objects reside in a variety of OUs, so the
script would need to search the entire directory.
Thanks,
Mike Tag: t Tag: 204559
FTP upload using InetCtls.Inet.1 - error with IE7
Hi,
I'm using the std script from PDF Creator to FTP upload files after PDF
printing.
The script uses the following function to upload.
However after installing IE 7, I get an error on the line "Set ftpo =
CreateObject("InetCtls.Inet.1")".
I have done some googleing, and found out that it because of IE 7.0. How can
I easy change the function so that it works?
Code:
Call FTPUpload(domain, rdir, user, pass, fname)
Private Sub FTPUpload(domain, rdir, user, pass, fname)
Dim fso, ftpo
Set fso = CreateObject("Scripting.FileSystemObject")
Set ftpo = CreateObject("InetCtls.Inet.1")
ftpo.URL = "ftp://" & domain
ftpo.UserName = user
ftpo.Password = pass
ftpo.Execute , "CD " & rdir
Do
WScript.Sleep 100
Loop while ftpo.StillExecuting
ftpo.Execute , "Put """ & fname & """ """ & fso.GetFilename(fname) & """"
Do
WScript.Sleep 100
Loop while ftpo.StillExecuting
ftpo.Execute , "Close"
End Sub
Best regards
Mads Tag: t Tag: 204558
Displaying code as html
Does anyone know of a tool / freeware / code theyve written to parse a piece
of VBScript and format it as HTML. I would like to output code snippets onto
a web site / blog that is correctly formatted and with the right colours.
If someone has an xsl sheet or some other method of doing this it would save
me a lot of time. Tag: t Tag: 204554
Select menu choice in a .Net application via PostMessage
Hi all,
Can anyone give me a hint how to select a menuchoice in an .Net
application via a post message.
I have got this far
objHandle = objForm.FindWindow ("WindowsForms10.Window.8.app.
0.3b95145", "MyApplication")
// FindWindow works and I have got a handle.
// Now I want to activate the a menu choise. e.g. File/Save
PostMessage objHandle, ?????????
Any hints appriciated
/Broeden Tag: t Tag: 204553
VBS equivalent to BAT %USERPROFILE%
Using Office 2003 and Windows XP;
Due to the enhanced power and control found in VBS, I am trying to replace a
few old batch files with a VBS file. Mostly, these are used for deployment of
front-end MDB databases to users and distribution of MS-Excel files.
1) Is there anything in particular I should know about this migration from
batch to VBS? Given the flexibility in VBS it would seem I'm doing myself a
favor...
2) In a batch file, I can use %USERPROFILE% as part of a path and then no
matter who opens the batch file, their particular user profile is mapped.
What is the equivalent command(s) and/or keywords in VBS? --- If it requires
more code, could an example be posted?
Thanks much in advance. Tag: t Tag: 204551
Save results of ASP to excel and save file on server
Currently I am using the:
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment;
filename="myFile.xls"
Opening this page will prompt the user to save or download, as
expected.
What I am trying to do is create the XLS documents overnight so the
user doesnt need to wait for the asp script to take its course. They
can simply click on the "myFile.xls" and download its already saved
results. However, I don't know how to save the file dynamically
without user intervention to click "Save"
Thanks in advance for any assistance. Tag: t Tag: 204548
Adaptec Raid Controller - Interrogate
Is there any way to interrogate the state of an Adaptec Raid controller using
vbScript for data such as are the disks 'optimal'? This is on a Win2003 SBS
server.
Thanks - John Tag: t Tag: 204546
Script to Move All Files in First Folder to A Second Folder
Hello...
I need to move all the files in a network folder (\\bmd-fax\faxes) to
a second folder (\\bmd-fax\new). This will be done repeatedly
throughout the day, so I would like to do it with a script that is
assigned to a desktop icon.
We are using Windows XP computers on a Microsoft Server 2003
network. Does anyone know how to do that with a script?
Thanks so much for any help possible.
Jessi Tag: t Tag: 204544
VbS Script Define??
I need a script that searches words from www.urbandictionary.com and
www.dictionary.com if possible also www.thesaurus.com for words when
executed. Displaying the #1 result. First it would check if the word
is in dictonary.com than urbandictionary.com. When using thesaurus.com
you would use a different command. I need help with the para string,
and stat strings of the websites. I can make the commands and
executables. Here is some code that might be useful for you guys if
need be or you can use your own way.
content = InetOpen("http://dictionary.reference.com/search?q="&word)
if instr(content, "No entry found for") <> 0 then
call defUrban(word, user, mode)
exit sub
end if
data = split(content, "<LI TYPE=""a"">")
if ubound(data) = 0 then
info = split(content, "<DD>")
if ubound(info) > 3 then
for i=1 to ubound(info)
newdef = mid(info(i), 1, instr(info(i), "<")-1)
call displayText(i & ": " & newdef, " ", BotVars.Username, 1)
next
else
for i=1 to ubound(info)
newdef = mid(info(i), 1, instr(info(i), "<")-1)
call displayText(i & ": " & newdef, " ", BotVars.Username, 1)
next
end if
if ubound(info) = 0 then
call defUrban(word, user, mode)
end if
exit sub
end if
'else if ubound(data) > 0, when there is a list of definitions...
if ubound(data) > 3 then
call handleText(user, "Found " & ubound(data) & " entries for "&
word & ". Here are three.", mode)
for i=1 to 3
newdef = mid(data(i), 1, instr(data(i), "<")-2)
call displayText(i &": " & newdef, " ", BotVars.Username, 1)
next
else
for i=1 to ubound(data)
newdef = mid(data(i), 1, instr(data(i), "<")-2)
call displayText(i & ": " & newdef, " ", BotVars.Username, 1)
next
end if
End Sub
Sub defUrban(word, user, mode)
if ScINet.stillExecuting then
call handleText(user, "The bot is busy... wait a few seconds and
try again.", mode)
exit sub
end if
content = InetOpen("http://www.urbandictionary.com/define.php?
term="&word)
if instr(content, "is undefined") <> 0 then
call handleText(user, "Failed to find a definition using both a
dictionary and an urban dictionary.", mode)
exit sub
end if
defArray = split(content, "<div class=""def_p"">")
if ubound(defArray) = 0 then
call handleText(user, "Failed to find a definition using both a
dictionary and an urban dictionary.", mode)
exit sub
end if
defcount = 0
found = false
for i=1 to ubound(defArray)
if instr(defArray(i), "1.") = 0 then
found = true
def = mid(defArray(i), instr(defArray(i), "<p>"))
def = mid(def, 1, instr(def, "</p>")-1)
def = replace(def, """, "")
'addchat vbyellow, def
while instr(def, "<") <> 0
pos1 = instr(def, "<")
pos2 = instr(def, ">")
temp = mid(def, pos1, pos2-pos1+1)
def = replace(def, temp, "")
wend
addchat vbred, len(def)
def = replace(def, " ", " ")
def = replace(def, vbnewline, "")
def = replace(def, vbtab, "")
def = replace(def, cr, "")
def = replace(def, lf, "")
def = replace(def, ctlf, "")
def = replace(def, " ", " ")
call displayText(word & ": " & def, " ", BotVars.Username, 1)
defcount = defcount + 1
if defcount = 1 then exit sub
end if
next
if found = false then call handleText(user, "Definition exists on
urban dictionary, but not on dictionary.com - Definition could not be
displayed.", mode)
End Sub Tag: t Tag: 204543
Credentials when using Controller.CreateScript
I am using Controller.CreateScript successfully to run scripts remotely on
hosts in the same domain. When trying to launch the Controller.CreateScript
on a host that is not in the same domain, I receive a Permission denied
error, and there is an "Access denied attempting to launch a DCOM Server" in
the event log on the server in which the object was attempted. There is not
a trust relationship between these 2 Windows 2000 domains. I would like to
keep things as secure as possible (i.e. I don't want to give "everyone"
permission to create WSHRemote on my host) - what is the best way to
configure the server in the alternate (non-trusting) domain to accept my
remote script, or configure the CreateScript to pass credentials? Tag: t Tag: 204542
script fails if string contains chinese characters
I have a vbscript (see below) that works fine when Regional Options
are set to English (US). However, if I change the Regional Options to
Chinese (PRC), the script fails with the following error message:
Test.vbs(20, 4) Microsoft VBScript runtime error: Invalid procedure
call or argument
The statement that fails is
f=2EWrite(msg)
The value of msg is " starting on 2007=E5=B9=B44=E6=9C=882=E6=97=A5 xxx"
As a workaround, I can get the script to work by changing
FormatDateTime(now(),1)
to
FormatDateTime(now(),4) ' -- returns a date in short format w/o
chinese characters
However, I am wondering if there is a way of making the script to work
with the long date format. Does anyone know why the long format
cause this problem? Is it because latin digits are mixed with chinese
characters?
I see the problem on both XP SP2 and Win 2003 SP1.
Thanks for any suggestion.
HH
Here is the actual script:
'--------------------------------------------------------------------------=
------------------------
Const ForReading =3D 1, ForWriting =3D 2, ForAppending =3D 8
Const OutFile =3D "c:\testfile.txt"
Dim fso, f, msg
Set fso =3D CreateObject("Scripting.FileSystemObject")
if fso.FileExists(OutFile) Then
fso.DeleteFile(OutFile)
End If
Set f =3D fso.OpenTextFile(OutFile, ForWriting, True)
msg =3D " starting on " & FormatDateTime(now(),1) & " xxx"
FormatDateTime(now(),4) & "." & vbCrLf
WScript.Echo "msg type is " & TypeName(msg)
WScript.Echo msg
f.Write(msg)
f.Close
'--------------------------------------------------------------------------=
------------------------ Tag: t Tag: 204540
Boxes appear instead of text when appending to a file.
Hi All,
I'm new to vbscripting and have an issue which I just can't figure
out. I'm hoping somebody here can set me straight.
My Dilemma,
When Appending to a text fil via my script, the text shows up as boxes
in Notepad instead of text. If I copy the text to MSWord or Excel i
see what looks like boxes and other crazy characters. Funny thing is
that when I write to the text file, I have no issues, the text comes
out clean. I'm sure it's my code that is jacked up, so please do fix
her up if you see a problem. I've also attempted specifying the format
as ASCII and get the same result.
Here's what I see in the text file
=E2=B5=84=E4=B5=81=C2=B5=C2=A5=E4=B1=93=E2=B5=83=E4=B1=82=E3=80=B0=E0=A4=B1=
=C5=BE=C2=BA=C3=87=C3=85=C2=AB@=C5=93=C2=AB=E3=8C=89=E3=88=AF=E2=BC=B9=E3=
=80=B2=E3=9C=B0=E3=8C=A0=E3=94=BA=E3=A8=B9=E3=A4=B0=E2=80=9A=E2=80=B9=E0=B5=
=8D
Here's my script, you'll notice this is an HTA so the interesting
section should be between <script Language=3D"VBScript"> and </script>
TIA
<head>
<title>Policy</title>
<HTA:APPLICATION
ID=3D"Policy"
APPLICATIONNAME=3D"Policy"
SCROLL=3D"yes"
SINGLEINSTANCE=3D"yes"
WINDOWSTATE=3D"normal"
>
</head>
<script language=3D"VBScript">
Option Explicit
Const USER_PROFILE =3D &H28&
Const ForReading =3D 1
Const ForWriting =3D 2
Const ForAppending =3D 8
Dim PolicyTextPath, PolicyFolderPath, PolicyUsername,
PolicyReportingPath, PolicyReportingTextPath, PolicyFileName,
PolicyReportingobjFile, _
PolicyTextobjFile, PolicyobjFSO, Policyarrcommands, PolicyobjNetwork,
PolicyobjFolderItem, PolicyobjShell, PolicyobjFolder,
PolicyobjComputer, _
objPolicyFSO, objPolicyFile, PolicyContents, TextstrWordList,
TextstrSearchWord, ReportingstrWordList, ReportingstrSearchWord,
PolicyReportingText, PolicyText
Set PolicyobjFSO =3D CreateObject("Scripting.FileSystemObject")
Set PolicyobjNetwork =3D CreateObject("Wscript.Network")
Set PolicyobjShell =3D CreateObject("Shell.Application")
Set PolicyobjFolder =3D PolicyobjShell.Namespace(USER_PROFILE)
Set PolicyobjFolderItem =3D PolicyobjFolder.Self
Set PolicyobjComputer =3D CreateObject("Shell.LocalMachine")
Set PolicyobjShell =3D CreateObject("Shell.Application")
'Wscript.Echo PolicyobjFolderItem.Path
PolicyReportingPath =3D "\\blabkup\softwaredeployment\policies\Reporting
\"
PolicyFolderPath =3D PolicyobjFolderItem.Path & "\policy"
PolicyUsername =3D PolicyobjNetwork.Username
Sub Window_onLoad
Policyarrcommands =3D Split(Policy.commandLine, chr(34))
PolicyFileName =3D Policyarrcommands(3)
PolicyTextPath =3D PolicyobjFolderItem.Path & "\policy\" &
PolicyFileName & ".txt"
PolicyReportingTextPath =3D PolicyReportingPath & PolicyFileName &
"=2Etxt"
Call PolicyPath
End Sub
'=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Sub PolicyPath
Dim PolicyPath
PolicyPath =3D "\\blabkup\softwaredeployment\policies\Policy\" &
PolicyFileName & ".txt"
Set objPolicyFSO =3D CreateObject("Scripting.FileSystemObject")
Set objPolicyFile =3D objPolicyFSO.OpenTextFile _
(Policypath, ForReading)
PolicyContents =3D objPolicyFile.ReadAll
objPolicyFile.Close
BasicTextArea.value =3D PolicyContents
End Sub
'=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Sub CheckBox
If Checkbox1.Checked Then
Msgbox "By selecting the (I Agree) checkbox you agree to
the policy listed and it's contents."
Call FolderExist
End If
If Checkbox2.Checked Then
Msgbox "You selected (I Do Not Agree), you will continue to
be prompted to accept this policy" _
& vbcrlf & "as it is a business policy which needs to be accepted."
Call Cancel
End If
End Sub
'=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Sub FolderExist
If PolicyobjFSO.FolderExists(PolicyFolderPath) Then
Set PolicyobjFolder =3D PolicyobjFSO.GetFolder(PolicyFolderPath)
If PolicyobjFSO.FileExists(PolicyTextPath) Then
Set PolicyobjFolder =3D PolicyobjFSO.GetFile(PolicyTextPath)
Call TextFileWrite
Else
Call TextFileCreate
End If
'If PolicyobjFSO.FileExists(PolicyReportingTextPath) Then
' Set PolicyobjFolder =3D
PolicyobjFSO.GetFile(PolicyReportingTextPath)
' Call ReportingTextFileWrite
'Else
' Call ReportingTextFileCreate
'End If
Else
Set PolicyobjFolder =3D PolicyobjFSO.CreateFolder(PolicyFolderPath)
Call TextFileCreate
End If
End Sub
'=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Sub TextFileCreate
Set PolicyTextobjFile =3D PolicyobjFSO.CreateTextFile(PolicyTextPath,
ForWriting, True)
'PolicyTextobjFile.writeline "Created " & Now
PolicyTextobjFile.Close
Set PolicyTextobjFile =3D Nothing
Call TextFileWrite
End Sub
'=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Sub ReportingTextFileCreate
Set PolicyReportingobjFile =3D
PolicyobjFSO.CreateTextFile(PolicyReportingTextPath, ForWriting,
True)
'PolicyReportingobjFile.writeline "Created " & Now
PolicyReportingobjFile.Close
Set PolicyReportingobjFile =3D Nothing
Call ReportingTextFileWrite
End Sub
'=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Sub TextFileWrite
Set PolicyTextobjFile =3D PolicyobjFSO.OpenTextFile (PolicyTextPath,
ForReading)
TextstrWordList =3D PolicyTextobjFile.ReadAll
PolicyTextobjFile.Close
TextstrSearchWord =3D PolicyobjComputer.machinename & vbtab &
PolicyUsername
If InStr(TextstrWordList, TextstrSearchWord) =3D 0 Then
Set PolicyTextobjFile =3D PolicyobjFSO.OpenTextFile
(PolicyTextPath, ForAppending)
PolicyTextobjFile.Writeline PolicyobjComputer.MachineName & vbtab
& PolicyUsername & vbtab & Now
msgbox PolicyobjComputer.MachineName & vbtab & PolicyUsername &
vbtab & Now
PolicyTextobjFile.Close
End If
If PolicyobjFSO.FileExists(PolicyReportingTextPath) Then
Set PolicyobjFolder =3D PolicyobjFSO.GetFile(PolicyReportingTextPath)
Call ReportingTextFileWrite
Else
Call ReportingTextFileCreate
End If
Set PolicyTextobjFile =3D Nothing
Call ReportingTextFileWrite
End Sub
'=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Sub ReportingTextFileWrite
Set PolicyReportingobjFile =3D PolicyobjFSO.OpenTextFile
(PolicyReportingTextPath, ForReading)
ReportingstrWordList =3D PolicyReportingobjFile.ReadAll
PolicyReportingobjFile.Close
ReportingstrSearchWord =3D PolicyobjComputer.machinename & vbtab &
PolicyUsername
If InStr(ReportingstrWordList, ReportingstrSearchWord) =3D 0 Then
Set PolicyReportingobjFile =3D PolicyobjFSO.OpenTextFile
(PolicyReportingTextPath, ForAppending)
PolicyReportingobjFile.WriteLine PolicyobjComputer.machinename &
vbtab & PolicyUsername & vbtab & Now
'msgbox PolicyobjComputer.machinename
PolicyReportingobjFile.Close
End If
Set PolicyReportingobjFile =3D Nothing
Call Cancel
End Sub
'=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Sub Cancel
Set PolicyobjFSO =3D Nothing
Set PolicyobjNetwork =3D Nothing
Set PolicyobjShell =3D Nothing
Set PolicyobjFolder =3D Nothing
Set PolicyobjFolderItem =3D Nothing
Set PolicyobjComputer =3D Nothing
Set PolicyobjShell =3D Nothing
Self.Close
End Sub
'=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
</script>
<body TEXT=3D#000000 STYLE=3D"font:14 pt arial; color:Black;
filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=3D1, StartColorStr=3D'#000000', EndColorStr=3D'#FF9933')">
<Table ALIGN=3DCenter>
<textarea name=3D"BasicTextArea" rows=3D"25" cols=3D"75"></textarea>
</Table>
<TABLE ALIGN=3DRIGHT>
<input type=3D"checkbox" name=3D"Checkbox1"> I Agree<br>
<input type=3D"checkbox" name=3D"Checkbox2"> I Do Not Agree<p>
<input id=3Drunbutton class=3D"button" type=3D"button" value=3D"OK"
name=3D"run_button" onClick=3D"CheckBox">
<input id=3Drunbutton class=3D"button" type=3D"button" value=3D"Cancel"
name=3D "Cancel_Button" onClick=3D"Cancel">
</Table>
</body> Tag: t Tag: 204539
Context Menu ADUC check to see if more that one user is selected
I have added a context menu to Users in ADUC. This menu launches an
application but it should only do so if one user is selected. I am
struggling with the code to check if more than one user is selected.
Any ideas are much appreciated.
Thanks
Dallas Tag: t Tag: 204538
Finding multipe cases that are true
Hi,
I know I read about this somewhere, but I just can't find it again.
I am trying to write a script that will transfer data from a CSV file
to an Excel spreadsheet. The data has to do with the status of trouble
tickets. There can be any one of five different statuses for each
tech. There could be one or five or none. the data looks like this;
"Problem ID +","Assignee ","Status","D/T Reported +"
"PRB000007683094","joe.tech","New","3/30/2007 9:00:30 AM"
"PRB000007663668","joe.tech","Service Restored","3/23/2007 8:25:40 AM"
"PRB000007671182","dan.man","In Progress","3/26/2007 7:24:33 PM"
"PRB000007618787","dan.man","Service Restored","3/7/2007 10:50:10 AM"
"PRB000007671271","dan.man","Service Restored","3/26/2007 9:47:17 PM"
"PRB000007680738","dan.man","Service Restored","3/29/2007 11:50:54 AM"
"PRB000007652289","dan.man","Service Restored","3/19/2007 6:36:24 PM"
"PRB000007667099","dan.man","Service Restored","3/25/2007 3:48:01 AM"
"PRB000007489048","freebird","Pending","1/18/2007 12:30:31 PM"
"PRB000007621881","black.hat","Service Restored","3/8/2007 9:10:14 AM"
"PRB000007612876","jarhead","On Hold","3/5/2007 3:35:12 PM"
"PRB000007613512","jarhead","Service Restored","3/5/2007 6:00:28 PM"
If id do an If Then Else statement I only get one type, if I do a
Select case statement I get one type. How can I get each of them into
its proper place? Tag: t Tag: 204536
Parsing Script Help
I need to create a parsing script, but it has been a long time since
I've done any scripting that I need a major refresher. Here is what I
need from the script:
1. Read an IDX file (large text file from an AS400/iSeries)
2. Capture the characters 1-16 and 17-32 as separate variables (Lets
call them A and B)
3. Compare A and B to see if they are identical, if they are ignore
them, if they aren't prepare them for output
This is only the first part of a bigger process. What is happening
is...Imagine you have an account at a bank (A). For each account you
can have an additional sub account, like multiple savings, checking,
vacation, car loan, etc... and each of these would be identified by
their own number in field B. If you only have one account A will
always equal B, but if you have multiple accounts A will never equal
B. So I need to know which set of A's and B's don't equal.
Once I have that information I will need to compare it with another
file to make sure that the B value belongs to the A value. So back to
our example I want to make sure John Doe's checking account belongs to
John Doe and not John Smith. For right now All I need help with is
the separating the data relevant to what I need.
Thank you. Tag: t Tag: 204533
Re: [ann] Using an HTA as a dialog for an HTA...
Please make a test to the following link :
http://groups.google.com/group/microsoft.public.fr.scripting/browse_thread/thread/845329491e365fc/a4e92bb90cb6c58f?lnk=st&q=+group%3A*.scripting+author%3AJean+-+JMST&rnum=12#a4e92bb90cb6c58f
Tsakalidis G. Evangelos
Serres / Greece
"mr_unreliable" <kindlyReplyToNewsgroup@notmail.com> wrote in message
news:eHKIHrkaHHA.1508@TK2MSFTNGP06.phx.gbl...
> From-time-to-time one sees quibbles posted in the
> wsh/vbs ng's, concerning various inconveniences and/or
> inadequacies of the "usual suspects" for dialogs, (e.g.,
> msgboxes, showModalDialog, showModelessDialog, etc).
>
> HTA's are generally considered more flexible than the above,
> but using an hta as a dialog is problematical, especially if
> you want to communicate with it. And so, enter the
> _"wshGetHTADocObject"_ utility, which does just that.
>
> The wshGetHTADocObject is an actX object, which does just
> what its name suggests. Once you have the doc object, then
> you can interface with the hta's elements and events. Granted,
> this is no different than interfacing with an instance if
> Internet Explorer, except that you don't have to deal with
> those petty annoyances involved with using IE as a dialog.
>
> The (c++) code for this actX object was provided by KB249232.
> However, I found something much more useful. Eduardo Anthony
> Morcillo, (a.k.a., "Edanmo") converted microsoft's c++ code
> into vb.net, and posted it here:
>
> http://www.mvps.org/emorcillo/en/code/inet/iedom.shtml
>
> I converted Edanmo's code from vb.net to vb5, so that I could
> compile it with microsoft's (free, but subsequently abandoned)
> vb5cce compiler.
>
> The attachment includes the source code, the compiled actX
> object (an ocx), an hta mini app plus an hta child dialog.
> It then occurs that one may also use hta's as dialogs from
> a normal script, so an example of that is included too.
>
> Reqirements: in order to use the ocx, you will have to register
> it. Also, you will need the vb5 runtimes (which I understand
> do not come with winVista, but are still available for
> downloading from msdn). Finally, you will need the oleacc.dll.
> This one is not very familiar, it comes with the "accessability"
> package. My own (ancient) system dates back to the last century,
> and it does have oleacc.dll already installed. But if your own
> system does not, then get out your trusty installation CD, and
> bring up your installer, and look for the "accessability" package.
>
> cheers, jw
> Tag: t Tag: 204532
Windows Scripting (WSH) Filetypes...
Hello, Folks!
I know that .VBS and .JS are used as just straight scripting filetypes
that can be run by CScript.exe or WScript.exe. I, also, know
that .WSF files are XML-based scripting files where you can have VBS
and / or JS sections mixed together (not sure if this is run through
WScript, CScript, or both). I have read that a .WSH file is a "Window
Scripting Host Settings file" but I have never seen any examples of it
being used.
Does anyone have any practical examples of using a .WSH file?
TIA... Tag: t Tag: 204526
force a script to resume before it is ready
Can I be Helped???
This is part of my FTP script that connects to multiple Computers (as
determined by a machine.txt file) and retrieves a file from each
computer with all having the same name. The script then renames that
file to the computer name, date and time.
My problem is when one of the computers is not available, the script
hangs while attempting to get that file then errors out because it is
trying to rename a file that does not exist.
I know that you can use "on error resume next" with regard to renaming
a file that does not exist,
but I would still like to make it continue after only a few seconds.
My questions;
Can you tell it to "On error resume next" say after only 3 or 4
seconds.
or can I tell it "On error to Cleanup files" and goto Next to
continue
loop.
Thanks so much,
Cisco
'__________________________________________________
' now run the FTP batch file created above
' create a shell and run the batch file
'_________________________________________________
Set oShell = WScript.CreateObject ("WSCript.shell")
oShell.run strFTPBat,0,TRUE
Set oShell = Nothing
'_____________________________________
'Cleanup files
'_______________________________________
fso.DeleteFile strFTPBat,1
fso.DeleteFile strResponseFile,1
'______________________________________________
'Rename the Files
'_____________________________________________
set fso = createobject("scripting.filesystemobject")
set file = fso.getfile("machine.ini")
mybase = fso.getbasename(file.name)
myext = fso.getextensionname(file.name)
mysuffix = replace(formatdatetime(now(),vbShortdate),"/","-")
mytime = replace(formatdatetime(now(),vbLongTime),":","-")
file.name = mybase & strFtpHost & "-" & mysuffix & "-" & mytime & "."
& myext
'file.name = mybase & strFtpHost & "-" & mysuffix & "." & myext
'msgbox file.name
'______________________________________________
'Continue Loop
'_______________________________________________
Next
'____________End Of Script__________ Tag: t Tag: 204511
E-Mail on AD Group Membership Change
Hi Guys.
I am really hoping someone can help me.
Does anyone have a script or can help me with one. I need a script that i
can run once an hour that will check the Domain Admins and the Administrator
groups in AD and if any change has been made since the last check to send and
email
Thanks to anyone who can help me with this Tag: t Tag: 204508
Error Number 13 Description mismatch
I can't seem to get this script to work. After hours of looking with
no luck, maybe you guys can help me find the errors.
'define
'1.0
' ^ Version Required ^
' Plugin Script
' Designed and Scripted By:
Sub define_Event_Load()
End Sub
'// Fires when the bot executes.
Sub define_Event_LoadDisplay()
End Sub
'// Fires when a user on battle.net talks.
Sub define_Event_UserTalk(Username, Flags, Message, Ping)
if Left(LCase(Message),7) = BotVars.Trigger & "define" then
GetDBEntry Username, myAccess, myFlags
VetoThisMessage()
if instr(myFlags, getAccess("definition")) <> 0 then
if len(Message) < 9 then
call handleText(username, "Supply a word to be defined.", ping)
else
call define(mid(Message, 9), username, ping)
end if
end if
end if
End Sub
Sub define_Event_PressedEnter(Text)
call define_event_userTalk(BotVars.username, 0, Text, -4)
End Sub
Sub define_Event_WhisperFromUser(Username, Flags, Message)
call define_Event_UserTalk(BotVars.Username, 0, Message, -3)
End Sub
Sub define(word, user, mode)
if lcase(word) = "warlock" or lcase(word) = "w_a_r_l_o_c_k" then
call handleText(user, word & ": God's gift to warcraft.", mode)
exit sub
end if
if lcase(word) = "coke" or lcase(word) = "cold_cherrycoke" then
call handleText(user, word & ": See Noob.", mode)
exit sub
end if
if lcase(word) = "noob" then
call handleText(user, word & ": Person that sucks balls at video
games like warcraft.", mode)
exit sub
end if
if ScINet.stillExecuting then
call handleText(user, "The bot is busy... wait a few seconds and
try again.", mode)
exit sub
end if
content = InetOpen("http://dictionary.reference.com/search?q="&word)
if instr(content, "No entry found for") <> 0 then
call defUrban(word, user, mode)
exit sub
end if
data = split(content, "<LI TYPE=""a"">")
if ubound(data) = 0 then
info = split(content, "<DD>")
if ubound(info) > 3 then
for i=1 to ubound(info)
newdef = mid(info(i), 1, instr(info(i), "<")-1)
call displayText(i & ": " & newdef, " ", BotVars.Username, 1)
next
else
for i=1 to ubound(info)
newdef = mid(info(i), 1, instr(info(i), "<")-1)
call displayText(i & ": " & newdef, " ", BotVars.Username, 1)
next
end if
if ubound(info) = 0 then
call defUrban(word, user, mode)
end if
exit sub
end if
'else if ubound(data) > 0, when there is a list of definitions...
if ubound(data) > 3 then
call handleText(user, "Found " & ubound(data) & " entries for "&
word & ". Here are three.", mode)
for i=1 to 3
newdef = mid(data(i), 1, instr(data(i), "<")-2)
call displayText(i &": " & newdef, " ", BotVars.Username, 1)
next
else
for i=1 to ubound(data)
newdef = mid(data(i), 1, instr(data(i), "<")-2)
call displayText(i & ": " & newdef, " ", BotVars.Username, 1)
next
end if
End Sub
Sub defUrban(word, user, mode)
if ScINet.stillExecuting then
call handleText(user, "The bot is busy... wait a few seconds and
try again.", mode)
exit sub
end if
content = InetOpen("http://www.urbandictionary.com/define.php?
term="&word)
if instr(content, "is undefined") <> 0 then
call handleText(user, "Failed to find a definition using both a
dictionary and an urban dictionary.", mode)
exit sub
end if
defArray = split(content, "<div class=""def_p"">")
if ubound(defArray) = 0 then
call handleText(user, "Failed to find a definition using both a
dictionary and an urban dictionary.", mode)
exit sub
end if
defcount = 0
found = false
for i=1 to ubound(defArray)
if instr(defArray(i), "1.") = 0 then
found = true
def = mid(defArray(i), instr(defArray(i), "<p>"))
def = mid(def, 1, instr(def, "</p>")-1)
def = replace(def, """, "")
'addchat vbyellow, def
while instr(def, "<") <> 0
pos1 = instr(def, "<")
pos2 = instr(def, ">")
temp = mid(def, pos1, pos2-pos1+1)
def = replace(def, temp, "")
wend
addchat vbred, len(def)
def = replace(def, " ", " ")
def = replace(def, vbnewline, "")
def = replace(def, vbtab, "")
def = replace(def, cr, "")
def = replace(def, lf, "")
def = replace(def, ctlf, "")
def = replace(def, " ", " ")
call displayText(word & ": " & def, " ", BotVars.Username, 1)
defcount = defcount + 1
if defcount = 1 then exit sub
end if
next
if found = false then call handleText(user, "Definition exists on
urban dictionary, but not on dictionary.com - Definition could not be
displayed.", mode)
End Sub Tag: t Tag: 204494
Operating system question
Ok, so I know this has to be a fairly easy vbs, but I'm looking to gather 2
requirements: First I need to know the Product key on all my PC's on the
network (2000 and XP). Secondly, I would like to also check to see if it is a
Dell PC. I would like all of this info to be sent to a text doc that I can
come back to and look over.
Thoughts? Tag: t Tag: 204490
ADSI - Uncheck recipient update policy checkbox
Hello all,
I have written a script that creates userobjects in Active Directory using
ADSI. When a user is created, and I take a look on the tab E-Mail Addresses
in the Active Directory Users and Computers snap-in, the checkbox
"Automatically update e-mail addresses based on recipient policy" is checked.
I want to uncheck this checkbox, but I cannot find out how to do this.
Does anybody know a method to disable the checkbox from a script?
Many thanks in advance. Tag: t Tag: 204480
vbscript security
Hello,
we have a very big environment (600 DC, 16.000 ws) and we are making most of
the admin related tasks automatically by using scripts. In our scripts, we
have to write a domain admin account name and its password. We are using
lsrunase.exe utility and conerting our script into exe. Most of the security
people say this way is not secure. Is there any other way to make our
scripts much more secure?
Thanik in advance.
Atilla Gultekin. Tag: t Tag: 204476
determine how much ram
Is it possible to use vbscript and wmi on a bunch of 2k machines to
determine
-how many memory slots are on the main board
-how much memory is in each memory slot
Thanks, Jeremy Tag: t Tag: 204467
open CD drive properties panel
Hi all. Anyone know how I can open the CD drive property panel? I want
to duplicate what happens when you right click on the drive and select
properties. Tag: t Tag: 204465
Error Handling
My vbscript runs through a list of computers and performs a check. On a few
computers I get the following
Error: Permission denied: 'Get Object'
Code: 800A0046
Errors on this: Set oRegistry =
GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer &
"/root/default:StdRegProv")
I have On Error Resume Next in my script, however, then this error is
encountered it is retaining the values from the last successful check. I
need to be able to skip over this and not retain the previous value. Tag: t Tag: 204457
MapNetwork drive
Hello
I'm currently mapping a network in my script, but what if that drive is not
onlone for some reason. How can I tell, so I can take the appropriate
action? Will that method return something I can branch off of?
Thanks Tag: t Tag: 204455
How to save an XML doc to a variable?
I can load a XML document from a VBScript variable, perform some modifications but when I try to
save the updated XML document to a variable using the save() method, it does not work since this
method does not output to a variable;
Dim XMLDoc, xmlString
Set XMLDoc = CreateObject("msxml2.domdocument")
XMLDoc.async = vbFalse
XMLDoc.loadXML("<?xml version=""1.0""?><test>data</test>")
'
' code to add/update elements in XMLDoc
'
XMLDoc.save(xmlString)
I looked at the WriteTo() and WriteContentTo() methods as well but they do not store in a variable.
How can I save the updated XML document to a vbscript variable?
Thanks. Tag: t Tag: 204449
Run As command from inside batch file
From inside my batch file I need to run an application as a different user,
similar to the Run As command from the desktop. I'm currently using a DOS
Batch file but could use a vbscript batch as well.
Is there a way to exexcute a file from a batch file as a different user?
My current solution is using a Scheduled Task that is configured to run as a
different user and then I run that Task from the batch file.
schtasks /run /tn wbp04324_filecopy
I'd like to avoid using the Scheduled Task if I can call it directly.
Thanks, -phil
--
no place like 127.0.0.1 Tag: t Tag: 204448