Searching Multiple Domains for Users
Hi! I have been tasked with searching for users across multiple domains
to get the login name & the domain they are in. I have only been
provided a list of display names. I created the following code which
works great except that it does not work on any other domain except the
one that I am a member of. E.G. I can find the users in Domain1 but I
get no results for Domain2 or Domain3 -- Any ideas why? Thanks in
advance!
Joseph
'==============================================
'On Error Resume Next
Dim selList, userList, arrUsers, strUser, strQuery_ Domain1, strQuery_
Domain2, strQuery_ Domain3
Dim wshShell, objCSV, objFSO, objDialog, objTextStream, objUser
Dim objCommand, objConnection, objRecordSet
Set wshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set objCSV =
objFSO.CreateTextFile(WSHShell.SpecialFolders("Desktop") &
"\SearchResults.csv", True)
Set objDialog =
CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "All Files|*.*"
objDialog.FilterIndex = 1
selList = objDialog.ShowOpen
userList = objDialog.FileName
Set objTextStream = objFSO.OpenTextFile(userList, 1)
arrUsers = Split(objTextStream.ReadAll, vbCrLf)
objTextStream.Close
Set objCommand =
WScript.CreateObject("ADODB.Command")
Set objConnection =
WScript.CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 100
objCommand.Properties("Timeout") = 30
objCommand.Properties("Cache Results") = False
For Each strUser In arrUsers
strQuery_Domain1 =
"<LDAP://DC=Domain1,DC=us,DC=domain,DC=com>;(&(objectCategory=person)(objectClass=user)(displayName="
& strUser & "));givenName,sn,displayName,sAMAccountName;subtree"
strQuery_Domain2 =
"<LDAP://DC=Domain2,DC=us,DC=domain,DC=com>;(&(objectCategory=person)(objectClass=user)(displayName="
& strUser & "));givenName,sn,displayName,sAMAccountName;subtree"
strQuery_Domain3 =
"<LDAP://DC=Domain3,DC=us,DC=domain,DC=com>;(&(objectCategory=person)(objectClass=user)(displayName="
& strUser & "));givenName,sn,displayName,sAMAccountName;subtree"
objCommand.CommandText = strQuery_ Domain1
Set objRecordSet = objCommand.Execute
Do Until objRecordSet.EOF
objCSV.WriteLine """" & strUser & """,""" &
objRecordSet.Fields("displayName") & """," &
objRecordSet.Fields("sAMAccountName") & ",Domain1"
objRecordSet.MoveNext
Loop
objCommand.CommandText = strQuery_ Domain2
Set objRecordSet = objCommand.Execute
Do Until objRecordSet.EOF
objCSV.WriteLine """" & strUser & """,""" &
objRecordSet.Fields("displayName") & """," &
objRecordSet.Fields("sAMAccountName") & ",Domain2"
objRecordSet.MoveNext
Loop
objCommand.CommandText = strQuery_ Domain3
Set objRecordSet = objCommand.Execute
Do Until objRecordSet.EOF
objCSV.WriteLine """" & strUser & """,""" &
objRecordSet.Fields("displayName") & """," &
objRecordSet.Fields("sAMAccountName") & ",Domain3"
objRecordSet.MoveNext
Loop
Next
objCSV.Close
WScript.Echo "Script Completed" Tag: .count Tag: 181921
OpenTextFile Error
I am one of the scripting disadvantaged. I have copied the following code
from a MS KB 835991 article. It is supposed to import SID information into a
text document. I copied and pasted the code into a vbs file and it errors on
the sixth line.
I get an invalid procedure call or argument error for this line. Any help
would be appreciated. The code is as follows.
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program
Files\Active Directory Migration Tool\Protar.mdb"
Set rs= CreateObject("ADODB.RecordSet")
Set rs = objConnection.Execute ("Select * FROM [MigratedObjects]")
Set fso = CreateObject("Scripting.FileSystemObject")
Set fo = fso.OpenTextFile("sidMapping.txt", ForWriting, TRUE)
Do while not rs.EOF
fo.write rs("SourceDomainSid") & "-" & rs("SourceRid") & "," &
rs("TargetDomain") & "\" & rs("TargetSamName") & vbcrlf
rs.MoveNext
loop Tag: .count Tag: 181916
Thanks
That does work. How hard is it to display the countdown in seconds?
I am using this to warn users of an scheduled forced logoff.
I am using psshutdown which is freeware and does not have a warning
message.
I need to be able to schedule the logoff in the evenings before backup.
Thanks for your help on this! Tag: .count Tag: 181902
Read NTBackup Log with VBScript.
Hi,
I'm trying to read a logfile from NTBackup (Server 2003) using the
OpenTextFile and ReadLine methods. However, the file seems to be in some
kind of unicode encoding and VBScript doesn't read it properly. I've tried
using all three TriState modes in the OpenTextFile method, but they just read
in garbage, not the actual content of the log.
This is really stumping me, so any help would be appreciated.
Thanks
Mick Tag: .count Tag: 181897
Convert GBs to Bytes
Hi all,
Need a function that will convert GBs to Bytes (i.e. 3.14 GB = 3368383278
Bytes. Any one have a code snippet for this?
Thanks.
-Martin Tag: .count Tag: 181896
Auto DL a file with ssl
Hello
I am attempting to create a script that I can run on a periodic basis that
downloads a file over HTTPS. I have a VB script that work fine until I point
it to the secure server. I can schedule the script to run and it works great
until I apply SSL. I get "A security problem occurred" with msxml3.dll
The reason we are using HTTPS for the file download is:
1. It is free (we cannot purchase anything just yet)
2. FTP is not secure
Any help is appreciated
Thanks Tag: .count Tag: 181892
Simply Script
Hello
I want to write a simple script that I can schedule with task manager
to run.
I want the script to display a dialog box with set message and
countdown a preset number of seconds and then close.
Can anyone help with this?
Thanks in advance! Tag: .count Tag: 181891
Capturing Internet Explorer Script Error messages
I would like to capture the error message that appears in the Internet
Explorer Script Error window that when my script fails in HTA. I've
tried using err.number and err.description but it doesn't give me the
same level of detail. Does anyone know how to do this?
Thanks, Steve Tag: .count Tag: 181890
Function using exceptions to capitalize first letter of each word
Does anyone have any suggestions on how to make the following function
do the followign:
1. Capitalize every word except those in an exceptions list.
2. Always capitalize the first letter of the first word.
Thanks!
<%
Function TitleCase(strTemp)
Dim intFound
Dim strTempName
Do
strTempName = strTempName & UCase(Left(strTemp, 1))
strTemp = Right(strTemp, Len(strTemp) - 1)
intFound = InStr(strtemp, " ")
If intFound <> 0 Then
strTempName = strTempName & Left(strTemp, intFound)
strTemp = Right(strTemp, Len(strTemp) - intFound)
Else
strTempName = strTempName & strTemp
Exit Do
End If
Loop While intFound <> 0
Response.Write strTempName
End Function
%> Tag: .count Tag: 181888
how to center an ie pop window
hi
How do a center an IE window so it well be centered regardless of the screen
resulutions
if a use the code below i can center the window so it will work on a specfic
resulution, but i want it to be center regardless of the reslolution.
With IE
.left=155
.top=70
.height=635
.width=740
any ideas ?
Thanks
/Pe Tag: .count Tag: 181887
Scheduled Task Time Limit
Hi,
I need to schedule a number of tasks on 100+ servers. The WMI class
Win32_ScheduledJob appears to do what I need, but I can't work out how
to set a time limit on a recurring task (the jobs need to run for a
variety of different time limits, so setting the global default wouldn't
do it)
I've found an article on the MS site suggesting that this class supports
that functionality (as oppose to the command line which doesn't) but the
closest function listed is "UntilTime" and as far as I can work out,
it can only be used with absolute dates which wouldn't be much help for
a recurring job. Tag: .count Tag: 181886
Scripting the Add Network Place Wizard?
There has been many post about the "Add Network Place Wizard" and how one
can script shortcuts into the "My Network Places" folder like the wizard
does, but I have not yet found the post that solves my problem.
I need to script the creation of folder shortcuts in the "My Network Places"
folder. The following code almost works... But there is a Big BUT!
'****** START OF SAMPLE ******
Const NETHOOD = &H13&
Dim oWSHShell As WshShell
Dim oShell As Shell32.Shell
Dim oFolder As Shell32.Folder
Dim oFolderItem As Shell32.FolderItem
Dim oShortcut As Object
Set oWSHShell = New WshShell
Set oShell = New Shell32.Shell
Set oFolder = oShell.Namespace(NETHOOD)
Set oFolderItem = oFolder.Self
Set oShortcut = oWSHShell.CreateShortcut(oFolderItem.Path & "\" & "Shortcut
Name" & ".lnk")
oShortcut.TargetPath = "http://MyServer/MyFolder/"
oShortcut.Description = "This is the comment for the folder shortcut"
oShortcut.Save
'****** END OF SAMPLE ******
The But here is that this creates a shortcut object, you can tell this
because doing a right-click properties shows three tabs with the Find
Target, Change Icon and Advanced buttons, like you see on all shortcuts.
Had I used the "Add Network Place Wizard" I would have got a folder shortcut
which appears to be an entirely different beast. And you can confirm its
different by doing a right-click properties, this time you'll see a single
tab and on this tab page it states this is a Type: Folder.
By creating shortcuts with the above code we are unable to navigate to these
locations because the targets start with http:, when clicked the folder is
opened in IE instead of using explorer to navigate to the target. The reason
they start with http: is to do with web folders and WebDAV on our network.
What I need to do is create folder shortcuts just like those produced by the
"Add Network Place Wizard". What API's do I need to call, or changes to the
script above do I need to create folder shortcuts and not shortcuts to
folders?
Any assistance gratefully received.
Cheers
Steve Le Monnier Tag: .count Tag: 181884
backup of virtual machines
let me preface this by saying that I am not very good at vb. I am using a
script that backs up virtual machines and can't get it to back up the vhd
file (virtual hard drive) It should work but not sure why it doesn't, can
someone take a look at the following and let me know if it it looks good or
not???
If Result = 0 then
'Loop through all vm machines
For each objVM in virtualServer.VirtualMachines
'See if vm machine is running. If so copy shadow backup of vm disk drives
If objVM.State = 5 then
'Copy virtual hard disks and undo disks
For each vhd in objVM.HardDiskConnections
MyArray = Split(vhd.undoHardDisk.file,"\")
Filename = MyArray(Ubound(MyArray))
SourceName = "x" &
Right(vhd.undoHardDisk.file,Len(vhd.undoHardDisk.file)-1)
wscript.echo vhd.undoHardDisk.file
wscript.echo SourceName
objFSO.CopyFile SourceName,DestBackupDir & Filename
MyArray = Split(vhd.HardDisk.file,"\")
Filename = MyArray(Ubound(MyArray))
SourceName = "x" & Right(vhd.HardDisk.file,Len(vhd.HardDisk.file)-1)
objFSO.CopyFile SourceName,DestBackupDir & Filename
Next
End If
Next
End If Tag: .count Tag: 181881
Type mismatch error in when accessing an array
Hello,
I have a method on a com+ object that is returning an array of objects.
I know the array is popluated as calls to check the ubound and lbound
show valid values. However, any calls to get the value of a cell in the
array results in a type mismatch error.
Microsoft VBScript runtime (0x800A000D)
Type mismatch
/idmTest/userTest.asp, line 30
I have pasted below some of the samples that i have tried. Each results
in the error above. Any suggestions on how I can access this object
would be helpful.
' Call to get the array and to validate that it is an array.
Set userObj = Server.CreateObject("idmVBApi.ComUser")
userGrpAry = userObj.getUserGroups(5790)
arySize = ubound(userGrpAry)
response.write "userGrpAry size = " & lbound(userGrpAry) & " - " &
arySize & "<br>"
response.write "userGrpAry type isArray = " & isArray(userGrpAry) &
"<br>"
' the following fails
dim index
for index = lbound(userGrpAry) to ubound(userGrpAry)
response.Write "type = " & isobject(userGrpAry(index))
response.write userGrpAry(index).grpName
next
Calls to isNull(userGrpAry(index)) also fail.
Regards
Leslie Tag: .count Tag: 181877
Create printers on Windows Storager Server 2003??
Hi there
I have a script which should create 209 printers, based on information read
from a CSV file. Everything works 100% on my Windows XP Workstation, but
when I try to run it on my HP NAS2000s server running Windows Storage Server
2003 (similar to normal Windows Server 2003), I get an error with the
following command:
objNewPort.Put_
Here is my code:
Const ForReading = 1
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"
& strComputer & "\root\cimv2")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("\\fp1\public\william\printers.csv",
ForReading)
Do While objTextFile.AtEndOfStream <> True
objTextFile.Skipline 'Skip the heading
arrPrinterDetails = Split(objTextFile.Readline, ",")
'0-Name,1-Comment,2-DriverName,3-Location,4-PortName,5-ShareName,6-Duplex,7-Orientation,8-PaperSize strName = arrPrinterDetails(0) strPortName = arrPrinterDetails(4) strLocation = arrPrinterDetails(3) strDriverName = arrPrinterDetails(2) strShareName = arrPrinterDetails(5) WScript.Echo strName strDriverName = "Generic / Text Only" Set objNewPort = objWMIService.Get("Win32_TCPIPPrinterPort").SpawnInstance_ objNewPort.Name = strPortName objNewPort.Protocol = 1 objNewPort.HostAddress = strPortName objNewPort.PortNumber = "9999" objNewPort.SNMPEnabled = False objNewPort.Put_ Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_ objPrinter.DriverName = strDriverName objPrinter.PortName = strPortName objPrinter.DeviceID = strName objPrinter.Location = strLocation objPrinter.Network = True objPrinter.Shared = True objPrinter.ShareName = strShareName objPrinter.Put_LoopobjTextFile.Close Tag: .count Tag: 181875
Help: Return value of IE button clicked
I am using GUIMENU.vbs as a basis for a script I am writing. I am having a
problem getting the follwoing portion of the code to work:
'build HTML page based on menu items
For nF = 0 To Ubound(arrArguments)
objDoc.Write "<center><input type=""button"" value=""" & arrArguments(nF)
& """ name=""" & nF & """></p></center>"
objDoc.All(Cstr(nF)).onclick = GetRef("OnButton_Click")
Next
'this subroutine is called when a menu button is clicked
Sub OnButton_Click
nReturnValue = objdoc.activeelement.name
bDone = True
End Sub
The menu is created correctly, however I have been unsuccesful in returning
the vlaue of the option selected. My menu consists of two named buttons,
One & Two. I need the code to return the name of the button selected. The
above excerpt is verbatiam from the google source. Tag: .count Tag: 181874
Sharing userfolder with vbscript
Hi,
I've created a procedure for automating user creation in my
network:
1. I have a short script defining username etc. and adding group
membership.
2. Then, logging in for the first time, the user home folder is
automaticly created using the Folder Redirection function in
Group Policy.
3. My challenge now is to set the share afterwards, for instance
via the loginscript at first user login.
I've gotten this far with the script:
Const FILE_SHARE = 0
strComputer = "myserver"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
struser & "\root\cimv2")
Set objNewShare = objWMIService.Get("Win32_Share")
errReturn = objNewShare.Create _
("h:\users\myuser", "myuser", FILE_SHARE)
Wscript.Echo errReturn
However, this requires me to edit in the username in each
instance -for each user- making it useless for my login procedure.
I would like to use the %username% env ariable, as the variable is
set as soon as the user logs in, but then the script failed with
error 24 (path not found). Does the WMI service ignore it?
If anyone has an idea how to get this to work I'd be forever
greatful.
Regards... Tag: .count Tag: 181870
Member Servers [WILDPACKET]
I want to find out how many Member Servers we have on our Network in house
and remote sites. This is all one domain with multiple sites and we we have
100 servers.
What will be the quickest way to collect this information? Unluckily,
nobody documented this when the servers intially got deployed.
Any script?
Thank you in advance. Tag: .count Tag: 181869
Error Handling...
I was slapped in the face by irony today. See, for the life of me, I
can't seem to find any documentation on Error Handling for VBScript.
For instance, in the following line of code:
set objFs = GetObject("WinNT://" & strServer &
"/LanmanServer,FileService")
If strServer, a user defined string gathered from a dialog box, does
not equate to a resolvable machine name - the script reports an error,
but attempts to continue.
Strangely enough, the VBScript documentation for the GetObject()
function does not discuss possible errors, or how to handle them!
After banging my head trying to figure out what the function returns on
failure (I can't seem to get MS Script Debugger to work on VBScripts) I
finally threw my hands up and said, "forget it, the error can stay" and
this, I think, is how bugs find their way into MS products. For a
moment I actually felt like a Microsoft employee must feel! :)
Anyways, my question is, how do you handle Exceptions in VBScript? I
know Python is:
try:
...
except:
...
and Java is:
try {
...
} catch(Exception e) {
...
}
Any help would be appreciated!
-Tim Tag: .count Tag: 181865
List and remap shares
Well, batch has failed me, Perl will work but the users don't have it
installed. So my next step is vbscript, but I don't see it done.
What I need to do:
First: prompt a user for his userid and password assigned to him for a
remote file server.
Second: Given a few alternative names for the server, get a list of all
drive letters mapped to network shares on a server and the share they
point to. For example, for ServerX.saplings.us they may have
x: \\serverx.saplings.us\sharex
y: \\serverx\sharey
w: \\127.0.0.1\sharew
They could be using a short name, the full name, or the ip address. So
I will hardcode all 3 values in my script.
Thirdly, go through and disconnect all those shares.
Lastly, go through and reconnect each share, but this time use the
server name I designate(so I can get them all pointing to the same name)
and the userid and password he specified(so we can avoid having a bad
password stored with one of those shares, technically not possible but
it seems it is anyway)
I checked the script repository and didn't see anything, so figured I'd
post here before hacking on it myself. Tag: .count Tag: 181861
extracting text from a .htm document
I am a very experienced user of VBA but I know virtually nothing of
windows programming or file scripting (although I do understand the
basic filesystemobject commands). I'm using the help files in VBA
for OpenAsTextStream, but it isn't working.
I have over 500 .htm files from which I would like to extract the
text either into text files or into string variables so that I can do
further processing. This will save me the trouble of having to open
each of the htm files and save each as a text file manually. [Note
that if there is a better way to accomplish the above than the
OpenAsTextStream method, PLEASE let me know. ]
But when I try to use OpenAsTextStream, my problem is that I try to
use the following code from the VBA help file to extract the text and
put the text into a text file, but I get an error:
Dim f, fs, g, h, ts, j
Dim str2 As String
Const ForReading = 1, ForWriting = 2, ForAppending = 3 Const
TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CreateTextFile "c:\testfile.txt"
Set f = fs.getfile("c:\testfile.txt")
Set ts = f.OpenAsTextStream(ForWriting, TristateUseDefault)
str2 = "\\OurNetworkedDell\C\MyMainFolder\ASpecificFile.htm"
Set g = fs.getfile(str2)
Set h = g.OpenAsTextStream(ForReading, TristateUseDefault)
j = h.readall [this command gives an error]
How do I get from the command OpenAsTextStream to extract the text in g
and "write" it into f which is the text file "c:\testfile.txt"
Thank you!!!!! Tag: .count Tag: 181860
connection to ad
Hi,
how can I connect to AD when I just have a domain and a user id? Up to
now I have just found examples where everything is known, like cn, dn,
etc. But as I just mentioned I just know the domain and a user id. With
RootDSE and DefaultNamingContext I can find out the full domain, but it
seems that I have to know cn, too (and in some examples I can provide a
ldap server name. So I'm a bit confused how to correctly connect to AD).
Can anybody give me a hint on that, or recommend me a goog tutorial (I
haven't found anything really explaining on that at msdn or google, as
most examples are for asp.net and I have to use vbscript)
Thanks in advance.
Best regards,
Andi Tag: .count Tag: 181857
Registry error
Hello,
I have an Access database on a website, records of which display in a
table in an .asp page.
I have a form to add records that works fine, both on my localhost and
on the ISP's server.
However, I have this .asp page to display database records from which to
choose one to update. It replaces the "ID" field with a radio button,
which when selected takes the user to another form to amend the record.
------------------------------------------------------------------------
<%
Dim Conn, Rs, sql
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.Recordset")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("results.mdb")
sql= "SELECT * FROM tbl2005 order by date1;"
Rs.Open sql, Conn
Response.Write "<FORM name='Update' method='post' action='update_form.asp'>"
Response.Write "<table border=0 cellspacing=1 cellpadding=1 bgcolor=white>"
Response.Write "<tr>"&"<th colspan='2' align='left'
bgcolor=#dec45a>"&"Date"&"</th>"&"<th
bgcolor=#dec45a>"&"Day"&"</th>"&"<th
bgcolor=#b0e0e6>"&"Event"&"</th>"&"<th bgcolor=#9fcf8b>"&"A
Grade"&"</th>"&"<th bgcolor=#a0a0a4>"&"B Grade"&"</th>"&"<th
bgcolor=#8ac5ff>"&"C Grade"&"</th>"&"<th
bgcolor=#dec45a>"&"NTP"&"</th>"&"</tr>"
if NOT Rs.EOF then
Do While not Rs.EOF
Response.Write ("<tr>")
Response.Write ("<td bgcolor=#ffffbf>"&"<input type='radio' name='ID'
value="&Rs("ID")&">"&"</td>")
Response.Write ("<td bgcolor=#ffffbf>"&Rs("date1")&"</td>")
Response.Write ("<td bgcolor=#ffffbf>"&Rs("day")&"</td>")
Response.Write ("<td bgcolor=#ddf4ff>"&Rs("event1")&"</td>")
Response.Write ("<td bgcolor=#cce6cd>"&Rs("Agrade")&"</td>")
Response.Write ("<td bgcolor=#f0f0f0>"&Rs("Bgrade")&"</td>")
Response.Write ("<td bgcolor=#bbe9ff>"&Rs("Cgrade")&"</td>")
Response.Write ("<td bgcolor=#ffffbf>"&Rs("NTP")&"</td>")
Response.Write ("</tr>")
Rs.MoveNext
Loop
else
Response.Write("No records found")
end if
Response.Write("<tr>"&"<td colspan='3' align='left'>"&"<input type
='submit' name='submit' value='Select competition' >"&"</td>"&"</tr>")
Response.Write "</table>"
Rs.Close
Set Rs = Nothing
Set Conn = Nothing
%>
-------------------------------------------------------------------------
This script works OK on my localhost, but when I try it on my ISP's
server, it gives the following error message:
"Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver]General error Unable to open
registry key 'Temporary (volatile) Jet DSN for process 0x9cc Thread
0x740 DBC 0x9e5ce3c Jet'.
select_update.asp, line 25"
Is there a problem with the vbscript (something I can alter to fix), or
is this a problem with the ISP's server and registry access?
--
Cheers
Colin Wilson
------------------------------------------------------------------
Trentham Golf Club: http://www.trenthamgolf.com
------------------------------------------------------------------ Tag: .count Tag: 181854
Help with parsing string
Hi all,
Hope someone can help me with this..I have a string that I'm capturing using
the StdOut.ReadAll method, problem is the string contains two lines and I
only need the value example below - 4,708 and 425.3 "not MB":
Estimated number is: 4,708
Estimated size is is : 425.3MB
I've used the code below to get the first value but it also returns the
bottom part of the string. Do I need to use the Split function?
Code:
i = InStrRev(strLogOut, "is:")
strValb = "Value = " & Mid(strLogOut, i + 3)
WScript.Echo strValb
Ouput:
Value = 4,708
Estimated size is : 425.3MB
Thanks in advance.
-Sip Tag: .count Tag: 181853
HTA Help
Good evening,
1st off, I wasn't sure where to post HTA question, if this is complete the
wrong forum could someone please redirect me to a more appropriate one.
2nd and the question - I was wondering if someone could show me a sample HTA
which uses radio buttons to control what is displayed in another part of the
HTA. I have created a simple HTA which is split into 4 sections - Header,
Footer, right and left. In the Left section is a series of radio buttons. I
would like to be able to control the Right section based on what the user
selects in the Left section. For instance, if the use selects the 1st radio
button I would like a teaxt box to appear so they can enter a value and a
button to run a script...
Could someone either give me a sample script to learn from or direct me to a
webpage that can educate me on this subject.
Thank you very much.
Daniel Tag: .count Tag: 181848
wmi - filtering auditing entries to text file
Hi,
I am trying to collect logs using wmi of auditing entries in the event
viewer of domain controllers.
I noticed that the security auditing correctly logs the GUID of the
policy being modified; unfortunately when I collect it using wmi this
name, and others, are lost and replaced by different value like
%{bf967a76-0de6-11d0-a285-00aa003049e2}.
How do I retain these important information ? Can I use any other tools
?
Thanks and Regards Tag: .count Tag: 181844
Referencing Shell.Application in a wsf script
Hello,
I tried to poke around a bit with "Shell.Application". Because of the
possibility to include typelib informations with the reference tag, I
created a wsf-script with this content:
<?xml version="1.0" encoding="windows-1252" ?>
<package>
<job>
<reference object="Shell.Application"/>
<script language="vbscript">
<![CDATA[
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0, "Example", 0, ssfPERSONAL)
]]>
</script>
</job>
</package>
But this didn't worked. The error was something like "reference from
{50a7e9b0-70ef-11d1-b75a-00a0c90564fe} could not be included". (The
message was in german so I have to translate). The problem was solved
with the line
<reference guid="{50a7e9b0-70ef-11d1-b75a-00a0c90564fe}"/>
instead of the orginal line. Why did the reference tag with the
object-attribute not work?
Regards,
Tobias Tag: .count Tag: 181842
ASP Page moved to IIS 6.0 no longer works
I'm in the process of moving an application from IIS under Windows 2000 to a
new server running Windows 2003 and IIS 6.0. One of the pages uses the
wshell.script object to execute a batch file that executes ftp commands from
a text file.
This one page no longer works. I have tweaked the permissions for the asp
page, batch file, cmd.exe and ftp.exe so that I no longer get permission
denied errors. The page is served with a result code of 200 but simply does
nothing.
The batch file doesn't appear to contain any errors as I can execute it from
a command prompt with no problem. It produces output which is just ignored on
the old server.
Heres the relevent ASP code:
Dim oScript
Set oScript = Server.CreateObject("WSCRIPT.SHELL")
oScript.Run "c:\progra~1\dqcomp~1\dqvista\users\shared\PDI\ftpfaxflag.bat"
I've also tried the following:
' Call oScript.Run ("ftp.exe -s:" & Server.Mappath("ftpcmds.txt")
Here's the batch file:
ftp -s:c:\progra~1\dqcomp~1\dqvista\users\shared\pdi\ftpcmds.txt
Here's the ftpcmds.txt file:
open <mainframe name>
<usercode>
<password>
cd <mainframe directory>
lcd \progra~1\dqcomp~1\dqvista\users\shared\pdi
put faxflag.txt FLAGTEST
quit
Any help will be greatly appreciated. Tag: .count Tag: 181840
Check Reg script
Any one an example of a script that I can attach in GPO Login to check if
the value exists in the registry if = yes then go to next procedure if=no
then run the particular setup.exe file.
Thanks. Tag: .count Tag: 181838
automate profile swop: roaming to local
sorry to trouble you all again but you don't happen to know how to automate
the change that you can do to peoples profiles: swopping them from roaming to
local.
For example: in system if you click the user profile tab you can change the
type to local from roaming for the domain users
What I need to do is, maybe in group policies automate this for all domain
user instead of doing one by one.
reason their taking for every to load across the link
I've tried console root>local computer policy>computer
configuration>Administrative template>system>user profile
and then clicking on 'only allow local user profiles'
but this block my users logon scripts - which is no good
any ideas? Tag: .count Tag: 181837
Conditional Window Close
Hello,
I would like to have a script that closes a specific window if it
opens. I'm able to easily do this in Winbatch as well as Autoit, but
can't seam to figure it out in VBScript.
Anyone have any ideas on how to do this?
Thanks in advance for your assistance!
-=Paraleptropy=-
http://www.neflyfishing.net
0 Limit,Catch -n- Release
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =---- Tag: .count Tag: 181826
number formatting
I have a field returned from a query. This field will either be a number or
a string, the string will be a code that explains why there is no number. I
use a function to sort that out (see bottom of this post)
Now I have a number 94.8892254 in str
If I run FormatNumberIfNumeric(str) I get "95" I should get "95.00". How
do I fix this?
Thanks
MIke
Function FormatNumberIfNumeric(str)
If Isnumeric(str) then
FormatNumberIfNumeric = FormatNumber(str, 2, -1, 0, 0)
Else
If str = "" or ISNull(str) then
FormatNumberIfNumeric = "<b>???</b> "
Else
FormatNumberIfNumeric = str & "boo"
End If
End If
End Function Tag: .count Tag: 181823
RDP logn script override?
Firstly greetings everyone,
I've got a slight problem:
scenario:
I've got 2 sites using 1 SBS box for logon authentication rights to the
domain.
1 site has 1 set of scripts allowing them to access the drives in their
building and the same for the users in the other building.
My problem is that when the users logon to the RDP boxes I have setup for
them to access data in the opposite site they take their logon scrip with
them which of cause scripts the completely inappropriate drives.
has anyone found a solution for this problem?
thank you in advance
OSL Tag: .count Tag: 181821
removing non network printers from a computer
Hi.
We have a small script that we run on cumputers that log in to the
domain, the script deletes all printers and then addes a few.
We have a slight problem with the deletion of printers.
When the printer is not a network printer, the script will stop with the
error (here for the printer "Microsoft Office Document Image Writer":
Script: c:\thescript.vbs
Row: X
Col: Y
Error: This network connection
Code: 800708CA
Source: WSHNetwork.RemoveNetworkDrive
The script looks like this and the row that generates the error is the
one marked with "*".
' Begin removing all installed network printers
Set clPrinters = objWshNetwork.EnumPrinterConnections
For i = 0 to clPrinters.Count - 1 Step 2
'wscript.echo clPrinters.Item(i+1) + " deleted."
* objWshNetwork.RemovePrinterConnection clPrinters.Item(i+1), true, true
Next
Any suggestions on how to avoid removing non network drives?
/kb Tag: .count Tag: 181819
IE Favorites Rediection
I need a script to redirect a users IE Favorites to a central location on a
file server. Just as we have the option to redirect a users My Documents,
Desktop and Apllication Data folder from his profile.
I need the script desperately. Tag: .count Tag: 181818
Event log SQL query problem
Hi all,
I have a problem using a select statement when querying event logs. I use
the following statement:
------
Set colLoggedEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where (LogFile = 'Security' And
EventType = '5')" & _
"Or (LogFile = 'System' And EventType = '1')")
------
When executing I only get entries from the Security event log.
Before I tried this statement:
------
Set colLoggedEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where (EventType = 1 Or EventType =
5)")
------
When executing that one I only receive entries from the Application log,
which is - I guess - the first one that is analyzed by the script.
So please could someone tell me if and how I could get entries from multiple
event logs with one query?
TIA,
The Kirschi Tag: .count Tag: 181816
File Not Found Error - UNC?
Afternoon,
I am working through getting a script to grab a file name and the date
it was last modified and am not having any luck with the UNC it would
appear. The script is below and it is erroring on the line below:
Set DatZipFile = fso.GetFile(DatFilePath + Text)
If I msgbox (DatFilePath + Text) the path is correct. I have tried
using the files collection method but I can't properly filter for the
file im looking for. Any help would be greatly appreciated
Cheers
Rob.
-----------------------------------------------------------------------------
set shell = createobject("wscript.shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
const DatFilePath="\\server\c$\Program
Files\McAfee\ePO\3.0.1\DB\Software\"
set TheArgs = WScript.Arguments
NetworkD = TheArgs.Item(0)
NetworkDrive = NetworkD + ":"
WshNetwork.MapNetworkDrive NetworkDrive,"\\server\c$"
cmd = "%comspec% /c dir dat-*.zip /b | sort"
shell.currentdirectory = NetworkDrive + "\Program
Files\McAfee\ePO\3.0.1\DB\Software\"
set dir = shell.exec(cmd)
text = ""
do while true
if not dir.stdout.atendofstream then
text = text & dir.stdout.readall
end if
if dir.status = 1 then exit do
wscript.sleep 100
loop
WshNetwork.RemoveNetworkDrive (NetworkDrive),true
set shell = Nothing
set WshNetwork = Nothing
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Set DatZipFile = fso.GetFile(DatFilePath + Text)
Modified = DatZipFile.DateLastModified
------------------------------------------------------------------------------ Tag: .count Tag: 181815
include folder prior to a folder in a vbscript
I'm loving this Mp3Playlister_multiList vbs script. (
http://www.interclasse.com/scripts/Mp3Playlister_multiList.php) It
creates playlists recursively, but I have one request. Since I have
my mp3's arranged by c:\Artist\Album, the script saves as Album.m3u.
Could someone help modify it for me to save as Artist - Album.m3u.
I'm thinking that it would be modified here...
Sub createAndSavePlaylist(arrFiles, foldName)
Dim txt, txtFile, txtPath
'-- m3u file path
txtPath = dicPlaylistsPath.item(sScannedFoldName) & foldName &"."&
sPlaylistExt
'-- create m3u file (ASCII)
If Not fso.FileExists(txtPath) Then
Set txtFile = fso.CreateTextFile(txtPath,true,false) 'ASCII !!
End If
Set txtFile = fso.GetFile(txtPath)
Set txt = txtFile.OpenAsTextStream(ForWriting, 0) 'ForWriting , 0 for
ASCII (-1 for Unicode)
'-- write m3u entries
txt.write Join(arrFiles, vbCrLf)
txt.close
Set txtFile = nothing
End Sub
I'd greatly appreciate it. thanks, James Tag: .count Tag: 181809
vb script for click a button on a open program window
I am really new to vbscript, I have a program that loads when my
computer starts up. After windows has loaded, the program has a form
that has two buttons on it. One is "Hide" the other is "Close Program".
I would like to write a vb script that ran at startup as well and would
automatically click the "Hide" button on this program when it loaded. I
am first just trying to write the vbscript for clicking the Hide button
on the open form. then I will figure the adding it to the start up. If
anyone new of any examples that would help me or could provide some
general code I would greatly appreciate it. Tag: .count Tag: 181807
Moving VBScript to HTML or HTA
<lenghty post>
Hi all!
I have a VBScript that I'm using to set my computer up to wake me up in the
morning - basically an excuse to teach myself some basic scripting. Here's
the meat of the script:
"""""""""""""""""""""""""""""""""""""""
Dim objShell, objFSO, objTSOut, strDay, strMonth, strYear, strHour,
strMinute, strNow
strDay = InputBox("Enter day of month")
strMonth = InputBox("Enter the month")
strYear = InputBox("Enter the year")
strHour = InputBox("Hour")
strMinute = InputBox("Minute?")
strNow = Date
Set objShell = WScript.CreateObject("WScript.Shell")
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set objTSOut = objFSO.CreateTextFile ("C:\Batch\SetAlarm.cmd",true)
objTSOut.WriteLine "Schtasks.exe /Create /S COMPUTER /RU user /RP password
/SC ONCE /SD " _
& strYear & "/" & strMonth & "/" & strDay & " /TN WakeUpCall_" & strNow & "
/TR C:\Batch\ScheduledWakeupCall.vbs /ST " & strHour & ":" & strMinute &
":00"
objTSOut.Close
objShell.Run "C:\Batch\SetAlarm.cmd"
"""""""""""""""""""""""""""""""""""""""""""""""
So, it's actually a script that collcts info and creates a cmd file that
uses the 'Schtasks.exe' command to set up a scheduled task in Windows. The
task it schedules is in this case script that starts Media Player with a
specific playlist - a pretty nice way to wake up in the morning. :-)
Now, I would like to move this to a HTML or HTA file, just to see how it
works, and to get a nicer user interface. What I'm after is: how to get user
input from radio buttons, drop down boxes and so on, instead of the input
boxes I get with a vbs file. I have no clue how to capture the input from
forms, so I'm flying blind here and need some help. Any ideas??
TIA,
Örjan
</lengthy post> Tag: .count Tag: 181806
After Update/ on change
Hi
currently i am developing a few data access pages to enable users to enter
data from an intranet.
i am more than confortable in developin access databases but have only
recently touvhed upon DAP. I can program with access using VBA.
What i would like to do is the following:
a) When the record has been saved successfully to be able to display an
message box. I have been using VBScript and the function MsgBox, but nothing
appears, this has been used in the event After Update on the MSODSC object.
Any body know how to do this?
b) The Save button i would lik