checking response from readline
hi,
I have the following code which asks user a question and gets response. I
need to check response for validity but the following if statement is always
evaluated as true even when correct response is entered:
wscript.stdout.write "What is the SOURCE file type? (user/computer/group): "
strSourceFileType = trim(ucase(wscript.stdin.readline))
if strSourceFileType <> "user" or strSourceFileType <> "computer" or
strSourceFileType <> "group" then
err.raise 449
ErrHandler
end if
Even when I enter "user" or "computer" or "group" (without quotes) at the
prompt the condition evaluates as true and returns "Microsoft VBScript
runtime error: Argument not optional"
I have witten value of strsourcefiletype to screen and it is populated
correctly with no spaces, etc. as expected by the condition right after it is
read. Now if i simply specify:
if strSourceFileType <> "user" then
without the other two OR conditions and type "user" at the prompt all works
fine. I don't understand why I cannot look for the other values in the field
too. ???
thanks again. Tag: HTA to create AD user account and mailbox Tag: 203280
reading a file that has null or blank field
hi,
when reading through a CSV file and a field is missing I receive a run time
error. I have the on error resume next commented out for now during
debugging. But, how do I handle if a field is missing when trying to assign
the array? In this case would missing mean "NULL"? The code is as follows:
set objFSO = CreateObject("Scripting.FileSystemObject")
set objSourceFile = objFSO.OpenTextFile(strSourceFilename, ForReading)
if err <> 0 then ErrHandler
do until objSourceFile.AtEndOfStream
arySourceFields = split(objSourceFile.ReadLine,",",-1,1)
if err <> 0 then ErrHandler
wscript.stdout.write arySourceFields(0) '''remove.
loop
.
.
.
Example of csv file contents:
500,world,1,1,5
501,now,2,6,0
.
.
.
600,,,
601
the problem occurs for records like 601 above. notice there are no commas
seperating other fields. the csv just has first field and nothing in
remaining fields like rest of records. Code works fine for all other
instances including 600,,,
Assigning arySourceFields(x) to any variable or simply doing the
stdout.write above causes runtime of:
createfiles.vbs(102,1) Microsoft VBScript runtime error: Subscript out of
range: 'wscript.stdout'
How do I prevent the error from occuring in my code without the on error
resume next? Isn't there a function that would check to see if the subject
is valid?
Thank you. Tag: HTA to create AD user account and mailbox Tag: 203279
I am having a problem with a logon script using VBscript trying to
the computer name to the organizational unit in which it belongs.
Dim objSystemInfo, objNetwork, CurrentComputer
Dim strOu
Const OrgUnit = "OU=PCBMRDD"
Set objSystemInfo = CreateObject("ADSystemInfo")
Set CurrentComputer = GetObject("LDAP://" & objSystemInfo.ComputerName)
strOu = (Join(CurrentComputer.MemberOf))
If InStr(strOu, (OrgUnit)) Then
WScript.Echo "Hello"
End if
Wscript.Echo "Not found"
WScript.Quit
I am trying to use the computername of the PC and compare it to which
organizational unit belongs to. I am then going to map a drive based on the
organizational unit the PC belongs to and map it to a specific location.
When using the Echo statement after the GetObject statement I am able to
display all the active directory information for the ComputerName. When I
compile the code it will not check to see whether the computer name belongs
to a specific organizational unit. Tag: HTA to create AD user account and mailbox Tag: 203276
check if file open
hi,
I have the following code that writes to a text file.
set objDestinationFile = objFSO.CreateTextFile(strDestinationFilename,true)
.
.
.
objDestinationFile.WriteLine FileTypeVal & "," & FileTypeVal
After I write lines to the file and when a field changes I need to close the
file and create a new one for writing. How do I check to see if the file is
open by my code so that I can issue a close? If it isn't open I don't want
to close it, I just want to create new file. The only time it wouldn't be
open is the first time the script executes. Would doing the following
accomplish my goals and be correct?
if isobject(objDestinationFile) then objDestinationFile.Close
After I issue close do I need to set the object variable to nothing or can I
simply issue above set again.
thanks alot Tag: HTA to create AD user account and mailbox Tag: 203275
move users from AD
I amusing thhis script On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set objFileIP= FSO.OpenTextFile(".\IP_Users_Groups.txt", 1)
Set objFileOP = FSO.opentextfile(".\OP_Users_Groups.txt",2,True,-2)
Const ADS_PROPERTY_DELETE = 4
Do While objFileIP.AtEndOfStream = False
username,grpname =(objFileIP.ReadLine)
Set objGroup = GetObject _
("LDAP://CN=" & (grpname) &
",OU=Dept_Grps,ou=cam,ou=im,dc=nam,dc=nsroot,dc=net")
objGroup.PutEx ADS_PROPERTY_DELETE, _
"member",Array("CN=" & (username) &
",OU=Dept_Grps,ou=cam,ou=im,dc=nam,dc=nsroot,dc=net")
objGroup.SetInfo
Loop
WScript.Echo username & grpname
'**************************************************************************
objfileip.close
objfileop.close
WScript.Quit
My problem is there will be different users anf group, will the following
work
Do While objFileIP.AtEndOfStream = False
username,grpname =(objFileIP.ReadLine)
I will have a text file with username, groupname - how will the LDAP know
where to go. Do I use teo text files instaed of one? Tag: HTA to create AD user account and mailbox Tag: 203272
Ad Disable Accounts
We are in the need for a script that will search a dump .xls file and
disable AD accounts. Can any one please help on this.
Thanks Tag: HTA to create AD user account and mailbox Tag: 203270
Deactivating the User must change password on next logon
Hi guys!
Would really appreciate your help.
We have an AD 2003 domain setup, similar to below.
topleveldomain.com
Retail OU
Brand1 OU
Store0001 OU
Users OU
User accounts in here
0001user
bob
jane
Store0002 OU
Users OU
User accounts in here
Store0003 OU
Users OU
User accounts in here
Brand2 OU
Store0001 OU
Users OU
User accounts in here
What we need to do quickly is the following:
Query AD for all user accounts that dont start with the numbers, in the
Users OU of every StoreXXXX OU in the Brand1 OU only, not the Brand 2 OU
Query these user accounts to see if the property "User must change password
on next logon" is checked.
If it is checked, we need the vbs script to uncheck it for every user
account in the OU.
Any help greatly appreciated.
x Tag: HTA to create AD user account and mailbox Tag: 203261
XML, VBScript, and HTA royal rumble
I just started working with XML. However, I have been working with
HTAs and VBScripts for a while now. I am building an HTA that would
generate data into an XML file, and display it in a Data Island (which
I found is the easiest way to display it in this case.. since there
would an X number of data sources, with the same XML format). The
problems came when I had to filter the XML data to show only a certain
criteria. I could not embed XQuery code into the document as I am not
sure if there is a way to get the XQuery and Data Island to work
together to produce only a limited record set in the output table.
I then started looking at multidimensional array sorting and class
creation and sorting, I felt as though my mind was frying. XQuery
seems much easier but there was no easy way to use it since the Data
Island itself is a dynamic table with a dynamic data source spanning
different data types.
I thought probably the best way to achieve a filtered XML would be to
obtain a XQuery application (a small portable parser) that would run
against the original XML file producing a newer modified XML with the
needed data. I could not find such an application.
Has anyone got an efficient solution to such a problem? Thank you for
your time.
- Nasser Tag: HTA to create AD user account and mailbox Tag: 203260
Obtain User SID from AD
I need to obtain the User's SID's out of AD, but my script exits the loop
after the echo statement during the first loop thru and doesn't return and
presents a exit code of '0', which is success (which its not).
Any other ideas??
I obtained the following code from:
http://msdn2.microsoft.com/en-us/library/aa746535.aspx and
http://msdn2.microsoft.com/en-us/library/aa746409.aspx
Set objUser = GetObject("WinNT://" & strFQ_DomainName & "/" &
objRecordSet.Fields("sAMAccountName"))
arrUserSID = objUser.Get("ObjectSID")
intElements = UBound(arrUserSID)
Wscript.echo intElements ---> outputs 27, which is correct
For intCounter = 0 to intElements
wscript.echo "Loop: " & intCounter
strUserSID = arrUserSID(intCounter)
Next Tag: HTA to create AD user account and mailbox Tag: 203257
how to update binary field types in ADO
Hi,
Having some difficulties updating binary fields. This bit of code
seems to work fine in VB6, but when I make the minor changes necessary
for it to run in VBscript the Update never happens.
In fact the assigment to fld.Value doesn't appear to happen since
msgbox fld.Value(0) after the assignment does nothing. Is this
something that is beyong the capabilities of VBscript?
Thank You!
Dim arrBin(7) As Byte
Dim b As Integer
Dim strBin As String
strBin = "bintest"
For b = 1 To 7
arrBin(b - 1) = Asc(Mid(strBin, b, 1))
Next
While Not oRs.EOF
For Each fld In oRs.Fields
lngtype = fld.Type
Select Case lngtype
Case adBinary, adVarBinary, adLongVarBinary
fld.Value = arrBin
oRs.Update
End Select
Next
oRs.MoveNext
Wend Tag: HTA to create AD user account and mailbox Tag: 203254
SMS componets
Are there any components for VBScript that will allow me to send an sms
message?
Thank you,
Matthew Tag: HTA to create AD user account and mailbox Tag: 203253
"Internal Error 2738" due to corrupt vbscript dll?
I'm trying to install a small program just released by Microsoft. Everytime i
get "Internal Error 2738" after setup starts. The installer log gives this
reason: "DEBUG: Error 2738: Could not access VBScript runtime for custom
action". Can anyone say more? No one else seems to have this problem
installing the app, so i think it must be on my machine alone. How do i check
access or run a reinstall of the "vbscript runtime"? Is that a .dll that's
somehow corrupted? Tag: HTA to create AD user account and mailbox Tag: 203250
Looping...
I am looking for a way to pause a LOOP long enough to display the results
before moving on to the next go around. In the immediate window I can see
the results are there, just happening to fast to see results in form. Tag: HTA to create AD user account and mailbox Tag: 203249
OBD Explorer
HTA application , logic in VBScript
Make OBD acquisition from car with mobydic interface. Works in debug mode
without the interface ;)
Environnemetn : Internet Explorer in HTA mode, VBScript and REALTERM a
terminal software
It 's an exemple of data acquistion over serial protocol in VBScript
Using ActiveX/COM , WSH for disk access, XML for saving results SVG for
display it
http://perso.orange.fr/promethee60/data/technos/obd/OBDExplorer.html
IE is Great !! Tag: HTA to create AD user account and mailbox Tag: 203248
connecting to NON-Microsoft LDAP
I'm trying to connect to a NON-Microsoft LDAP server.
Has anyone been able to connect to a NON-Microsoft LDAP coding in
vbscript and using ADSI?
I sure do appreciate your response to this. Tag: HTA to create AD user account and mailbox Tag: 203247
Where to start with vbscript?
Hi all,
I've been given a small fairly trivial project to automatically
perform some operations on a spreadsheet like calculate days from
dates and create charts. I've figured vbscript is a good option, I've
seen code snippets that can get me most of what I need, but I'm
wondering where there is say an API or some sort of users guid that
will provide me with the info I need when I come across problems.
Thanks
Lionel. Tag: HTA to create AD user account and mailbox Tag: 203246
Script Editor
Does anyone know of a VB Script Editor/Debugger that is similar to
VBSEdit? I purchased VBSEdit and it crashed. I can't get their tech
people to respond to emails and I'm ready to move on to something else. Tag: HTA to create AD user account and mailbox Tag: 203239
read user name and group from one text file.
I have to remove different users and groups reading one file. I know how to
do it with one but not both user and group.
Can someone help me Tag: HTA to create AD user account and mailbox Tag: 203236
ipaddress
How can I grab just the first three oectets of a ipaddress? Regualar
expression...(/\d+\.\d+\.\d+\./)
For example,
10.116.189.34
after running a script I need to only have the following:
10.116.189. Tag: HTA to create AD user account and mailbox Tag: 203234
Location-based Startup Script
I would like to run a script at startup (and afeter hibernation) that
checked my location, based on the network connection I get. From that,
I would like to establish some defaults, like default printer.
I don't know much about initiating this type of script, how to
evaluate my network connection, and how to control default devices. If
someone can point mem toward some tutorial-like info, I would
appreciate it.
Thanks, Tag: HTA to create AD user account and mailbox Tag: 203224
read from excel sheet
OK I have to remove about 300 users from different groups.
Column A would have the different user names and column B would have the
different groups than I have to write the results to a txt file ot another
excel file. Tag: HTA to create AD user account and mailbox Tag: 203221
VBScript and VB6 COM object type mismatch...
Hi, Folks!
I am trying to use a to use a COM object written in VB6.
Set oSCNTool2 = CreateObject("SomeCompanyName.Tool2")
This COM object has a property called "xml" where it expects, you
guessed it, an XML string. Well, it turns out it's just expecting a
plain string and not any special XML node or what-have-you. The
problem is when I try to assign a string to this property I get a Type
Mismatch error.
oSCNTool2.xml = szXMLdata 'type mismatch error
The problem is VBScript deals in Variants and VBS strings are of the
Variant String subtype. This "xml" property is expecting the VB6
String variable type and not a Variant subtype. I do not have access
to the source code of the COM object to change it.
Does anyone know how to work around this issue?
TIA... Tag: HTA to create AD user account and mailbox Tag: 203218
Detect a scheduled script timed out.
I have a vbscript scheduled task that has the scheduled task timeout
set to 2 hours. How can I make the script aware that it is about to be
terminated? Is there a script event I can use to do this? Tag: HTA to create AD user account and mailbox Tag: 203216
browseforfolder to find file
This code:
Set oShell = CreateObject("Shell.Application")
set oFolder = oShell.BrowseForFolder(0,"Select poem",BIF_BROWSEINCLUDEFILES
+ 1,5)
Gives This Error
the system cannot find the file specified
Any thoughts???
Works great if I select a folder, dies if I select a file. works OK in VB6,
fails in VBScript
A Tag: HTA to create AD user account and mailbox Tag: 203208
Is there a limit on WMI connections from one computer?
I have some scripts which use WMI to get system info of printers, RAM,
serial no., etc...
Right now I want to use 10 copies of each script as there are about
10,000 computers I need to scan and doing the whole lot at once would
take too long, especially if I need a report overnight. So I cut them
up into 10 scripts to run at the same time, hitting 1,000 computers
each, with all 10 scripts being identical except for the computer
names and IPs they read from an excel sheet.
The issue I'm having is that there seems to be a one session limit on
WMI, so I can't run 10 scripts on one computer. The first script runs
fine, the second I run on the same computer just quits after a few
seconds (viewing task manager I see two wscripts, then it goes to
one). Is there a way around the limit, registry hack or something?
Doing a google search got me nothing on this.
Thanks for any help. Tag: HTA to create AD user account and mailbox Tag: 203207
Calling a WSH application where arguments refer to folder names that have spaces
In an HTA file I have the code shown below.
It used to run in a directory other than "My Report". The old folder
name had spaces and there were no problems.
When it runs in the "My Report" directory a message appears saying
"System can not find the file specified".
The string being sent to WSH.Run is:
C:\My%20Folder\script.vbs "C:\My Report\a.txt" "C:\My Report\b.txt"
Changing the string to
C:\My%20Folder\script.vbs ""C:\My Report\a.txt"" "C:\My Report\b.txt""
and
"C:\My%20Folder\script.vbs "C:\My Report\a.txt" "C:\My Report\b.txt" "
and
"C:\My%20Folder\script.vbs ""C:\My Report\a.txt"" ""C:\My Report
\b.txt"" "
and other permutations didn't work.
What do I need to do? Thanks.
<script language="VBScript">
Function CreateReport
File1 = "C:\My Report\a.txt"
File2 = "C:\My Report\b.txt"
Set WSH = CreateObject("WScript.Shell")
WSH.Run GetPath(document.location.pathname) & "my.vbs" & _
Chr(34) & File1 & Chr(34) & " " & _
Chr(34) & File2 & Chr(34)
Window.Close
End Function
Function GetPath(Path)
ix=InstrRev(Path,"\")
Path=Left(Path,ix)
GetPath = Path
End Function
</script> Tag: HTA to create AD user account and mailbox Tag: 203198
Moving through files in a directory
I am a newbie to VBScript, so any help is appreciated. I am trying to
move files from one location to another. I would like to look at each
file and check to see if that file is already in the destination
location. If it is in that location I would like to echo out the file
name.
Is there a way I can create an Object and go through the files one by
one? Would I try to move them all first and if I get an error
message, echo out the files and keep moving on?
Here is what I have so far, but this is a crude way of accomplishing
the task.
'MoveFSO.vbs
'Moves files from the jump drive to network shares
Option Explicit
Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "F:\class3\*.wmf" , "O:\WWW\" , OverwriteExisting
objFSO.CopyFile "F:\class3\*.jpg" , "O:\WWW\" , OverwriteExisting
objFSO.CopyFile "F:\class2\*.wmf" , "N:\WWW\" , OverwriteExisting
objFSO.CopyFile "F:\class2\*.jpg" , "N:\WWW\" , OverwriteExisting
Const DeleteReadOnly = True
objFSO.DeleteFile("F:\class3\*.wmf"), DeleteReadOnly
objFSO.DeleteFile("F:\class3\*.jpg"), DeleteReadOnly
objFSO.DeleteFile("F:\class2\*.wmf"), DeleteReadOnly
objFSO.DeleteFile("F:\class2\*.jpg"), DeleteReadOnly Tag: HTA to create AD user account and mailbox Tag: 203197
Moving through files in a directory
I am a newbie to VBScript, so any help is appreciated. I am trying to
move files from one location to another. I would like to look at each
file and check to see if that file is already in the destination
location. If it is in that location I would like to echo out the file
name and the file.
Is there a way I can create an Object and go through the files one by
one?
Here is what I have so far, but this is a crude way of accomplishing
the task.
'MoveFSO.vbs
'Moves files from the jump drive to network shares
Option Explicit
Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "F:\class3\*.wmf" , "O:\WWW\" , OverwriteExisting
objFSO.CopyFile "F:\class3\*.jpg" , "O:\WWW\" , OverwriteExisting
objFSO.CopyFile "F:\class2\*.wmf" , "N:\WWW\" , OverwriteExisting
objFSO.CopyFile "F:\class2\*.jpg" , "N:\WWW\" , OverwriteExisting
Const DeleteReadOnly = True
objFSO.DeleteFile("F:\class3\*.wmf"), DeleteReadOnly
objFSO.DeleteFile("F:\class3\*.jpg"), DeleteReadOnly
objFSO.DeleteFile("F:\class2\*.wmf"), DeleteReadOnly
objFSO.DeleteFile("F:\class2\*.jpg"), DeleteReadOnly Tag: HTA to create AD user account and mailbox Tag: 203196
WMI for Querying "Obtain DNS Server Address Automatically"
Does WMI provide any way to query whether "Obtain DNS Server Address
Automatically" is set for a NIC?
I know that you can set the value in WMI by calling SetDNSServerSearchOrder
with no parameters. So you might think that you could just query
DNSServerSearchOrder and get back something empty or null if "Obtain DNS
Server Address Automatically" is set. But actually, DNSServerSearchOrder
returns the DNS addresses that are currently assigned, so you can't tell if
they were automatically assigned or manually assigned.
Thanks for any help.
--
Joseph Morales Tag: HTA to create AD user account and mailbox Tag: 203194
Event Log Query
I've created a script that does the following:
*All output goes to a text file*
Searches through AD finding computer objects running a Server OS(using
wildcards).
Determines the disk space free on each physical drive for each machine
found.
For each machine found searches through the System and Application Log
for all error entries in the past 8 days.
Here is the script(it's not the prettiest and I know there are better
ways/methods but here it is):
Option Explicit
Dim objFSA
Dim objLogFile
Dim objFSO
Dim objLogItem
Dim objFSF
Dim objFinalLog
Dim objFSU
Dim objLog
Const ForWriting = 2
Set objFSU = CreateObject("Scripting.FileSystemObject")
Set objLog = objFSU.CreateTextFile("C:\deletefiles.vbs")
Set objFSA = CreateObject("Scripting.FileSystemObject")
Set objLogFile = objFSA.CreateTextFile("C:\tmpSrvAvail.txt")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objLogItem = objFSO.CreateTextFile("C:\tmpAllSrv.txt")
Set objFSF = CreateObject("Scripting.FileSystemObject")
Set objFinalLog = objFSF.CreateTextFile("MasterFile.txt")
objLog.Write "Set objFSL = CreateObject(" & chr(34) &
"Scripting.FileSystemObject" & chr(34) & ")"
objLog.Write vbCrlf
objLog.Write "strScript = " & chr(34) & "C:\tmpAllSrv.txt" & chr(34)
objLog.Write vbCrlf
objLog.Write "objFSL.DeleteFile(strScript)"
objLog.Write vbCrlf
objLog.Write "Set objFSM = CreateObject(" & chr(34) &
"Scripting.FileSystemObject" & chr(34) & ")"
objLog.Write vbCrlf
objLog.Write "Set objFSN = CreateObject(" & chr(34) &
"Scripting.FileSystemObject" & chr(34) & ")"
objLog.Write vbCrlf
objLog.Write "strScript = " & chr(34) & "C:\tmpSrvAvail.txt" & chr(34)
objLog.Write vbCrlf
objLog.Write "objFSL.DeleteFile(strScript)"
objLog.Write vbCrlf
objLog.Write "strScript = Wscript.ScriptFullName"
objLog.Write vbCrlf
objLog.Write "objFSN.DeleteFile(strScript)"
objFinalLog.Write "All Servers in Active Directory"
objFinalLog.Write vbCrlf
Const ADS_SCOPE_SUBTREE = 2
Dim objConnection
Dim objCommand
Dim objRecordSet
Dim strDomain
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
strDomain = "DC=dms,DC=local"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
"SELECT Name FROM 'LDAP://" & strDomain & "' WHERE
objectClass='computer' " & _
"and operatingSystem = '*Server*'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
objLogItem.Write objRecordSet.Fields("Name").Value
objLogItem.Write vbCrLf
objFinalLog.Write vbCrlf
objFinalLog.Write objRecordSet.Fields("Name").Value
objRecordSet.MoveNext
Loop
objFinalLog.Write vbCrlf
objFinalLog.Write vbCrlf
objFinalLog.Write "FREE DISK SPACE"
objFinalLog.Write vbCrlf
objFinalLog.Write vbCrlf
Dim g_strHostFile
Dim objFse
Dim objTextStream
Dim objWMIService
Dim colDisks
Dim g_strComputer
Dim objDisk
Const FOR_READING = 1
g_strHostFile = "C:\tmpAllSrv.txt"
Set objFse = CreateObject("Scripting.FileSystemObject")
If objFse.FileExists(g_strHostFile) then
Set objTextStream = objFse.OpenTextFile(g_strHostFile, FOR_READING)
Else
WScript.Echo "Computer list, " & g_strHostFile & " not found."
WScript.Quit
End If
Do Until objTextStream.AtEndOfStream
g_strComputer = objTextStream.ReadLine
On Error Resume Next
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & g_strComputer & "\root
\cimv2")
Set colDisks = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk Where DriveType = 3")
If Err = 0 Then
objLogFile.Write g_strComputer
objLogFile.Write vbCrLf
End If
Dim intFreeSpace
Dim intTotalSpace
Dim pctFreeSpace
Dim intTotalGB
Dim intFree
For Each objDisk in colDisks
intFreeSpace = objDisk.FreeSpace
intTotalSpace = objDisk.Size
pctFreeSpace = intFreeSpace / intTotalSpace
If Err <> 0 Then
objFinalLog.Write g_strComputer & " is offline, please check
manually."
objFinalLog.Write vbCrLf
objFinalLog.Write vbCrLf
Exit For
End If
intTotalGB = intTotalSpace/ 1024/ 1024/ 1024
intTotalGB = FormatNumber(intTotalGB, 1) & "GB"
If intFreeSpace < 1073741824 Then
intFree = objDisk.FreeSpace/ 1024/ 1024
Else
intFree = objDisk.FreeSpace/ 1024/ 1024/ 1024
End If
If intFreeSpace < 1073741824 Then
intFree = FormatNumber(intFree, 1) & "MB"
Else
intFree = FormatNumber(intFree, 1) & "GB"
End If
objFinalLog.Write g_strComputer & " "
objFinalLog.Write objDisk.DeviceID & " "
objFinalLog.Write intFree & " Free "
objFinalLog.Write intTotalGB & " Total "
objFinalLog.Write FormatPercent(pctFreeSpace) & " Percent Free"
objFinalLog.Write vbCrLf
objFinalLog.Write vbCrLf
Next
Loop
objTextStream.Close
Dim dtmStartDate
Dim DateToCheck
Dim colLoggedEvents
Dim objEvent
g_strHostFile = "C:\tmpSrvAvail.txt"
Set objFse = CreateObject("Scripting.FileSystemObject")
If ObjFse.FileExists(g_strHostFile) Then
Set objTextStream = objFse.OpenTextFile(g_strHostFile, FOR_READING)
Else
WScript.Echo "Computer list, " & g_strHostFile & " not found."
WScript.Quit
End If
Const CONVERT_TO_LOCAL_TIME = True
Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
DateToCheck = CDate(Date())
dtmStartDate.SetVarDate DateToCheck - 8, CONVERT_TO_LOCAL_TIME
Do Until objTextStream.AtEndOfStream
g_strComputer = objTextStream.ReadLine
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & g_strComputer & "\root
\cimv2")
Set colLoggedEvents = objWMIService.ExecQuery ("Select * From
Win32_NTLogEvent Where LogFile = 'System' AND TimeWritten >= '" &
dtmStartDate & "' AND EventType = 1")
If Err = 0 Then
objFinalLog.Write "Error Events from System Log."
objFinalLog.Write vbCrLf
End If
For Each objEvent in colLoggedEvents
If Err <> 0 Then
Exit For
End If
objFinalLog.Write g_strComputer
objFinalLog.Write vbCrLf
objFinalLog.Write "Category: " & objEvent.Category
objFinalLog.Write vbCrLf
objFinalLog.Write "Event Code: " & objEvent.EventCode
objFinalLog.Write vbCrLf
objFinalLog.Write "Message: " & objEvent.Message
objFinalLog.Write vbCrLf
objFinalLog.Write "Record Number: " & objEvent.RecordNumber
objFinalLog.Write vbCrLf
objFinalLog.Write "Source Name: " & objEvent.SourceName
objFinalLog.Write vbCrLf
objFinalLog.Write "Event Type: " & objEvent.EventType
objFinalLog.Write vbCrLf
objFinalLog.Write "Time Written: " & objEvent.TimeWritten
objFinalLog.Write vbCrLf
objFinalLog.Write vbCrLf
Next
Loop
objTextStream.Close
objFinalLog.Write VBCrLf
objFinalLog.Write VBCrLf
objFinalLog.Write "Error Events from Application Log."
g_strHostFile = "C:\tmpSrvAvail.txt"
Set objFse = CreateObject("Scripting.FileSystemObject")
If objFse.FileExists(g_strHostFile) Then
Set objTextStream = objFse.OpenTextFile(g_strHostFile, FOR_READING)
Else
WScript.Echo "Computer list, " & g_strHostFile & " not found."
WScript.Quit
End If
Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
DateToCheck = CDate(Date())
dtmStartDate.SetVarDate DateToCheck - 8, CONVERT_TO_LOCAL_TIME
Do Until objTextStream.AtEndOfStream
g_strComputer = objTextStream.ReadLine
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & g_strComputer & "\root
\cimv2")
Set colLoggedEvents = objWMIService.ExecQuery ("Select * From
Win32_NTLogEvent Where LogFile = 'Application' AND TimeWritten >= '" &
dtmStartDate & "' AND EventType = 1")
For Each objEvent in colLoggedEvents
If Err <> 0 Then
Wscript.Echo "We made it here." & g_strComputer
Exit For
End If
objFinalLog.Write vbCrLf
objFinalLog.Write g_strComputer
objFinalLog.Write vbCrLf
objFinalLog.Write "Category: " & objEvent.Category
objFinalLog.Write vbCrLf
objFinalLog.Write "Event Code: " & objEvent.EventCode
objFinalLog.Write vbCrLf
objFinalLog.Write "Message: " & objEvent.Message
objFinalLog.Write vbCrLf
objFinalLog.Write "Record Number: " & objEvent.RecordNumber
objFinalLog.Write vbCrLf
objFinalLog.Write "Source Name: " & objEvent.SourceName
objFinalLog.Write "Event Type: " & objEvent.EventType
objFinalLog.Write vbCrLf
objFinalLog.Write "Time Written: " & objEvent.TimeWritten
objFinalLog.Write vbCrLf
objFinalLog.Write vbCrLf
Next
Loop
objTextStream.Close
Wscript.Echo "Job Completed, check Master File for Output."
On Error GoTo 0
Dim objShell
Dim strDelete
Set objShell = CreateObject("Wscript.Shell")
strDelete = "C:\deletefiles.vbs"
objShell.Run(strDelete)
I was having problems deleting the files I create earlier in the
script, hence the reason my script creates another one, which deletes
the files and itself.
My problem is that I need to run this is in multiple domains, for
different clients. I do not believe this script will work correctly in
a mixed environment ie running 2003 and 2000 Server OS's, which some
of our clients have.
Can someone advise me on how to get this to work in a mixed
environment? Short of running a search on the 2000 machines, then
another on the 2003 machines. Thanks. Tag: HTA to create AD user account and mailbox Tag: 203193
Finding multiple memgers of a group
Hi,
I am working on a script that will determin if three different ID's
are in the local Administrators group on a long list of servers. I can
get my script to reliably report on ONE user, but If I try fro more
than one, I get mixed results and I can't trust the accuracy. Can
someone point me to a sample script or discussion on finding multiple
users in a group?
This script will tell me if JoeUser is a memger of the Administrators
group on a list of servers.
Option Explicit
Dim objGroup, strComputer, objFSO, objTextFile
Const ForReading = 1
On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:\Scripts\servers.txt",
ForReading)
Do Until objTextFile.AtEndOfStream
strComputer = Trim(objTextFile.Readline)
If (strComputer <> "") Then
Set objGroup = GetObject("WinNT://" & strComputer & "/
Administrators,group")
Wscript.Echo "Members of local Administrators group on computer " &
strComputer
Call EnumGroup(objGroup, "")
End If
Loop
Sub EnumGroup(objGroup, strOffset)
Dim objMember
For Each objMember In objGroup.Members
'Wscript.Echo strOffset & objMember.Name & " (" &
objMember.Class & ")"
If (objMember.Name = "JoeUser") Then
Wscript.Echo strOffset & objMember.Name & " (" &
objMember.Class & ")"
End If
Next
End Sub Tag: HTA to create AD user account and mailbox Tag: 203192
need help creating a VBS for an Excel file.
I have an Excel file with a few worksheets in it. One of those worksheets
contains data that is linked to a TXT file and another is linked to another
Excel file.
When I open the file it prompts to "Enable Automatic Refresh". I click yes,
then I get two more prompts - one for each of the links mentioned above.
Here's what I'm looking to do:
I want a script that will open that file and automatically respond (in the
affirmative) to those 3 prompts. I then want the file saved and copied into
another location - so that when the user opens it, it is more or less
"stale" data - in otherwords, it doesn't give them the option to
automatically refresh.
Is this possible? How? Help!
Thanks!
Glenn Tag: HTA to create AD user account and mailbox Tag: 203188
CDO.ReplyTo Method?
Is there a CDO.ReplyTo Method? I would like the email to be From a
NAME but I need to include an email address for them to reply to.
For instance, I do not want it to show up as FROM: email@domain.com
but rather FROM: NAME and then have them able to reply to the email.
Thanks. Tag: HTA to create AD user account and mailbox Tag: 203185
Interfacing with Exchange Address Contact List
Hi,
I have written a VBScript that takes a tab delimited file of
customer's contact information and loads it into a users contact list,
and loads into distribution lists by state. This works great. The
user runs the script, chooses the file's location, and it runs while
their outlook is open.
This is great except that it needs to be run relatively often as our
customer base grows. Is it possible to schedule a VBScript to run at
night that will run against a file and add it to specific user's
contact list? Currently, Outlook must be open and it connects to the
running account. Can i write something that does this without the
user needing to be logged in?
Thanks very much for your help. Tag: HTA to create AD user account and mailbox Tag: 203181
How to refresh the start menu?
Is there a way to script a refresh of the start menu (including Windows XP
and newer)? Iâ??m using start menu redirection and when my file share (where
the shortcuts are located) goes down and up again, I can refresh my desktop
(which is also redirected) to get my shortcuts back, but for the start menu I
have to kill and restart the explorer process, which isnâ??t the nicest way.
Surely there must be a way to refresh the start menu in another way? Tag: HTA to create AD user account and mailbox Tag: 203178
0x80041001 accessing WMI from script
Hello all,
I am trying to use a vbs script that changes alert resolution state in
MOM2005 SP1 using WMI ROOT\MOM, class MSFT_Alert. Script is here:
http://msdn2.microsoft.com/en-us/library/ms812714.aspx
For some object instances when I use command "Call objAlert.Put_" I got
error "SWbemObjectEx: Generic failure". Also when I am trying to change
resolution state value and save the object using wbemtest utility it shows me
more error data: "Number: 0x80041001, Facility: WMI, Description: Generic
failure".
For some object instances script works ok
WMIDiag from
http://www.microsoft.com/downloads/details.aspx?familyid=d7ba3cd6-18d1-4d05-b11e-4c64192ae97d&displaylang=en
says that "SUCCESS: WMIDiag determined that WMI works CORRECTLY".
I tried to update only part of an instance, but it still fails:
http://msdn2.microsoft.com/en-us/library/aa393949.aspx
Related link:
http://www.mombu.com/microsoft/mom-sdk/t-set-alert-resolution-state-put-method-fails-with-error-generic-failure-205225.html
What this error means and how to resolve the issue?
Mazhas Tag: HTA to create AD user account and mailbox Tag: 203176
Screen Refresh
Im having a hard time getting a hta application to update the screen
while processing.
>From what i have read i should be using settimeout but i can not work
out how. I must be just a dunce. The vbscript file just does a
wscript.sleep for 5 seconds while i troubleshoot this issue.
Any help will be greatfully received.
gui-report.hta
<html>
<link type="text/css" href="gui-report.css" rel="stylesheet" />
<head>
<title>GUI-Report</title>
<HTA:APPLICATION
ID="objHTAGUI-Report"
APPLICATIONNAME="HTAGUI-Report"
SCROLL="no"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
>
<OBJECT width="0" height="0" classid="clsid:
550dda30-0541-11d2-9ca9-0060b0ec3d39" id="complist" VIEWASTEXT="">
</OBJECT>
<body onload="Initialize();" onunload="Cleanup();" class="MainBody">
<script language="vbscript">
Dim fs, sh
Const sCmdString = "cscript /nologo test.vbs "
Const MaxForks = 1 'starts from zero (ie, 0 = one fork, 5 = six forks)
Const MaxRunTime = 15 ' Seconds
'wshExec
Const WshRunning = 0
Const WshFinished = 1
Sub Initialize()
Dim xmlDoc
Set xmlDoc = complist.XMLDocument
Const THESETTINGS = "C:\work\xmlreport\test.xml"
Set fs = CreateObject("Scripting.FileSystemObject")
Set sh = CreateObject("Wscript.Shell")
xmlDoc.Async=False
if fs.FileExists(THESETTINGS) Then
xmlDoc.load THESETTINGS
Else
xmlDoc.loadxml ("<?xml version=""1.0"" encoding=""utf-8"" ?
><computerlist><computer><Name>BLANK NAME</Name><Status></
Status><Reboot>0</Reboot><Enabled>-1</Enabled></computer></
computerlist>")
End If
End Sub
Sub Window_Onload
End Sub
Sub ChangePointer
If window.event.srcElement.id = "notesbuttonrun" Then
notesbuttonrun.style.cursor="hand"
ElseIf window.event.srcElement.id = "notesbutton" Then
notesbutton.style.cursor="hand"
End If
End Sub
Sub OK_OnClick
Dim xmlDoc
Set xmlDoc = complist.XMLDocument
xmlDoc.save "test.xml"
SetStatus "Saved!"
End Sub
Sub Load_OnClick
Dim fso, oFile, sHTML, sFilename, rc
Dim sLine, aLine
Dim xmlDoc, sXML
Set FSO = CreateObject("Scripting.FileSystemObject")
sFilename = FileName.Value
'on error Resume Next
Dim iLine
If FSO.FileExists(sFilename) Then
Set xmlDoc = complist.XMLDocument
Set oFile = FSO.OpenTextFile(sFilename)
sXML = "<?xml version=""1.0"" encoding=""utf-8"" ?><computerlist>"
Do Until oFile.AtEndOfStream
iLine = iLine + 1
SetStatus "Loading Line: " & iLine
sLine = oFile.ReadLine
aLine = Split(sLine, vbTab)
If Len(aLine(0)) > 0 Then
sXML = sXML & vbNewLine & "<computer><Name>" & aLine(0) & "</
Name><Status></Status><Reboot>0</Reboot><Enabled>-1</Enabled></
computer>"
End If
'
' If isArray(aLine) Then
' Else
' sXML = sXML & vbNewLine & "<name>" & TypeName(aLine) & "</
Name><Status></Status><Reboot>0</Reboot><Enabled>0</Enabled>"
' End If
Loop
oFile.Close
sXML = sXML & vbNewLine & "</computerlist>"
rc = xmlDoc.loadxml (sXML)
SetStatus "Loaded file: " & RC
Else
SetStatus "File Not Found"
End If
End Sub
Sub SetStatus(sMsg)
code.InnerHTML = "<textarea cols=100 rows=1>" & sMsg & "</textarea>"
End Sub
Sub cancel_OnClick
TheStatus.Value = "Cancel"
End Sub
Dim aThreadInfo
Dim iVal
Sub CheckBool()
SetStatus Now()
window.clearTimeout iVal
MsgBox "HH"
' iVal = window.setTimeout("CheckBool()", 100)
End Sub
Sub Process_OnClick
Call ProcessTest()
End Sub
Sub ProcessTest
Dim xmlDoc, xmlList, xmlComp
SetStatus "Processing"
Set xmlDoc = complist.XMLDocument
Set xmlList= xmlDoc.SelectNodes("computerlist/computer")
SetStatus TypeName(xmlList)
Redim aThreadInfo(MaxForks, 2)
Dim i
For i = 0 To UBound( aThreadInfo, 1)
Set aThreadInfo(i,0) = Nothing ' wshExec
aThreadInfo(i,1) = 0 ' Time
Set aThreadInfo(i,2) = Nothing ' xmlComp
Next
Dim xmlStatus, sEnabled, sCompName
' sEnabled = xmlComp.SelectSingleNode("Enabled").text
' If cBool(sEnabled) Then
' Else
' Set xmlStatus = xmlComp.SelectSingleNode("Status")
' xmlStatus.Text = "Disabled"
' End If
Dim iThread
For Each xmlComp in xmlList
iVal = window.setTimeout("CheckBool()", 100)
Set xmlStatus = xmlComp.SelectSingleNode("Status")
SetStatus "Processing: " & xmlComp.SelectSingleNode("Name").text
sCompName = xmlComp.SelectSingleNode("Name").text
xmlStatus.text = sCompName
sCommand = sCmdString & " /Workstation:" & sCompName
iThread = -1
Do until iThread <> -1
iThread = GetNextThread()
SetStatus "GetNextThread = -1"
' wscript.Sleep 100
Loop
Set aThreadInfo(iThread,0) = sh.exec(sCommand)
aThreadInfo(iThread,1) = Now()
Set aThreadInfo(iThread,2) = xmlComp
Do Until ProcessCheck()
' wscript.sleep 200
Loop
Next
Do Until ProcessCount()=0
'call ProcessCheck ()
Loop
End Sub
Dim idTimer
Sub PausedSection()
idTimer = window.setTimeout("PausedSection", 2000, "VBScript")
End Sub
Function GetNextThread ( )
Dim i
GetNextThread = -1
For i = 0 to UBound( aThreadInfo, 1)
If aThreadInfo( i, 1) = 0 then
GetNextThread = i
SetStatus "GetNextThread" & i
Exit Function
End if
Next
End Function
Function ProcessCount()
Dim i, t
call ProcessCheck ()
t=0
For i = 0 to UBound(aThreadInfo)
If NOT isNothing(aThreadInfo(i,0)) Then
t=t+1
End If
Next
ProcessCount=t
SetStatus "ProcessCount" & ProcessCount
End Function
Function ProcessFinished()
Dim i
ProcessFinished = True
'wscript.sleep 100
For i = 0 to UBound(aThreadInfo)
If NOT isNothing(aThreadInfo(i,0)) Then
ProcessFinished = False
End If
Next
End Function
Function ProcessCheck()
Dim i, stdOut
ProcessCheck = False
'wscript.sleep 100
For i = 0 to UBound(aThreadInfo)
If isNothing(aThreadInfo(i,0)) Then 'Check those objects that are
running
ProcessCheck = True
Else
If aThreadInfo(i, 0).Status = WshRunning Then
UpdateXMLStatus aThreadInfo(i, 2), Now() - aThreadInfo(i, 1)
' If Now-aThreadInfo(i,1) > MaxRunTime Then
' Call ProcessStdIO(aThreadInfo(i, 2), "Thread took longer than
MaxRunTime")
' DebugPrint "Terminating thread " & i & " and processid " &
aThreadInfo(i,0).ProcessID
' DebugPrint "Terminating thread Started:" & aThreadInfo(i,1)
' 'aThreadInfo(i,0).Terminate
' Run ".\kill.exe " & aThreadInfo(i,0).ProcessID
' wScript.Sleep 1000
' Set aThreadInfo(i,0) = Nothing
' aThreadInfo(i,1) = 0
' aThreadInfo(i,2) = vbNullString
' End If
Else
stdOut = vbNullString
stdOut = aThreadInfo(i, 0).StdOut.ReadAll
UpdateXMLStatus aThreadInfo(i, 2), "Completed"
'ProcessStdIO (aThreadInfo(i, 2), aThreadInfo(i,
0).StdOut.ReadLine)
aThreadInfo(i, 1) = 0
Set aThreadInfo(i, 0) = Nothing
Set aThreadInfo(i, 2) = Nothing
ProcessCheck = True
End If
End if
Next
End Function
Function isNothing(oTemp)
If TypeName(oTemp)="Nothing" Then isNothing = TRUE
End Function
Function UpdateXMLStatus(oXML, sStatus)
Dim xmlStatus
Set xmlStatus = oXML.SelectSingleNode("Status")
xmlStatus.Text = sStatus
End Function
Function ProcessCompThread (xmlComp)
End Function
</script>
<title>Gui Report Title</title>
</head>
<body>
<table border="0" width="100%">
<tr>
<td width="50%">FileName:<input type="file" value="FileName"
name="FileName" size="40"> <input type="button" value="Load"
name="Load" class="button"></td>
<td width="50%"><input type="button" value="Process"
name="Process" class="button" size=50></td>
</tr>
<tr>
<td width="50%">
<input type="button" value="OK" name="OK" class="button"><input
type="button" value="Cancel" name="Cancel" class="button"></td>
<td width="50%">ReportDir:<input type="text" value="ReportDir"
name="ReportDir" size="50"></td>
</tr>
<tr>
<td width="100%" colspan="2">
<div id="InsertBuildSelect"></div>
<table cellspacing="1" cellpadding="2" id="actionheader"
width="100%">
<tbody>
<tr>
<th width="300">Computer Name</th>
<th width="250">Status</th>
<th width="50">Enabled</th>
<th width="50">Reboot</th>
<th>output</th>
</tr>
</tbody>
</table>
<DIV STYLE="overflow: auto; width: 100%; height: 550; padding:0px;
margin: 0px">
<table datasrc="#complist" width="100%" cellspacing="1"
cellpadding="2" id="actionlist">
<tbody>
<tr>
<td width="300"><span datafld="Name"></span></td>
<td width="250"><span datafld="Status"></span></td>
<td width="50"><input type="checkbox" datafld="Enabled"
style="width:12; height:12" /></td>
<td><input type="checkbox" datafld="Reboot" style="width:12;
height:12" /></td>
</tr>
</tbody>
</table>
</DIV>
<table>
<td width="100%" colspan="2">
<div ID=code_header></div>
<div id="code"></div>
</td>
</table>
</div>
</td>
</tr>
</table>
<input type="hidden" name="TheStatus" size="20">
</body>
</html>
test.xml
<?xml version="1.0" encoding="utf-8"?>
<computerlist>
<computer><Name>ADMIN</Name><Status></Status><Reboot>0</
Reboot><Enabled>0</Enabled></computer>
<computer><Name>ADMIN1</Name><Status></Status><Reboot>0</
Reboot><Enabled>0</Enabled></computer>
<computer><Name>ADMIN2</Name><Status></Status><Reboot>0</
Reboot><Enabled>0</Enabled></computer>
</computerlist> Tag: HTA to create AD user account and mailbox Tag: 203173
Sort multi-dimensional array using vb.net
Hi all,
I have a recordset (result after executing a SQL query) containing names of
employees and their information. The [EmployeeName] column is in unicode.
Due to limition of sorting unicode results in T-SQL, I would like to dump
the recordset in an array and sort them according to the [EmployeeName].
Sample data will be as follows:
[EmployeeNo]......[EmployeeName]......[Dept]......[Title]
193......Peter......Finance.....Manager
632......Amy......Marketing......(blank)
8765......Chris......Marketing......Clerk
87......John......HR......(blank)
I guess the data should be put in an array (arr(no.ofRecords,4))similar to
the one below:
arr(0,0) = 193
arr(0,1) = Peter
arr(0,2) = Finance
arr(0,3) = Manager
arr(1,0) = 632
....
I find it impossible to use the "sort" method in vb.net because it deals
with 1-dimensional array only. May I know how to sort the above data in vb
.net (2003) so I can have the [EmployeeName] in ascending order? I will need
to display the rest of the information as well.
Thanks very much. Tag: HTA to create AD user account and mailbox Tag: 203172
Need Some Help
I have created a script to force the replication on one of our DFS servers.
Set wmi = GetObject("winmgmts:\\" & strcomputer & "\Root\MicrosoftDfs")
Set query = wmi.execquery("Select * from DfsrConnectionInfo where
partnername = 'FAOSFPS-HO01'")
For Each item In query
item.forcereplication()
Next
i am getting SWbemObjectEx: Invalid parameter when i call the method
forcereplication.
I don't know what parameters to use or what i am doing wrong Tag: HTA to create AD user account and mailbox Tag: 203168
Using InStr to find $$
I need to find the existence of two dollar signs in a string. I tried
the InStr command but could not make it work:
barcode = "whatever$$asdfa"
twodollarsigns = "$$"
If InStr(barcode,twodollarsigns)=0 Then
MsgBox "there is missing data"
It works with other characters, not the $$. Any ideas on how I can do
this?
Thanks
DG Tag: HTA to create AD user account and mailbox Tag: 203158
external vbscript file
I've programmed in VB in Windows for years but new to web dev and
VBScript...
I'm trying to write a popup balloon to display when user hovers or
clicks a link...
The text will be data returned from a SQL query. That function works
works but I'm trying to put it in an external vbs file.
I have my vbs file KJVQuery.vbs with the function that returns a <p>
tag with the recordset data:
Function GetKJVBibleVerse (sBook, sChapter, sVerse)
....
End Function
In my calling ASP I;m just trying to test the call with this:
<script type="text/vbscript" src="KJVQuery.vbs" language="vbscript"></
script>
<% response.write( GetKJVBibleVerse ("Mark", "003", "'001' AND
'012'")) %>
When I run I get this:
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'GetKJVBibleVerse'
/test3.asp, line 13
PS - anyone know where I can find some code already written with a
nice popup that will disappear when it loses focus - not when user
clicks close button?
Thanks...Tom Tag: HTA to create AD user account and mailbox Tag: 203154
initialize input value
Trying to initialize an input text box with a date. I thought using <
% Date %> in value would do it...
<input name="iDate" type="text" maxlength="50" value="<%Date%>">
Thanks... Tag: HTA to create AD user account and mailbox Tag: 203151
Open URL links and save page
Hi,
I'm looking to see if it is possible to create a script that can open a list
of links (url's) one by one is fine and save that page?
Is this possible?
Thanks,
Sanj Tag: HTA to create AD user account and mailbox Tag: 203149
I need to check Folder and make sure it is empty.
I have 4 folders that are used all night and populated with text files. In
the morning, the files have all been processed and the foldrs are ( or
should be) empty. Occasionally text files get left behind.
I need to modify an existing VBScript to check and make sure each folder is
empty before allowing operator to continue with script's operation.
Psuedocode:
'Check Folder1 Is Folder empty?
If Folder is empty, then
'procede with next step,
ELSE
'display message box "Text Files have been left unprocessed in Folder1.
Move and process files, and empty Folder1, then restart this
script."VBCRLF,"This program will now end". '(The vbscript will end and no
further action taken if files still exist.)
END IF
I can handle the actions to take, but I don't know the best way to determine
if a folder is empty or if any files exist. The filenames would be multiple
and various. Tag: HTA to create AD user account and mailbox Tag: 203138
Power Management
I currently have about 500 portables that I need to modify the power scheme
on. They are defaultly set to the "Laptop/Portable" Scheme. It is causing
multiple problems in my environment. I need to change the scheme to "Always
On" but making these changes require modification to the below keys of the
registry. And non-admin users don't have permissions to change them.
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ControlsFolder\PowerCfg
HKU\.DEFAULT\Control Panel\PowerCfg
HKCU\Control Panel\PowerCfg
I have created scripts that modify the HKCU and can apply it as a login
script but I need to modify the machine and .default.
Thanks in advance,
James Tag: HTA to create AD user account and mailbox Tag: 203114
Call a vbscript file from a dos batch file?
Can I call a vbscript from a dos batch file?
I am creating Windows 2000 and XP unattended installations.
The way I have things set up is that I boot the subject computer from a dos
based network boot disk.
First the user is given the option to choose the Student or Teacher domain.
Then the user is given the option to install either XP or 2000.
I'd also like the user to be able to enter whatever the end computer's name
should be (as a variable I guess).
Then a vbscript residing on the appropriate server would be called.
That script would read what the computers name is supposed to be, delete an
existing account in Active Directory if it exists, and then create the
computer account.
Is this possible?
Thanks,
Jeremy Tag: HTA to create AD user account and mailbox Tag: 203111
Need Help with file deployment script
I have struggled mightily with this, but it is well beyond my fairly
pathetic coding abilities. If someone could please help it would be
greatly appreciated.
What I have is a program that runs scripts or other executables every
5 seconds.
The program will not run the script if there is already 1 instance
running, so no worries about multiple instances.
What I want is a script that when run, will check C:\Deploy
If any files exist in the folder it will move them to C:\Backup
\YYYYMMDDHHMMSS
It will deploy copies of those files to a list of network destinations
\\MM00156\C:\deploy for example
Under normal circumstances, 3 folders will be dropped into C:\Deploy
There will be any number of files within those folders, and those
folder names will be static
I need to copy ONLY certain files from within those folders to the
network destinations
preferably from a list such as
C:\Backup\20070221155536\Config\Dbapi.pcs
C:\Backup\20070221155536\Junk\Config.ini
etc etc etc
The files when delivered to the network locations will always be
overwriting old files, so would need some sort of overwrite without
confirm setting or something.
My thinking was that the list could be an array populated from an ini
file (I suck at arrays), or could just be listed within the script
itself, the list of filenames would never change, so it doesn't really
matter.
I got as far as being able to create the backup folder, but am really
struggling with how to make it not create a backup folder every 5
seconds, and how to copy only the files in my list.
Option Explicit
Dim N, objFSO, objFolder
Dim strDirectory
N = Now
strDirectory = "C:\Backup\" & ((((Year(N)*100 + Month(N))*100 +
Day(N))*100 + Hour(N))*100 + Minute(N))*100 + Second(N)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder(strDirectory)
Permissions would already be set on all folders to allow the necessary
operations, so no issues there.
Anyway, I'd really like some help on this one if possible
Thank you SO much in advance.
Jason Tag: HTA to create AD user account and mailbox Tag: 203100
Script to remove and create directories
would some assist me in creating a vbs script file to do the following
commands:
del /q "c:\Documents and Settings\%username%\cookies\*.*"
del /q "c:\Documents and Settings\%username%\Local Settings\Temp\*.*"
del /q "c:\Documents and Settings\%username%\Templates\*.*"
del /s /a:h /q "c:\Documents and Settings\%username%\*.tmp"
del /q "c:\Documents and Settings\%username%\Templates\*.*"
rmdir /s /q "c:\Documents and Settings\%username%\Local Settings
\Temporary Internet Files"
rmdir /s /q "c:\Documents and Settings\%username%\Local Settings\Temp"
i'm trying to use a .vbs file rather than a .bat file for this process
for my users to clear out data from the above locations.
thank you in advance,
don Tag: HTA to create AD user account and mailbox Tag: 203098
Script to Delete Internet Cache Files?
I am looking for a way to delete the internet cache files via a script,
without deleting cookies. I have a website which is being upgraded, and the
new version crashes due to old internet cache files that are not refreshed
properly.
Deleting the cache files corrects the problem, but I want to avoid having
each user do this when they access the app after the upgrade, as it will
generate a lot of calls for our help desk.
IE is already configured to check for new files on every visit to the page,
but this is not working in this case.
We could simply delete the contents of everyone's temporary internet files,
but this would remove their cookies and all their favorite settings would be
lost. This would upset some users, and politically be a bad move, so it is
not really an option.
I was hoping there would be some way to script this so we could delete all
of the cache files, excluding offline content and cookies, just like you do
from the Tools, Internet Options, Delete Files.
Does anyone know of a way to do this? Tag: HTA to create AD user account and mailbox Tag: 203097
Has anyone got or know where to download a HTA which will create a
user account in active directory and a exchange 2000 mailbox?