Using VBScript to refresh group policy, restart, and log in.
I am writing a script that needs to apply the domain's group policy,
restart, and automatically log the administrator back in without
needing any user interaction. The problem is that I cannot get rid of
the legal message. This is the popup that appears after you press CTL-
ALT-DEL on a Win2k or WinXP machine which has a message set in the
group policy. In my case, the message is set in a domain GPO.
My first solution was to delete the legalnoticetext and
legalnoticecaption registry values in HKLM. This is a very common
example on the internet. However, (like many of these examples) this
doesn't work because the group policy will just be applied again when
the computer is restarting.
My second solution was to make use of the NoMachinePolicy DWORD value
located in:
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\GPExtensions
\{827D319E-6EAC-11D2-A4EA-00C04F79F83A}
When NoMachinePolicy is set to 1, it prevents the security policy from
being applied. I had the script set the value to 1 just before
rebooting, and then change the value back after logging in. This
solution also has problems, and I can't use it. In Windows XP, it
appears to reverse the changes made by the gpupdate /force command. I
am executing gpupdate /force, setting the auto logon registry entries,
setting NoMachinePolicy to 1, clearing the legal message text and
caption, and then restarting. But here's the problem: when the group
policy is applied, the administrator account is renamed to something
else. However, after I restart the account's name goes back to
administrator. My auto login fails because I have the wrong account
name for DefaultUserName. And I have verified that after the gpupdate
command is run, the account name does change just before the gpupdate
finishes. I have no idea why this is happening.
The second reason I don't like using this is because I cannot leave
NoMachinePolicy set to 1 the whole time the script is working. The
script installs several packages after restarting which need to be
able to apply group policy. And if I do not have it set the whole
time, the computer will not be able to automatically boot up and login
if one of the package installations forces a restart.
So I'm looking for a working solution that will let me bypass the
legal message for an automated logon. This is the only problem
stopping me from being able to use this script, and I would really
appreciate some help here. Tag: How to find a DFS root in a domain Tag: 207096
Shutdown computer using VBScript
Hi. I am trying to shutdown a group of computers that are on the
domain using a VBScript. When the user launches the VBScript it will
ask for the time in seconds before the computer shutdowns. It is being
done based on the way the command prompt does i.e. shutdown -m \
\computerName -s -t 00. I know the script will work if I make the
computer shutdown ignoring the user input but need to know how to do
it so the user can select how long it will be before it shutdown.
Thanks very much for anyone who can help me in this matter. Tag: How to find a DFS root in a domain Tag: 207084
registry keys to treeview control
Hi,
I have been struggling with the following
I am using vbscript in an application that will display registry keys
(and their values) as part of a treeview control.
I know the 'parent key', under which there can be a varying number of
subkeys, and their subkeys, and so on.
I know how to enumerate subkeys under a single key, using WMI and
EnumKey
What I am srtuggling with is, that I need some mechanism to process
each of the found subkeys to find about their subkeys, and so on. Some
kind of recursive algorhythm. I have seen and tried examples of
recursive algorhythms, for instance for files and folders. But
somehow, I cannot get my brain to figure out how to translate those to
my needs.
I was hoping someone could help me out, either with some sample code
or a website perhaps? I have so far searched pscode.com and some
others, but havent quite found what I am looking for.
kind regards,
arno Tag: How to find a DFS root in a domain Tag: 207083
Read from one Text file and Write to another.
I have to make an edit to a file and what I was planning to do is open
the file to read, then compare each line read to see if it equals my
search value, which is a substring of what is probably there. If it
does not, simply write it to another file. If it does = my search,
simply replace the value with my edit and write to the other file. I
would do this until the original file is at end. I would then like to
move my new file over the original, which should now include my edit.
Or
Open File for Read
Open Other File for Right
'read through first file
While file not at end
If line contains my search substring
replace line to include new substring
write it to other file
else
write line to other file
End if
End While
Close new file
Close original file
Move new file to original
Done!
Any guidance from a vbscript wiz would be greatly appreciated!
Thanks!!! Tag: How to find a DFS root in a domain Tag: 207075
How to insert the Thousands Separator (comma) in Excel?
Hello all.
I've got a VBScript that takes a CSV file, makes some formatting
changes, and saves it to an XLS file. What I'd like to add to this
script is the command to insert the Thousands Separator in column B
for the entire column. Column B contains numbers in every cell except
for the top cell which has a word.
In searching I did find the Constant "Const xlThousandsSeparator = 4"
but I can't quite figure out how to write the line to implement it.
Any suggestions would be greatly appreciated. Thanks!
My script:
Const xlDescending = 2
Const xlNormal = 1
Const xlCenter = -4108
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim CurDir
CurDir = objFSO.GetFolder(".").Path
Set Folder = objFSO.GetFolder(CurDir)
Set Folder = nothing
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Open(CurDir & "\Results.csv")
Set objWorksheet = objWorkbook.Worksheets(1)
'~~ Sort by Column B, Descending
Set objRange = objWorksheet.UsedRange
Set objRange2 = objExcel.Range("B1")
objRange.Sort objRange2,2
'~~ Insert blank row at Row 1
sRow = "1"
objExcel.Worksheets(1).Rows(sRow).Insert xlDown
'~~ Insert Header text
objExcel.Worksheets(1).Cells(1,1).Value = "Server"
objExcel.Worksheets(1).Cells(1,2).Value = "Error Amount"
'~~ Bold the Header row
Set objRange3 = objExcel.Range("A1:B1")
objRange3.Font.Bold = True
'~~ Auto Fit and Center both Columns
objExcel.Cells.EntireColumn.AutoFit
objExcel.Cells.EntireColumn.HorizontalAlignment = xlCenter
'~~ Insert blank row at Row 2
sRow = "2"
objExcel.Worksheets(1).Rows(sRow).Insert xlDown
objWorkbook.SaveAs CurDir & "\Results.xls",1
objWorkbook.Close
objExcel.Quit
Set objFSO = nothing
Set objExcel = nothing
Set objWorkbook = nothing
Set objWorksheet = nothing
Set objRange = nothing
Set objRange2 = nothing
Set objRange3 = nothing Tag: How to find a DFS root in a domain Tag: 207066
Problems with Connection Strings
Hello Everyone,
I am a newbie to web development. I am using FrontPage 2002/SP3 on XP and
IIS 6.0 on Win2K3 server. My Dev website is stored locally and I am
publishing to the IIS server.
I am attempting to connect to and query an Access database stored both
locally and on the IIS server. This is the code (and connection string that
I am using, (which I believe should be using the Microsoft Jet driver, pardon
if I am not 100% correct in this statement.)...
<%
dim oConn
dim strConn
dim strSQL
dim rs
Set oConn = CreateObject("ADODB.Connection")
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and
Settings\rks.RPS.002\My Documents\My
Webs\richweb\GSDtest\OtherFiles\jettest.mdb
oConn.open strConn
%>
On my local XP box, the first time I hit the hyperlink to call this page
(jet.asp), IIS shows me all the code on the page. If I refresh the page, it
renders and displays correctly, except the query that I run does not appear
to execute, or at the very least, the results of the query are not
returned/displayed.
When I run this page on the IIS server, I get the following error message:
Microsoft VBScript compilation error '800a0401'
Expected end of statement
/GSDtest/Jet.asp, line 8
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and
Settings\rks.RPS.002\My Documents\My
Webs\richweb\GSDtest\OtherFiles\jettest.mdb
----------------------------^
The ^ character is pointing to the "." (period) after OLEDB and before the
number 4. Can anyone tell me why I am having this problem and how to resolve
it?
TIA,
Rich Tag: How to find a DFS root in a domain Tag: 207065
Login script for printing preferences
I need to over-ride Printing Preferences at the point of login to change a
default label size on a Zebra TLP-2844 Thermal Printer.
Is this information stored in the registry and is it possible to do this
please?
Thank you, Mark Tag: How to find a DFS root in a domain Tag: 207064
Check if AD attribute exists
Hi, is there a way to check if an attribute of a user object in Active
Directory is "Not Set", i.e. currently has no values set?
Checking for Null or an empty string doesn't seem to be possible, but I
don't really want to rely on checking for an error.
many thanks,
Craig Tag: How to find a DFS root in a domain Tag: 207061
Assign serial Number to Thumb Drive (USB)
Is there a way to process a VB Script to put a serial number in for a USB
Thumb Drive?
Thanks in advance. Tag: How to find a DFS root in a domain Tag: 207059
Install MSI
Hi!
I have the following code to install an app:
Set objInstaller = CreateObject("WindowsInstaller.Installer")
objInstaller.UILevel = 3 + 32
objInstaller.InstallProduct "app.msi"
In some machines the user do not have install privileges.
Is there any form to install the app in these machines?
Thanks. Tag: How to find a DFS root in a domain Tag: 207056
Urgent!!! VB Developers for UAE
VAM SYSTEMS is a Business Consulting, IT Technology Solutions and
Services company with operations in UAE, Qatar, USA, Singapore,
Australia and India.
We are currently looking for a team (4 to 8 developers) VB Developers
for our UAE operations with the following Skill Set and Terms &
Conditions
Skill Set required:
Skills:
1. Strong Development experience VB, VB Scripting, SQL and Delphi.
2. Experience on banking will be an added advantage.
Domain: Banking.
Experience Required: 3-5yrs
Terms and conditions:
Joining time frame : 2 weeks (Maximum 4 weeks)
The selected candidates shall join VAMSYSTEMS-UAE and deputed to one
of the leading banks in UAE.
Should you be interested in this opportunity, please send your latest
resume in MS Word format at the earliest at
nishanthini.suda@vamsystems.com or If there is any queries you can
chat me on nishanthini_28@hotmail.com,
nishanthini_81@yahoo.co.in,vinirma@gmail.com, Skype ID is nishanthini2
or call us +91 471-3015245 or 2311320. Tag: How to find a DFS root in a domain Tag: 207053
Urgent!!! VB Developers for UAE
VAM SYSTEMS is a Business Consulting, IT Technology Solutions and
Services company with operations in UAE, Qatar, USA, Singapore,
Australia and India.
We are currently looking for a team (4 to 8 developers) VB Developers
for our UAE operations with the following Skill Set and Terms &
Conditions
Skill Set required:
Skills:
1. Strong Development experience VB, VB Scripting, SQL and Delphi.
2. Experience on banking will be an added advantage.
Domain: Banking.
Experience Required: 3-5yrs
Terms and conditions:
Joining time frame : 2 weeks (Maximum 4 weeks)
The selected candidates shall join VAMSYSTEMS-UAE and deputed to one
of the leading banks in UAE.
Should you be interested in this opportunity, please send your latest
resume in MS Word format at the earliest at
nishanthini.suda@vamsystems.com or If there is any queries you can
chat me on nishanthini_28@hotmail.com,
nishanthini_81@yahoo.co.in,vinirma@gmail.com, Skype ID is nishanthini2
or call us +91 471-3015245 or 2311320. Tag: How to find a DFS root in a domain Tag: 207052
IsDate()
I am working with an HTA, having the user enter a numeric value for the
MONTH / DAY / YEAR. I then concatenate them into the format shown and then
do an IsDate(). If the user enters something like 14 / 2 / 2007, IsDate
returns True; it is reading the date as DAY / MONTH / YEAR.
Any idea how I can get around this without using DropDowns?
Thanks.
Bart Tag: How to find a DFS root in a domain Tag: 207051
Bug in Win32_LogonSession?
Hello everyebody,
It seems that Win32_LogonSession class has an undocumented bug or
feature related to the RunAs service.
Here is a simple script:
*******************************************************************************************
Set objWmiSvc = GetObject("winmgmts://")
Set colUsers = objWmiSvc.execQuery("Select * from
Win32_LoggedOnUser")
For Each objUser In colUsers
set objUser = objWmiSvc.Get(objUser.antecedent)
set objSess = objWmiSvc.Get(objUser.dependent)
WScript.Echo objUser.name & " - " & objSess.logontype
Next
*******************************************************************************************
I run it under a regular user account and it displays:
MyUser - 2
where
MyUser - the user currently logged on
2 - means that is an interactive session.
Then, from the same session spawn a command prompt windows using Run
As with another username and rerun the script from the initial user
context (not the new run as window).
Now it displays:
MyUser - 0
where
MyUser - the user currently logged on
0 - means this is SYSTEM session !!!
Is this a bug in WMI?
Has anyone seen this before? Tag: How to find a DFS root in a domain Tag: 207050
Using the DiskQuota object returns many names unresolved in Windows 2000 - any way to get all?
I am attempting to gather the disk quota information on a number of
volumes on a Windows 2000 server. I am using the script from TechNet
at http://www.microsoft.com/technet/scriptcenter/scripts/storage/quotas/default.mspx?mfr=true.
The entries are returned but many of them return a blank LogonName and
an AccountStatus value of 5 (Account information is unresolved). I
note that if I display the quota entries from the volume properties
many of the entries display [Retrieving Name] for some period of time.
I am guessing that the use of the shell object from the script does
not get refreshed. Is there any way to get the information refreshed
in Windows 2000?
Thanks! Tag: How to find a DFS root in a domain Tag: 207048
Locale and CDate issue
When I am using setlocale to a western locale like en-gb or en-us, the
CDate function is sensitive to the field sequence defined in the
locale. So if I CDate a string like 25/12/2007 using en-gb the date is
Christmas, if I do the same in a en-us locale, 12/25/2007 is
Christmas.
If I setlocale to ar-sa (Arabia Saudi Arabia) and use the
formatdattime function, I get the Gregorian date converted to a Hijri
date automatically.
However, if I use CDate while in the ar-sa locale setting, the
datevalue that is created seems like the middle ages (1428/12/16). How
can I get a correct datetime value from a Hijri date using the locale
features in vbscript?
tia Tag: How to find a DFS root in a domain Tag: 207045
ADO stored proc
I am new to vbscript and need to learn it but more importantly I need to know
how to access a SQL Server stored procedure using vbscript and ADO. I've
looked at vbscript books and sql server books on Amazon and don't know what
to get that would discuss vbscript for a stored procedure. Could you please
direct me to a website or recommend a book or books that explain it.
thanks - nick Tag: How to find a DFS root in a domain Tag: 207038
Get filetype of files without extension
Hi,
When you have activated the explorer option "hide known file
extensions" and you mail an attachment, on the receiving computer, the
extension has been lost.
With MS Word documents, this is no problem, the file will
automatically be opened with MS Word.
With pdf documents, this isn't the same... you get a dialog to choose
the right program (but when you open this, you can see PDF1.2).
Is it possible to programmatically get the file-type or extension from
those files?
Thanks in advance,
Netfreaky Tag: How to find a DFS root in a domain Tag: 207027
error accessing property of an object
I'm tyring to access an object created by using a method from a third
party API. The documentation tells me what object should be return,
and the properties of that object, but when I try and access one of
those properties I've shown an error message saying that the Object
doesn't support this property or method. Here's the code I'm using
(edited to protect the third party NDA)
[script]
1: <%
2: dim siteApi, userApi
3: dim userObj
4: dim session, user_date_created
5:
6: set siteApi = createobject("MSSoap.SoapClient30")
7: siteApi.mssoapinit("http://thirdparty.domain/site/api?wsdl")
8:
9: set userApi = createobject("MSSoap.SoapClient30")
10: userApi.mssoapinit("http://thirdparty.domain/user/api?wsdl")
11:
12: session = siteApi.login("username","p@ssw0rd")
13:
14: set userObj = userApi.getUser(session,"webadmins")
15:
16: user_date_created = userObj.date_created
17: %>
[/script]
In the above code, the session variable is populated with the correct
info (a HEX string), suggesting that my siteApi object is being
created and used correctly. However, I get the following error when I
run it without line 16 commented out:
[error]
Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: 'date_created'
/soapTest/index.asp, line 16
[/error]
The documentation for the user API does show that 'date_created' is a
property of the UserStruct object, returned by the 'getUser' method,
so I'm readlly confused why this won't work.
Is there anything fundamentally wrong with my script? If not, is there
any ASP I can use to see what properties are available with the
userObj?
Thanks for any help you can offer
Kevin Tag: How to find a DFS root in a domain Tag: 207019
Connecting and reading SQL databases
Hello,
So far I have the following:
Set VAR = CreateObject("ADODB.Connection")
VAR.Open("DSN=temp")
Suppose my SQL database is:
A B
C D
corolla 2
BLAH BLAH
camry 4
BLAH BLAH
accord 5
BLAH BLAH
miata 2
BLAH BLAH
WHERE A,B,C,D are column names.
Now,
Dealing with only columns A and B,
I want to assign a variable in my VBScript program the value of column
B of the row containing accord, how do I go about?
NOTE: database owner is cadb and name of database is cars.
I would really appreciate any help.
Thanks a lot. Tag: How to find a DFS root in a domain Tag: 207012
Alternative to NetConnectionID?
The WMI Tasks: Networking page at
http://msdn2.microsoft.com/en-us/library/aa394595.aspx shows an example using
NetConnectionID, and notes that this isn't available on Windows 2000, for
which you should use the "example below". But the example below still uses
NetConnectionID. For me any attempt to use this throws an Invalid Query
exception. I'm calling from C# rather than VBScript. Is that second example
on the web page wrong?
What I need to do is to find the "typical" network adapter - you know, the
Ethernet port you almost always find on the back of the computer. On Windows
2000. I know there are different configurations, and maybe there is no answer
which *always* works, but right now on Windows 2000 I'm stuck with scanning
for Manufacturer=Intel (which for now is true of all the computers we ship in
our product as far as I know), and I'd like to find something better than
that. (On XP I can just look for NetConnectionID='Local Area Connection').
P.S. What's up with WMI telling me a Bluetooth connection is
AdapterType=Ethernet? That's the reason I can't just scan for that. Tag: How to find a DFS root in a domain Tag: 207006
VBSCRIPT and DSMOD
I am running this DSQUERY and DSMOD command to change all the
passwords on my lab network:
dsquery user -limit 10000 | dsmod user -pwd Password1
However, it fails when it encounters a user with the hidden attribute,
such as ROOT$. I am NOT a vbscript'er, so I'm not sure how to write
this...any help would be greatly appreciated.
Thanks,
Phil Tag: How to find a DFS root in a domain Tag: 207003
(Wscript.Network) issue removing network drive
Hey All,
I have a question about (wscript.network). I am trying to remove some
network drives on xp pro workstations using the script below. Well,
it's just not working. I don't get any errors but when I open "My
Computer" it still shows the connection to the network drive.
I can use the shell to run "net use" to delete these drives but I was
trying to get this other way to work. Any ideas what would
prevent .network from removing the drives? Thanks in advance.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim objNetwork
Set objNetwork = CreateObject("WScript.Network")
'Remove Existing Network Drives
objNetwork.RemoveNetworkDrive "G:", True
objNetwork.RemoveNetworkDrive "H:", True
objNetwork.RemoveNetworkDrive "I:", True
objNetwork.RemoveNetworkDrive "M:", True
objNetwork.RemoveNetworkDrive "S:", True
objNetwork.RemoveNetworkDrive "T:", True
objNetwork.RemoveNetworkDrive "Y:", True
objNetwork.RemoveNetworkDrive "V:", True
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Shrp Tag: How to find a DFS root in a domain Tag: 206995
lastlogonTimeStamp Script... Works but...
Ok well here is my script. It works sort of... What I would like for
it to do it get the lastlogontimestamp for every user in the domain.
It works if I add - On Error Resume Next - putting this in either
skips the record that does not have a lastlogontimestamp or uses
outputs the same timestamp from the previous user account.
If I leave it out I get the following error - (33, 4) Active
Directory: The directory property cannot be found in the cache. -
Line (33, 4) is - set objLogon = objUser.Get("lastLogonTimeStamp")
I tried to add in this but I think I'm doing it wrong. Instead of
skipping or outputting the wrong timestamp I would like for it to say
- 404 TimeStamp Not Found - .... something along those lines :P
If Hex(Err.Number)="&H8000500D" Then
WScript.Echo "No such property!" & vbCrLf & "Err. Number: " _
& vbTab & CStr(Hex(Err.Number)) & vbCrLf & "Err. Descr.: " _
& vbTab & Err.Description
End If
==========================
Any suggestions?
Thank You
============================
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Dim objRootDSE
Dim objConnection, objCommand, objRecordSet
Dim UserDN, objUser, strDNSDomain, strQuery
Dim objLogon, strWeeks, strDays, intLogonTime
Dim intLLTS, intReqCompare, ADVersion
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
strQuery = "SELECT distinguishedName FROM 'LDAP://" & strDNSDomain &
"' WHERE objectCategory = 'User'"
objCommand.CommandText = strQuery
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
UserDN = objRecordSet.Fields("distinguishedName").Value
Set objUser = GetObject("LDAP://" & UserDN)
wscript.echo UserDN
' Begin calculation
set objLogon = objUser.Get("lastLogonTimeStamp")
intLogonTime = objLogon.HighPart * (2^32) + objLogon.LowPart
intLogonTime = intLogonTime / (60 * 10000000)
intLogonTime = intLogonTime / 1440
intLLTS = intLogonTime + #1/1/1601#
strDays = strWeeks * 7
intReqCompare = Now - strDays
If intLLTS < intReqCompare Then
wscript.echo Mid(objUser.Name,4) & " last logged on
at " & intLLTS
End If
objRecordSet.MoveNext
Loop Tag: How to find a DFS root in a domain Tag: 206994
WshShell.Run and long command
Hi, I have an install of Adobe CS3 that I can execute from a bat file. I
can't seem to convert the bat command to vbscript. It gets as far as
executing the setup.exe, but ignores the silent switch and anything after it.
Here is the command from the batch file that works.
E:\D\Creative Suite 3\Application\Adobe CS3\setup.exe" --Mode=Silent
--deploymentFile="E:\D\Creative Suite 3\Application\Adobe
CS3\deployment\install.xml"
Here is the vbscript that fails. It executes the setup.exe but ignores the
statements after the setup.exe.
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run """E:\D\Creative Suite 3\Application\Adobe CS3\setup.exe""" &
Space(1) & "--Mode=Silent" & Space(1) & "--deploymentFile=" &
"""E:\D\Creative Suite 3\Application\Adobe CS3\deployment\install.xml""", 2,
True
I have tried doing different codes with no luck. I have used ( ) with no
luck.
I can usually figure the command out fine. Please help.
Thanks,
Jeff L. Tag: How to find a DFS root in a domain Tag: 206993
VBScript to Remove Lotus Notes Person Record
Hi,
Is anyone able to assist. I need a Sub to remove/Delete a Person
Record in lotus notes but a struggling to find the code to do this. I
have code to delete a user, but 30 days before deleting the user we
would like to just remove them from all address books.
Here is the code I have already:
'==================================================================================
'Sub to Delete the Leavers Lotus Notes Address Book Entries
'==================================================================================
'==================================================================================
'Sub to Delete the Leavers Lotus Notes User Accounts Including
replica's
'==================================================================================
Sub DeleteLNUser (Lnusername,sLNpassword)
Dim objSess As New NotesSession
Dim adminp As NotesAdministrationProcess
Const ID_HIERARCHICAL = 172
Const MAILFILE_DELETE_ALL = 2
Const Immediate = False '==================Enter True or False. True
deletes all references to the user in the Domino Directory before
issuing an administration process request. False lets the
administration process make all deletions.
Set ObjSess = CreateObject("Lotus.NotesSession")
ObjSess.Initialize sLNpassword
Set adminp = notesSession.CreateAdministrationProcess(NOTES SERVER)
Call adminp.DeleteUser(Lnusername , immediate , MAILFILE_DELETE_ALL,
"", False)
End sub
'==================================================================================
Many Thanks Tag: How to find a DFS root in a domain Tag: 206992
Simple Time function (for you, maybe)
Hi,
I want to look at a date time stamp and determine if it is before or
after 0600 in the morning.
I have tried this, with no luck (everything comes back as "Day"
text = book1.Worksheets(1).Cells(x,4).Value
FSpace = Instr(text," ") + 1 'Search for the first space in the
string
qTime = Right(text,FSpace) 'Chop the string down
WScript.Echo "qTime: " & qTime
If qTime > "6:00" Or qTime < "18:00" Then
book1.Worksheets(1).Cells(x,6).Value = "Day"
Else
book1.Worksheets(1).Cells(x,6).Value = "Night"
End if
TIA Tag: How to find a DFS root in a domain Tag: 206982
Generating a HTML file with accentuated characters?
Hi!
We wrote a VBScript that create an Active Directory report into a HTML file
format, but users names containing accentuated characters are displayd
incorrectly! What could we do to avoid that (codepage settings)?
Thanks.
Claude Lachapelle
Systems Administrator, MCSE Tag: How to find a DFS root in a domain Tag: 206979
backup a remote host's event logs
Hello,
With VBScript, I'm trying to back up all the workstations and member
servers from the PDC FSMO role holder. My script enumerates the hosts
on the domain and then passes each hostname to a method which tries to
backup the event logs on that box (The script is also smart enough to
know how many logs are on the box and tries to back them up one at a
time). My script runs without complaining but it will only backup the
log files on the box which the script is run -- not any of the remote
boxes.
I've looked at:
http://groups.google.com/group/microsoft.public.win32.programmer.wmi/browse_thread/thread/f24756bda5859d8d/f74e6e83a58910c4
http://groups.google.com/group/microsoft.public.win32.programmer.wmi/browse_thread/thread/b3fe81a46fdeca2d/393d1380a58a207b
One of the posts says you cannot do this with WMI and the other post
implies they got it to work. A portion of my code is posted below
(and is pretty much the same as what is in one of the links above).
You'll notice I'm not ignoring errors and when I run the script here
backupLog always returns zero -- this is the confusing thing, the
script runs without complaining but it will only backup the log files
on the box which the script is run -- not any of the remote boxes.
' h = hostname
' l = Win32_NTEventlogFile.LogfileName
Sub backupLogs(h, l)
Dim sFileName : sFileName = "C:\Temp\" &_
h & " " &_
l & " " &_
".evt"
Dim objWMI : Set objWMI = GetObject("winmgmts:" &
"{impersonationLevel=impersonate,(Security, Backup)}!\\" & h & "\root
\cimv2")
Dim colLog : Set colLog = objWMI.ExecQuery("Select * from
Win32_NTEventLogFile where LogFileName='" & l & "'")
For Each log in colLog
backupLog = log.BackupEventLog(sFileName)
If backupLog <> 0 Then
MsgBox "The " & l & " log on " & h & " could not be backed up."
Else
log.ClearEventLog()
End If
Next
End Sub
So what is it... is it indeed possible to backup event logs from
remote machines? If so, any suggestions to where I went wrong with my
script are greatly appreciated.
Thanks! Tag: How to find a DFS root in a domain Tag: 206976
Array Question
I think this would be solved with an array, but I'm not sure. I have
no idea how to implement one into this.
I currently have a backup script going for my company. I'm just a IT
person, not a programmer by any means. I'm working off of a previously
created script. What this script does, is it calls another program
called "Robocopy" to do the actual copying.
Basically right now, the script backs up certain PC's. Afterwards, if
there is an error it emails me, telling me which computers didn't
complete the backup. It also creates text files with logs and stuff.
I want to be able to have a list with the PC name's and corresponding
email addresses of the owners of that PC. So if there is an error the
script, it find the PC name that got the error, located the email
address assigned to that PC name, and sends and email to that address,
stating that there was an error.
Here are my scripts ...
This one specifies Source & Destination
http://docs.google.com/Doc?id=dcc6zqw6_1fhdh4g
This one is the actual script
http://docs.google.com/Doc?id=dcc6zqw6_0czkw8m Tag: How to find a DFS root in a domain Tag: 206971
logoff/shutdown script
My manager has asked me to write a script that will run every time
someone tries to log off or shutdown a computer. In the past people
have logged off computers while virtual machines were running and
usually automation would be running at the time or people would be
doing manual QE testing so it would always be a real pain when they
were shut off without warning. He wants me to write a script
(shutdown or logoff or even both) that would check for one of VMware's
executable files that only appear when a VM is running and then prompt
a warning to the user to stop them from shutting down or logging off.
I've done a some reading on the internet about logoff/shutdown scripts
and I've emailed some people that I know. I know that it should be
either a vbscript or jscript file. I know where to save the script
when I'm done and how to configure group policy so that it runs on all
the computers. I even know how to format the script (1. get a process
list, 2. search the list for the VMware process 3. if process is found
alert the user and cancel shutdown/logoff 4. if not, do nothing). The
only problem is I DON'T KNOW HOW TO WRITE ONE. Do you guys have any
suggestions as far as websites or reading material? Any thoughts
would be appreciated. Tag: How to find a DFS root in a domain Tag: 206957
Error Handling - IADS bug ?
I have a script to create users.
.......
On Error Resume Next
set objUser = objCIADS.Create("User", "CN=" & strFname & " "
&strLname)
objUser.Put "samAccountName", strAccName
objUser.SetInfo
if (Err.Number<>0) then
Wscript.Echo "User Creation failed for " & strFname & " " &
strLname & vbcrdlf & _
"With Error " & Err.Description & " - continuing"
.......
It works just fine.
If I try and create a user that already exists then
the error event is not triggered. If I omit the On Error Resume Next I
get an error saying the object already exists.
Is this a bug or have I got something wrong? Tag: How to find a DFS root in a domain Tag: 206954
scripting folder date
If I use the following script -->
Const CONVERT_TO_LOCAL_TIME = True
Set dtmStart = CreateObject("WbemScripting.SWbemDateTime")
dtmStart.SetVarDate Now, CONVERT_TO_LOCAL_TIME
dtmRegular = dtmStart.GetVarDate(CONVERT_TO_LOCAL_TIME)
dtmNew = DateAdd("d", -37, dtmRegular)
Wscript.Echo dtmNew
wscript.quit
<--
I get an output something similar to 5/6/2007 10:11:10 AM
Is there a way to trim off the time information? I'm writing a script to
determine the date of a folder, and then if it is older than say 4 months,
delete it. Unfortunately, the time information is also there, and so the
script never deletes the folder.
Any Ideas how I can trim that time info off of there?
Thanks Tag: How to find a DFS root in a domain Tag: 206953
Hex program
Hi,
I want to know if there's any method to open a file in Hex with
VBScript
Thx
Omar Abid Tag: How to find a DFS root in a domain Tag: 206945
Need a vb-script to read user + data (phone-number etc.) from active
We need a dynamic phone list for an internal website with user-names and
corresponding phone number. to keep administrative effort low it would
be best to generate it automatically from active directory entries.
has anyone a script that can do that? eventually another one to search
data for a given name?
thx, mk (ts) Tag: How to find a DFS root in a domain Tag: 206941
Parse text find match extract line
I am looking for a way to loop through a file and do the following
(vbs script?)
1) Find string match A, then move down 4 lines and save the contents
of that new line (Line 5)
2) Find string match B then save that same line
Save 1 and 2 above to a new file, separated by a comma.
For example if a file looks like this:
*********************
HEADER_BEGIN
header1line1
header1line2
header1line3
header1line4
HEADER_END
DATA_BEGIN
data line1
data line2
data line3
DATA_END
HEADER_BEGIN
header2line1
header2line2
header2line3
header2line4
header2line5
header2line6
HEADER_END
DATA_BEGIN
data line1
data line2
data line3
DATA_END
****************
Tricky because the headers may be different lengths (some 3 lines,
some 10 lines)
"HEADER_BEGIN" is always the same. (I want the 4th line underneath)
"data line3" is always the same (I want this whole line)
My output file would read like this:
********
header1line4, data line3
header2line4, data line3
**********
I've spent hours searching for answers and have been unsuccessful.
File is thousands of lines long. I have hundreds of files in one
folder. (Ideally I could loop through all the files) Tag: How to find a DFS root in a domain Tag: 206939
Register event sink in Exchange
Hello!
I'm working on my first event sink, written in VBScript.
Following some examples found in the Web I was able to write a simple
script, which should check every new message and if it finds a known
value in TO: field, write a mail to the sender (something like an
out-of-office but selective).
Now I'm trying to register my script in Exchange, I followed the steps
in this KB article:
http://support.microsoft.com/kb/895239
but when I try to send this command:
C:\Scripts>cscript regevent.vbs add OnSave ExOleDB.ScriptEventSink.1
"file://./BackOfficeStorage/mycompany.local/MBX/kurtz" -m deep -file
"c:\scripts\autoreply.vbs"
I always get this error:
Error Opening Connection : -2147217895 Unable to find an object or
data correspondly to name, interval or selection criteria specified
(I'm translating from my language...)
I'd like to connect my script only to my mail folder (named kurtz).
Where Am I wrong?
Thanks!
PS: Maybe this isn't the correct NG? Better in exchange ng? Tag: How to find a DFS root in a domain Tag: 206938
Copying a Link's Target File
I want to:
1. iterate through a folder of shortcuts
2. Get the target path
3. Copy the target file back to the folder of links.
Here is my attempt. Any suggestions?
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolderOfLinks = oFSO.GetFolder("C:\Documents and Settings\Dan
\Desktop\Links")
Set colFiles = oFolderOfLinks.Files
For Each oFile in colFiles
If strcomp(right(oFile.name,4),".lnk", vbTextCompare) = 0 Then
Set oLink = oFile.TargetPath
Set oLinkedFile = oFSO.GetFile(oLink)
oLink.Copy oFolderOfLinks
End If
Next Tag: How to find a DFS root in a domain Tag: 206937
get event log NAMES
Hello,
I have a script for backing up and clearing log files. I was
wondering... is there any way (WQL perhaps) to get the names of the
event logs. In the domain, there are domain controllers and member
servers. The domain controllers have 6 physical logs and the member
servers have 3 physical logs. It would be cool to create a collection
which holds all the event view logs on the host automatically --
instead of hardcoding event log names or maintaining two different
scripts where the only difference is the number of *.evt files.
I tried looking at some of the very verbose scriptomatic stuff but
didn't see a method to get all the event log names off of a host.
Suggestions are greatly appreciated! Tag: How to find a DFS root in a domain Tag: 206932
octet string - Echo or Dump Contents
How Echo the value of the Attrib. I do not need to convert to a string. I
just need the HEX raw data. FYI the attrib is extensionData(SmartDL Filter)
Thanks in Advance...
RT Tag: How to find a DFS root in a domain Tag: 206928
VBScript Working Progress
Hi
Does anyone know how to make to IE progress bar to display the VBScript
running progress?
Kururu Tag: How to find a DFS root in a domain Tag: 206925
Including STYLE tag in script
I am creating an InternetExplorer object to show progress. I am trying
to hide the scrollbars and can do this via CSS but do not know how to
include this in the script. How can I include this: <STYLE TYPE='text/
css'><!--body {overflow:hidden}--> to get rid of the scrollbars?
objExplorer.Document.style.innerhtml? Tag: How to find a DFS root in a domain Tag: 206909
Retrieving two (or more) Arguments from a Text File
hello,
i've a script that read line and return line as argument
_______________________________________________
Const ForReading = 1
Set objDictionary = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("list.txt", ForReading)
i = 0
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
objDictionary.Add i, strNextLine
i = i + 1
Loop
For Each objItem in objDictionary
StrComputer = objDictionary.Item(objItem)
msgbox strComputer
Next
________________________________________________________
return line by line the content of list.txt file.
10.119.1.1;i'mfirstcomouter
10.119.1.2;i'mSecondcomputer
10.119.1.3;i'm...........
Is possible to have 2 (or more) arguments with input file separated by ;
or other symbol ?
Thank you for any suggestions,
A. Tag: How to find a DFS root in a domain Tag: 206906
Learn scripting from scratch (VB) wich study book ?
Trying to find out what the best study book is to learn scripting (VB) from
scratch, Need a good study book.
Which one ??
Rik Tag: How to find a DFS root in a domain Tag: 206904
Serious HTA/CSS Help...
I'm trying to use show/hide layers with CSS to make something like a
tabbed interface for my HTA. I found and modified a nice bit of
javascript and CSS that uses changes the "display" property of some
div tags to either "block" or "none". I'm been using it on my website
(thepip3r.com) -- you can see it working if you click projects -> HTAs
-> RunAs_Admin. That tabbed interface is what I'm trying to
incorporate into my HTA. The problem is that I got all of the code
into my HTA and CSS files for the HTA but when I run the HTA, all of
my Div tags are displayed at the start instead of not displaying like
the display:none property does on my site. I'm not sure what's going
on or if CSS is just qwerky with HTAs.
I've verified that my div display property is initially set to "none"
and that my javascript function is correctly setting only layer1's
display property to "block" on the initial page load. So I'm not sure
where my problem lies. If anyone can offer any insight, please do so
-- i'm at a loss.
Also... ironically, even though the page shows everything as "block"
on the inital HTA load, once you start clicking the layer tabs, each
div starts disappearing like it's supposed to be doing so I have no
idea what I'm doing wrong if anything.
Thanx in advance. Tag: How to find a DFS root in a domain Tag: 206895
Script will not continue - Please Help!!!
What I want to happen it to open the Adobe Reader, print a PDF, then
continue on my merry way. What happened is that the reader would not
close after the file printed. I looked on the net and found that this
is a common problem with AcroRd32.exe. So, I thought I would try to
kill the process after the file printed. The code to kill the process
works, but I cant get that far. Once the PDF opens, the script waits
and will not continue until Adobe closes. Once I manually close Adobe
my "OK" message comes up and the code continues. I can't figure out
how to make this work. Can someone please help. This is the code
that I am using.
Function printPDF ( exportName )
set wshShell = CreateObject( "WScript.Shell" )
cmdLine = """" & "AcroRd32.exe" & """" & " /t " &_
"""" & exportName & """" & " " &_
"""" & "Kyocera Mita KM-4035" & """" & " " &_
"""" & "Kyocera Mita KM-4035" & """" & " " &_
"""" & "IP_XXX.XX.X.XX" & """"
'msgbox cmdLine
ok = wshShell.Run( cmdLine, 1, true )
set wshShell = Nothing
msgbox "OK"
'kills the adobe process
Dim objWMIService, objProcess, colProcess, strComputer,
strProcessKill
strComputer = "."
strProcessKill = "'AcroRd32.exe'"
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery ("Select * from
Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
objProcess.Terminate()
Next
End Function Tag: How to find a DFS root in a domain Tag: 206890
problems comparing bytes
Hi,
Next problem in an ongoing saga of trying to work with binary files
in VBS. I've created a function in VB6 to read an original copy of a
file and return it in blocks so that I can compare it to the same file
in an ODBC data source.
Public Function GetBytesFromFile(bytesReadTotal As Variant, _
blockSize As Variant, _
FILE As Variant) As Byte()
On Error GoTo EH
Dim offset, size As Long
Dim fileIndex As Integer
Dim arrBin() As Byte
offset = CLng(bytesReadTotal) + 1
size = CLng(blockSize)
FilePath = CStr(FILE)
ReDim arrBin(size - 1)
fileIndex = 1
Open FilePath For Binary Access Read As #fileIndex
Get #fileIndex, offset, arrBin
Close
GetBytesFromFile = arrBin
Exit Function
EH:
MsgBox Err.Number & ": " & Err.Description & vbNewLine &
Err.Source, vbCritical
Resume Next
End Function
I'm calling this once for every block of data read, and then comparing
it to the database copy, but i can't get past the second Byte,
withough it failing as so...
"Invalid procedure call or argument: 'Asc'"
iReturn = TestFunctions.GetBytesFromFile(bytesReadTotal, _
blockSize, FILE)
msgbox "data type is: " & typeName(iReturn)
' type is "Byte()" as expected
msgbox "length of iReturn: " & LenB(iReturn)
' len is 4 bytes as expected
temp = Chr(Asc(MidB(iReturn, 3, 1)))
' Bytes one and two go through this fine, but bytes 3 and 4 cause the
above error.
The block coming from the database does the same thing at the same
place. Since a byte is notihng but a number 0-255 what could cause
the assignment to fail?
Thank You
Eric Tag: How to find a DFS root in a domain Tag: 206874
Anyone here have InstallShield experience and knows WMI scripting?
Hello,
I've asked this question in the InstallShield forums but haven't got a
reply that is the least bit cogent.
I'm making a project that will be a Windows service. I also want this
project to be zero configuration on the user end after install. I
need to manipulate the service after install and though doing that via
WMI would be a slam dunk.
I'm not going to post the whole script. But my VBScript has these two
lines:
Dim objWMI : Set objWMI = GetObject("winmgmts:\\" & sName & "\root
\CIMV2")
Dim objService : Set objService =
objWMI.Get("Win32_Service.Name='Message Handler Service'")
In the second line, InstallShield does not like the "objWMI.Get"
part. This script runs fine from the desktop but not from within my
*.msi file. Does anyone know of a workaround?
Suggestions are greatly appreciated! Tag: How to find a DFS root in a domain Tag: 206864
Writing a script to monitor system tasks and shutdown process
Hello Everyone;
I would like to write a script that monitors, on my command, the system
performance to track down programs that eat up too many system resources;
also, another script that monitors the system shutdown process to see if
something crashes or won't shutdown and let the computer power down.
Now, I a little about scripting, but nothing about the classes or objects
embedded within the scripts to accomplish these tasks. Does anyone know of
such items that can be envoked within the script and be used to monitor
these actions?
Any input is highly appreciated.
Thank you;
Bray. Tag: How to find a DFS root in a domain Tag: 206861
Hi all,
Does any one know how to find the DFS root in a Domain using VBscript.