Where can I ask for help with javascript ?
Hi,
Not sure if this is the correct forum, but this is my question. The
following script (onblur) will validate a field for it to be (mm/dd/yyyy),
if user enters the date in such format then user is allowed to go to the
next field, otherwise displays an alert.
The problem with the script is that if user just leaves field blank it still
displays the alert, I need to tweak it so that when user leaves the field
blank nothing happens. Perhaps some master in Javascript could help out ?
This is the code
--------
<script type="text/javascript">
<!--
function validateDate(fld) {
var RegExPattern =
/^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\
(?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\
[AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;
var errorMessage = 'Please enter the date in the required format
(mm/dd/yyyy)';
if ((fld.value.match(RegExPattern)) && (fld.value!='')) {
;
} else {
alert(errorMessage);
fld.focus();
}
}
//-->
</script>
---------
Thanks in advance,
Alejandro Tag: Script for scanning the structure of the AD Tag: 197537
bits query
we use bits for our large downloads so i was pleased to find bitsjob.vbs in
the technet mag august. But how do i use it? I'm scipting dumb. Please help. Tag: Script for scanning the structure of the AD Tag: 197536
edit text file
Hello
i have to edit a text file.
the task is:
i have a text file which is located at c:\windows.., i will have to replace
the ip 172.18.52.10 to 175.45.52.63 .It is always a replace the IP and save
it and the IP is always found at the end of text file.
Can you please give me some tips of how i can do that in VBscipt
Thx in advance
Nazeedah Tag: Script for scanning the structure of the AD Tag: 197532
Excel scripting
Hi,
I have written a script that reads value from Excel & "should terminate"
when blank cell is encountered.
However, even the script that is posted on the site does not get terminated
"immediately" when the blank cell or row is encountered.
It terminates only after the blank row is passed for one time.
How can i make the script terminate "immediately" when it encounters blank
row. It should not read that row at all.
Following is a sample script from the site :
=========
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open _
("C:\Scripts\New_users.xls")
intRow = 2
Do Until objExcel.Cells(intRow,1).Value = ""
Wscript.Echo "CN: " & objExcel.Cells(intRow, 1).Value
Wscript.Echo "sAMAccountName: " & objExcel.Cells(intRow, 2).Value
Wscript.Echo "GivenName: " & objExcel.Cells(intRow, 3).Value
Wscript.Echo "LastName: " & objExcel.Cells(intRow, 4).Value
intRow = intRow + 1
Loop
objExcel.Quit
=============
Any help on terminating immediately after it encounters blank row would be
much appreciated.
thanks in advance ... Tag: Script for scanning the structure of the AD Tag: 197529
Multilingual support in Len method
Hi,
I am writing a website that should support Hebrew & English (as well as
other languages).
I need to know the simple character count (not byte count!) of a
string.
When I am using the Len(str) method (with string variable as input), I
receive the following:
- English strings return the exact number of characters.
- Hebrew strings return the UTF-8 byte count.
I would like to know the number of characters in the string in both
cases, in order to cut long strings, but actually Hebrew strings are
cut differently than English strings.
I am aware of the fact that all strings are UNICODE, but I am not
interested in their byte count - only character count.
Thanks,
Gabi Tag: Script for scanning the structure of the AD Tag: 197528
logon script for an examination account
In Alberta, high schools have what are called diploma exams. Some of these
exams are written on computer. The basic setup is that students log on to a
generic account. That account then loads a Word file called dipoma.doc.
Diploma.doc has a footer. The students replace the line XXXXXX in the
footer with their six digit student id. Then, they are told to use Save-As
to give the file a uniqe name. The word doc also automatically saves every
five minutes and is formatted with a specific font and size and double line
spacing. We used to have the students save to a directory called diploma on
the local drive. But then I had to make another script to delete the
diploma directory on each computer after each exam. Also, we have now put
Deep Freeze on the computers and some of the computers don't have a 'thaw
space'. So, what I'd like to do is create a server share like
\\server\diploma$. I know how to set up the share and ntfs settings so
students can save to that directory and only see their doc. But I'm
wondeering if it would be easy, as the students logon with the generic
account of 'diploma', to create a vbscript that:
1. asks the students to input their student id
2. then creates a directory in \\server\diploma$ named by their student id.
3. copies the diploma.doc to the student's sub directory and renames it
XXXXXX.doc (their student id obviously)
4. then opens the doc for the students to start witting the exam
Thanks,
Jeremy Tag: Script for scanning the structure of the AD Tag: 197522
Running a script against an OU
In the following script, what do I have to put in place of "atl-ws-01" to
run the script against an OU called lab1? Can I use the distinguished name?
Or would it be easier to run it with a GPO?
strComputer = "atl-ws-01"
Set objUser = GetObject("WinNT://" & strComputer & "/Administrator, user")
objUser.SetPassword "09iuy%4e"
objUser.SetInfo Tag: Script for scanning the structure of the AD Tag: 197516
Find user group membership
I am using this script to check to see if a user exists in AD. Since there is
already a connection to AD would it be possible to check for group membership
at the same time??...and if so..how?
Thanks
input = inputbox("Enter UserID")
if UserExists(Input,sDisplayName) then
wscript.echo "Found " & sDisplayName
else
wscript.echo "Not account found for 'Dave'"
end if
Function UserExists(sUser,sDisplayName)
Dim oConnection, oCommand, oRoot, sDNSDomain, sQuery, sFilter, oResults
UserExists = False
sDisplayName = sUser
On Error Resume Next
' Use ADO to search the domain for all users.
Set oConnection = CreateObject("ADODB.Connection")
Set oCommand = CreateObject("ADODB.Command")
oConnection.Provider = "ADsDSOOBject"
oConnection.Open "Active Directory Provider"
Set oCommand.ActiveConnection = oConnection
' Determine the DNS domain from the RootDSE object.
Set oRoot = GetObject("LDAP://RootDSE")
sDNSDomain = oRoot.Get("DefaultNamingContext")
sFilter = "(&(ObjectClass=user)(ObjectCategory=person)(samAccountName=" &
sUser & "))"
sQuery = "<LDAP://" & sDNSDomain & ">;" & sFilter & ";displayName;subtree"
oCommand.CommandText = sQuery
oCommand.Properties("Page Size") = 100
oCommand.Properties("Timeout") = 30
oCommand.Properties("Cache Results") = False
Set oResults = oCommand.Execute
Do Until oResults.EOF
if oResults.Fields("displayName") <> "" then
sDisplayName = oResults.Fields("displayName")
UserExists = True
End if
oResults.MoveNext
Loop
On Error Goto 0
End Function Tag: Script for scanning the structure of the AD Tag: 197509
Find User Group Membership
I am currently using this script to verify that a user exists in AD and was
wondering if since there is already a connction to AD if I could also verify
group membership for that user at the same time.
input = inputbox("Enter ID")
if UserExists(Input,sDisplayName) then
wscript.echo "Found " & sDisplayName
else
wscript.echo "No account found for" & Input
end if
Function UserExists(sUser,sDisplayName)
Dim oConnection, oCommand, oRoot, sDNSDomain, sQuery, sFilter, oResults
UserExists = False
sDisplayName = sUser
On Error Resume Next
' Use ADO to search the domain for all users.
Set oConnection = CreateObject("ADODB.Connection")
Set oCommand = CreateObject("ADODB.Command")
oConnection.Provider = "ADsDSOOBject"
oConnection.Open "Active Directory Provider"
Set oCommand.ActiveConnection = oConnection
' Determine the DNS domain from the RootDSE object.
Set oRoot = GetObject("LDAP://RootDSE")
sDNSDomain = oRoot.Get("DefaultNamingContext")
sFilter = "(&(ObjectClass=user)(ObjectCategory=person)(samAccountName=" &
sUser & "))"
sQuery = "<LDAP://" & sDNSDomain & ">;" & sFilter & ";displayName;subtree"
oCommand.CommandText = sQuery
oCommand.Properties("Page Size") = 100
oCommand.Properties("Timeout") = 30
oCommand.Properties("Cache Results") = False
Set oResults = oCommand.Execute
Do Until oResults.EOF
if oResults.Fields("displayName") <> "" then
sDisplayName = oResults.Fields("displayName")
UserExists = True
End if
oResults.MoveNext
Loop
On Error Goto 0
End Function
Thanks Tag: Script for scanning the structure of the AD Tag: 197508
Monitoring Server Availability Script
Ok, let me start off by saying that I am not a pro by any means at making
these scripts, I combined 2 together to get the functions I wanted.
My only problem with this script is that I get the email every time, even
when I know the server is up and running. Is there something wrong in there
that is causing this? Any help is greatly appreciated. Thanks.
url="http://www.contoso.com"
on error resume next
Set objHTTP = CreateObject("MSXML2.XMLHTTP")
Call objHTTP.Open("GET", url, FALSE)
stat=objHTTP.status
if not stat="200" then
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "www.contoso.com is DOWN"
objMessage.Sender = "mrussell@contoso.com"
objMessage.To = "mrussell@contoso.com"
objMessage.TextBody = "WEBSITE IS DOWN"
'==This section provides the configuration information for the remote SMTP
server.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"mail.lifeclinic.com"
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
objMessage.Send
end if Tag: Script for scanning the structure of the AD Tag: 197503
Monitoring Server Availability Script
This is the script that I made, and I will freely admit that I'm not a pro by
any means at making them. The domain names have been changed obviously. My
only problem is that every time the monitor runs I get an email even though I
know the site is still up. Is there something wrong there that is telling it
to send the message no matter what? Any help is greatly appreciated. Thanks.
url="http://www.contoso.com"
on error resume next
Set objHTTP = CreateObject("MSXML2.XMLHTTP")
Call objHTTP.Open("GET", url, FALSE)
stat=objHTTP.status
if not stat="200" then
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "www.contoso.com is DOWN"
objMessage.Sender = "mrussell@contoso.com"
objMessage.To = "mrussell@contoso.com"
objMessage.TextBody = "WEBSITE IS DOWN"
'==This section provides the configuration information for the remote SMTP
server.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"mail.lifeclinic.com"
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
objMessage.Send
end if Tag: Script for scanning the structure of the AD Tag: 197501
Run a command from VB Script
I am trying to run the following command
WsShell.Run ("WinSCP3.exe secureSFTP /console /script=fsftp.txt")
WsShell is an instance of WScript of course. I need a way for the vbs to
wait for the command to finish before it gets back the control and the next
line is executed, but vbs is taking back control too early and my command is
not running. How can I accomplish such thing? Sleep is not working.
Thanks,
--
Leo Selmani Tag: Script for scanning the structure of the AD Tag: 197500
Encryption with vbs and capicom
Hi I'm looking for a solution to encrypt data with vbs and capicom and
decrypt with java. Encrypt the data with capicom is quite easy but the
encyption on the java site seems not to be easy.
For the encyption we used the AES 256bit Alogrithm.
Does someone have an idea how we could solve the problem encrypting in
vbs - decrypting in java?
Thanks
michel Tag: Script for scanning the structure of the AD Tag: 197498
Script works on XP and not on NT Trying to write to the registry
Well I have a script that is working fine under XP but it doesnt want
to work under NT. I am trying to write a multi String value in the
registry.
const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath = "SOFTWARE\Patchlink.com\Gravitix\Agent\Policy"
MultValueName = "DriveExemption"
strComputer = "."
iValues = Array("F:\", "G:\", "H:\", "I:\", "J:\", "K:\",_
"L:\", "M:\", "N:\", "O:\", "P:\", "Q:\", "R:\",_
"S:\", "T:\", "U:\", "V:\", "W:\", "X:\", "Y:\", "Z:\" )
Set oReg=GetObject( _
"winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
oReg.SetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath,_
MultValueName,iValues
Any Ideas?
Thanks
Ryan Tag: Script for scanning the structure of the AD Tag: 197496
cscript
I am new to using cscript and am trying to debug a script. I can start the
debugger using a command like "cscript //x myscript.vbs". That seems to work
fine and the debugger stops on the line that has a problem and asks me if I
wish to Break or Continue. (I always choose Break).
My question is that when I use the Stop Debugging menu option, I get a
window asking me whether I want another instance of the debugger or use the
existing instance. No matter which I choose, my script is restarted in that
instance and continually stops on the bad statement. In essence, it appears
that there is a loop that will not allow the original debugger instance to
stop and allow me to edit the offending statement.
Is this "normal" or am I missing something?
Thanks. Tag: Script for scanning the structure of the AD Tag: 197495
VBS script scheduling problem
I have a VBS script that I have scheduled to run every 30 minutes, between
5AM and 11PM. The problem I am having is if the internet connection is down
(it is being worked on, so it happens a fair amount), then the script fails
and then doesn't run again until after the server is restarted (which is
next to never). How can I build my script to fail gracefully, and keep
running even if the internet is down?
Here is my script,
'Script for downloading NOAA weather XML data and inserting it into DB
'Start downloading file
sSource = "http://www.weather.gov/data/current_obs/KHLX.xml"
sDest = "\\SWVTC06\inetpub\intranet\rss\weather.xml"
set oHTTP = WScript.CreateObject("Microsoft.XMLHTTP")
set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
oHTTP.open "GET", sSource, False
oHTTP.send
body8209 = oHTTP.responseBody
set oHTTP = nothing
sOut = ""
For i = 0 to UBound(body8209)
sOut = sOut & chrw(ascw(chr(ascb(midb(body8209,i+1,1)))))
Next
set oTS = oFSO.CreateTextFile(sDest, True)
oTS.Write sOut
oTS.Close
set oTS = Nothing
set oFSO = Nothing
'Done downloading file
'Start inserting file into DB
'Parse XML and set variables
Dim mydoc
Set mydoc = WScript.CreateObject("Microsoft.XMLDOM")
mydoc.async=false
mydoc.load("\\swvtc06\inetpub\intranet\rss\weather.xml")
If mydoc.parseError.errorcode<>0 then
MsgBox(mydoc.parseError.errorcode & "<br>")
MsgBox(mydoc.parseError.reason & "<br>")
MsgBox(mydoc.parseError.srcText & "<br>")
MsgBox(mydoc.parseError.URL & "<br>")
Else
dim
wTime,wWeather,wTemp,wHumidity,wWindString,wWindDir,wWindDegrees,wWindMPH,wWindGust
dim wPressure,wDewpoint,wHeatIndex,wWindChill,wVisibility,wPic,wInsertTime
Set objLst = mydoc.getElementsByTagName("*")
wTime = objLst.item(13).childNodes(0).text
wWeather = objLst.item(15).childNodes(0).text
wTemp = objLst.item(16).childNodes(0).text
wHumidity = objLst.item(19).childNodes(0).text
wWindString = objLst.item(20).childNodes(0).text
wPressure = objLst.item(27).childNodes(0).text
wDewpoint = objLst.item(28).childNodes(0).text
wHeatIndex = objLst.item(31).childNodes(0).text
wWindChill = objLst.item(34).childNodes(0).text
wVisibility = objLst.item(37).childNodes(0).text
wPic = objLst.item(39).childNodes(0).text
wInsertTime = Now
End If
dim Conn
dim strSQL
set Conn = CreateObject ("ADODB.connection")
Conn.Open "driver={SQL Server};server=swvtc06;Trusted_Connection=Yes;Initial
Catalog=Weather"
strSQL = "INSERT INTO
Weather(Weather,Temperature,RelativeHumidity,WindString,Pressure,Dewpoint,HeatIndex,WindChill,Visibility,Icon,ObsTime,InsTime)
VALUES ('" & wWeather & "','" & wTemp & "','" & wHumidity & "','" &
wWindString & "','" & wPressure & "','" & wDewpoint & "','" & wHeatIndex &
"','" & wWindChill & "','" & wVisibility & "','" & wPic & "','" & wTime &
"','" & wInsertTime & "')"
'MsgBox strSQL
objRS = Conn.Execute(strSQL)
Thanks,
Drew Tag: Script for scanning the structure of the AD Tag: 197490
Script to add a wireless network
Hi there
Does anyone know of a script that can be run to manually add details of a
wireless network to XP SP2 machines? All with wireless being managed by
windows.....
Many thanks
Phill Tag: Script for scanning the structure of the AD Tag: 197489
VB to read a file to work out what it really is
Hi guys,
I am downloading a lot of jpg files from the web for a project the only
problem is sometimes they are bitmap files with the wrong file
extension. Windows appears to be cool with this however the script
loads them into photoshop which just makes the whole thing fall over.
Is there a way using windows scripting to check that a jpg is actually
that and if not to spit the file out and not process it.
Many thanks in advance. Tag: Script for scanning the structure of the AD Tag: 197488
Write long string variable to disk
Hi VBS gurus.
I've run into an issue with a function which writes a long string to
disk using the FSO.
It errors out on the "tf.Write" statement.
Your help is appreciated.
'//==============BEGIN of CODE============
Function wrFile(strFileName, strFileContent)
Dim strDirPath
Dim fso, tf
'// Set the ouput directory
strDirPath = GetTmpDir()
'// Write the output
Set fso = CreateObject("Scripting.FileSystemObject")
Set tf = fso.CreateTextFile(strDirPath & strFileName, True)
WScript.Echo Left(strFileContent, 200)
tf.Write (strFileContent)
tf.Close
End Function
'//==============END of CODE============
The wrFile() function is called from the following code. As you can
expect the "strFileContent" variable is a long string containing line
breaks, carriage returns etc.
'//==============BEGIN of CODE============
'// Get the source info
Set objHTTP = CreateObject("Msxml2.XMLHTTP.4.0")
With objHTTP
.open strURLMethod, strURL, False
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.send strURLvars
strHTTPresp = .responseText
End With
'// Cleanse the info
<-- SNIP a whole bunch of RegEx statments -->
'//Write the info
wrFile("OutputFile.txt", strHTTPresp)
'//==============END of CODE============ Tag: Script for scanning the structure of the AD Tag: 197487
VBA-Problem with AD-User-Properties containing hyphens
I have to assign values to several existing AD-User-Properties, for
example "fen-UM-AllowCoversheetOverride".
As they contain hyphens, I put them in square brackets (view article
http://groups.google.de/group/microsoft.public.scripting.vbscript/browse_th=
read/thread/738be478df9267f8/2fbb6c217bfe9e26?lnk=3Dgst&q=3Dhyphen&rnum=3D1=
#2fbb6c217bfe9e26).
This works fine in VB-Script, but not in VBA (Excel):
objUser.[fen-UM-AllowCoversheetOverride] =3D False
What I get is Runtime-Error 438 "Property or Method not supported"
(the english version could be different, original message in german is
"Objekt unterst=FCtzt diese Eigenschaft oder Methode nicht")
Other properties without hyphens are processed correctly.
Any ideas?
tia
Peter Tag: Script for scanning the structure of the AD Tag: 197486
how can get the netbios name of current domain before user logon?
hello,
I need a vbs snippet which can get the netbios name of current domain before
user logon.
the below snippet can't work since user is not logon:
Set oWshNetwork = WScript.CreateObject("WScript.Network")
stDomainName =oWshNetWork.userDomain
how to achieve the function by other way ?
-- Tag: Script for scanning the structure of the AD Tag: 197485
Autoreboot during Machine Startup Script
Hi Guys
My last Web based post died upon submit so apologies if this appears twice.
I have a requirement to restart some workstations after removing some
registry entries and a service. My reboot code works under interactively
logged on user privileges but not under the security context of the startup
script (SYSTEM?).
The code executes fine without raising any errors but doesnt reboot. There
are no "On Error Resume Next" statements in the code and I have removed all
error handling. Any ideas?
Function ShutDown()
sComputerName = "."
Set oWMI = GetObject("winmgmts:" &
"{impersonationLevel=impersonate,(Shutdown, RemoteShutdown)}!\\" &
sComputerName & "\root\cimv2")
Set colOperatingSystems = oWMI.ExecQuery("Select * from
Win32_OperatingSystem")
' Attach to the first OS object
For Each obj in colOperatingSystems
obj.Win32Shutdown(6)
Next
End Function Tag: Script for scanning the structure of the AD Tag: 197480
Autoreboot during GPO Machine Startup Script
Hi Guys
I have a requirement to remove some registry entries, modify some files and
remove a service on a range of computers. I have decided to implement this in
a computer startup script delivered via a GPO.
My code works under a logged in user's context but doesn't seem to work in
the security context of a startup script (SYSTEM?).
The code executes and doesn't raise any errors but doesn't perform the last
step which is the reboot. I have turned on some additional event audfit
logging but do not see any failures. Anyone got any ideas?
The reboot function is below and I have removed out the error handling and
logging bits for clarity.
Function ShutDown()
sComputerName = "."
Set oWMI = GetObject("winmgmts:" &
"{impersonationLevel=impersonate,(Shutdown, RemoteShutdown)}!\\" &
sComputerName & "\root\cimv2")
Set colOperatingSystems = oWMI.ExecQuery("Select * from
Win32_OperatingSystem")
For Each obj in colOperatingSystems
obj.Win32Shutdown(6)
Next
End Function Tag: Script for scanning the structure of the AD Tag: 197479
Send email alert when file is modified
Is there a way for a script to send me an email message anytime a particular
file is modified? I already have code to send an email alert - I just need
the logic that periodically checks the file and sends the alert if it has
been modified. Tag: Script for scanning the structure of the AD Tag: 197473
Script to run schedule tasks
Hi all,
Can anyone help me with a script that can run a schedule task and also that
automatically press the specific button in the program that run the program.
For example, I want to a script to schedule and run SpyBot and automatically
press the "Check for problems" button in SpyBot program.
Thanks in advance!
Jason
--
Double Trouble Tag: Script for scanning the structure of the AD Tag: 197468
Search text file
Hello,
Just cannot think straight at the moment. I have an employee table in
.csv fomat where the far left column is everyone's unique emplyee ID
and the column to the right has the employee Id of their manager -
basically a one to many realationship. I just can't think of how to
this...maybe an array or dictionary object? I am very adept at using
them.
Thanks for any help provided.
Tim Tag: Script for scanning the structure of the AD Tag: 197456
Retrieving current time from remote servers
Hello,
I am looking for a simple way of retrieving the current time from
remote Windows NT/2000 servers using vbScript. I am presently using the
Win32_LocalTime class to retrieve the current time from Windows 2003
servers, but have found that this class is not supported on Windows
NT/2000.
Any help would be greatly appreciated. Tag: Script for scanning the structure of the AD Tag: 197454
SQL and VBS
Dont know if this is the right group for this but i'll ask anyway.
What u want to achive is a very simple backup solution which copies our
daily SQL2000 database files to a network share.
This script runs on the server and just does a basic file copy.
The problem i have is we have 72 servers we want to roll this out to
but i have to change the network path for each one.
is there anyway to replace the added code to get the client computers
(where the backup files copy to) This setting is held in a table on the
SQL server.
Can i do a select statment to pick this value with the code below?
'Check to see if the folder exists on the PLUM server
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists("C:\FSO") Then
Set objFolder = objFSO.GetFolder("\\client pc name\c$\database
backups")
Else
Set objFolder = objFSO.CreateFolder("\\client pc name\c$\database
backups")
End If
'Copy the Database backup files to the PLUM server
dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.copyfile"D:\BACKUPS\*.*", "\\client pc name\c$\database backups\" Tag: Script for scanning the structure of the AD Tag: 197453
Removing quotes from a test file
Hi,
is there a function or simlpe way I can parse a value and strip the quotes
from it?
Example. I'm reading a CSV file, for some text fields (like a Display Name
with spaces in it) the whole field is surrounded with quotes (").
so when I get the value, the quotes are part of the string itself:
varName = "John Doe"
I can imagine some ways of removing the quotes (like using SPLIT or MID) but
is there a specific function for doing this?
Tks in advance Tag: Script for scanning the structure of the AD Tag: 197452
Script To Log Moved Files
Am using the script below to move files from one folder to another. Does
anyone know what I should add to it to have it create a text file that
appends to itself and should what was moved.
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFile "C:\LOC1\test.wav" , "C:\LOC2\" Tag: Script for scanning the structure of the AD Tag: 197447
array help, plase
How Can I set this to use an array in the PATH STATEMENT
arrComputers = Array("SRVR1", "SRVR2", "SRVR3")
For Each strComputer In arrComputers
Set MyFile= fso.CreateTextFile("C:\B\" & strComputer & ".csv", True)
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
' ***** THIS NEXT SECTION IS WHERE THE PROBLEM IS *******
arrPATH = Array("D:\SQLData\MSSQL\Data", "L:\Backup\Data-Log",
"L:\SQLData\MSSQL\LOG")
FOR EACH strPATH in arrPATH
Set colFileList = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='strPATH'} Where " _
'<<strPATH here causes error in next for statement
& "ResultClass = CIM_DataFile")
' ******If strPATH is replaced with an actual path like C:\ then it works
For each objFile In colFileList
str = str&objFile.FileName&","& objFile.Extension
&","&objFile.FileSize&VBCRLF
Next
Wscript.echo str ' testing use....
Next
MyFile.WriteLine(str)
MyFile.Close
Next Tag: Script for scanning the structure of the AD Tag: 197442
Run remote process
I am trying to run a process, like notepad, on a remote computer. I can do
this successfully HOWEVER, I want to know if it is possible at all to run
this process on a user account that is logged in so if i run notepad it will
open it up on their screen?
so if I'm logged in right now....I run a script from a remote computer
telling this local computer to open notepad - is it possible to open it in
that user account so the user can see it (displayed infront of them)? Tag: Script for scanning the structure of the AD Tag: 197440
Delete old profiles
in need of a vbscript deleting all old profiles older than 30 days and
exlcude particular profiles, such as Administrator.
--
Andrea Tag: Script for scanning the structure of the AD Tag: 197433
delete old profiles
I am looking for a vbscript in which it will delete all profiles older than
30 days but exclude specific profiles such as Administrator, All User.
Can you help?
--
Andrea Tag: Script for scanning the structure of the AD Tag: 197432
Delete old Profiles
I am trying to write a vbscript in which I will be able to delete all
Profiles older than 30 Days, but exclude particular profiles such as
Administrator, All Users.
Can you help?
--
Andrea Tag: Script for scanning the structure of the AD Tag: 197431
Convert Binary to String
I need to query the registry on workstations for a binary value, and write
the results to a file (as a string). Here is my code and the spot where it
blows up because the result is not a string. Please help me! Thanks....
PKComputerIP="xxx.xxx.xxx.xxx"
Const HKEY_LOCAL_MACHINE = &H80000002
Set oReg=GetObject("winmgmts:\\" & PKComputerIP & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\EAPOL\Parameters\Interfaces"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each subkey In arrSubKeys
wscript.echo subkey
strSubKeyPath = strKeyPath & "\" & subkey
strValueName = "1"
oReg.GetBinaryValue HKEY_LOCAL_MACHINE,strSubKeyPath,strValueName,strValue
'ERROR IS IN THE NEXT LINE!***********************
wscript.echo strSubKeyPath & "=" & cstr(strValue)
Next Tag: Script for scanning the structure of the AD Tag: 197428
screensaver
Does anyone know if it is possible to create a vbscript that launches a
webpage as a screensaver? Tag: Script for scanning the structure of the AD Tag: 197421
calling a batch file from a vbs script
I have been unable to find any resources on how to call a batch file from a
vbs script could you please help?
Dane
Danewman@ahrc.org Tag: Script for scanning the structure of the AD Tag: 197420
GPO script to create new System DSN
Hi, I am having trouble with a GPO Login script that is suppose to create a
new DSN connection for a SQL database, and it gets pushed to 700 plus PCs in
a WAN, that are either XP Pro SP2 or Win2000 SP?.
Here are the first five lines of the script, and it seems to error out on
the 5th line, for some users, but when connected as with and install admin
account (that pushes nothing) and run from explore, it accomplishes what it
needed. Sorry I don't have the error, but it says something about the
driver location. Can someone tell me is there a better way to write that
line, or even this whole process?? OR can anyone tell me what they think
might be the cause of an error like this, that only happens for some users,
and then works for admin
Dim oWshShell
Const cRegKey1 = "HKLM\Software\ODBC\ODBC.INI\NewSQL\"
Const cRegKey2 = "HKLM\Software\ODBC\ODBC.INI\ODBC Data Sources\"
Set oWshShell = CreateObject ("WScript.Shell")
oWshShell.RegWrite cRegKey1 &
"Driver","C:\%systemroot%\System32\sqlsrv32.dll" Tag: Script for scanning the structure of the AD Tag: 197414
Modifying AD users with an INPUT file
HI all, what I am trying to do is modify users profile tab properties
with an input file. The input file holds the User account names where
as the script will just be hardcoded with the changes. I have a scirpt
that queries group membership based on user input and then generates a
file with all users in that group.
Here is an example of the file.
HS1USER1
HS1USER2
HS1USER3
HS1USER4
HS1USER5
Now I I am trying to get a script that will modify the user profile tab
for the users in this file.
Here is what I have so far.
option explicit
Const ForReading = 1
Dim objconnection,objcommand,objRecordset,fso,
InputFile,struser,strDN,objuser
Set fso = CreateObject("Scripting.FileSystemObject")
Set InputFile = fso.OpenTextFile("C:\Temp\scripts\ADmember\hs1.txt",
ForReading, False)
'Set objTextFile = objFSO.OpenTextFile _
'("C:\Temp\scripts\ADmember\hs1.txt", ForReading)
Do until InputFile.AtEndOfStream
Set struser = Trim(InputFile.ReadLine)
wscript.echo struser
Const ADS_SCOPE_SUBTREE = 2
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
objCommand.CommandText = _
"SELECT distinguishedName FROM 'LDAP://dc=NHC' WHERE
objectCategory='user'" & _
"AND SAMAccountName=" & struser
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
strDN = objRecordSet.Fields("distinguishedName").Value
objRecordSet.MoveNext
Loop
Set objUser = GetObject("LDAP://" & strDN)
Wscript.Echo objUser.Name
objUser.Put "profilePath", "\\sea-dc-01\Profiles\myerken"
objUser.Put "scriptPath", "logon.bat"
objUser.Put "homeDirectory", "\\sea-dc-01\HomeFolders\myerken"
objUser.Put "homeDrive", "H:"
objUser.SetInfo
loop
InputFile.Close
I am not sure to be honest if I am on the right track or not. But i
keep getting an error that object required for String Hs1user1.
Any ideas or suggestions are appreciated.
Thanks Tag: Script for scanning the structure of the AD Tag: 197412
basic help to run an application from WSH
hello,
Apologies for such a basic question, but I've looked everywhere and
nothing is helping.
I'm just learning vbscript for wsh and here is my first script, saved
in file "<file>.vbs":
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "<file path of file.vbs>"
Where <...> is a full file path such as "c:\documents and
settings\[...]" etc.
When I run this by selecting the file I always get a
Script: <script file path>
Line: 2
Char: 1
Error: THe system cannot find the file specified.
Code: 80070002
Source: (null)
However if I just move the file to c:\, so the path is "c:\<file>" the
file opens.
Also if I cut and paste the exact file path from the script into the
Run box on the start menu, the file opens.
Any help with this?
Many thanks. Tag: Script for scanning the structure of the AD Tag: 197410
Using a Variable To Run A Function
Dear VBS Experts,
I'm trying to do something that I'm not sure is possible, so any
experienced input would be helpful. Basically, I have a web app that is
designed to accept user input. Based on the input, several variables are
sent to a central coordinating function (the vbs code will either be on the
ASP page itself, but more likely part of a COM+ object). One of the
variables that will be passed to this coordinating function is a number that
represents a certain piece of code that needs to be run against the remaining
variables. However, I want the code to reside in seperate .vbs files that
are not part of the application. The central function reads an .ini sub task
file that will show (based on the number in the first variable) the path to
the .vbs file to run when processing the input.
It probably sounds a little crazy already, but my purpose in this special
case is so that I can keep the actual source code (for a growing and dynamic
list of functions that I call sub-tasks), completely seperate from the ASP
application and any COM+ registered modules. My delimma is to find a way to
effectively call the individual .vbs files, run them against the variables
that were passed to the coordinating function in the ASP page, and return any
results from these .vbs files to the ASP application.
So far, I don't know of any way that I can use a returned result from a
function (such as the path to the .vbs file returned from the sub task .ini
file) to run another function by name, even if it was a registered COM+
object. So it seems that my only alternative is to call the .vbs files and
run them against the variables using the shell command. In doing so, is
there any way that I can return any error codes generated by the various .vbs
files that run? For example, if I shell the variables to a CreateADGroup.vbs
file from the coordinating function, is it able to return Active Directory
specific error codes or will it only return general error codes related to
the shell?
Any other ideas in ways of running, what you might call "off-line code",
from a sentral code function would be helpful. My only requirment is that
the actual task specific code be located in seperate .vbs files that do not
require them to be registered in COM+ modules. In some respects, running
these sub tasks in seperate threads has some advantages in terms of
distributed processing etc.
If anyone has some thought on how I can accomplish this, I'm all ears.
Rpz Tag: Script for scanning the structure of the AD Tag: 197405
need help with Now()
how can i make Now() return Now() + 3 hours?
my page uses Now() but it returns pacific time and i want to display
eastern.
thanks Tag: Script for scanning the structure of the AD Tag: 197401
I Can't call WScript object methods vhen using my script through H
Hi
I'm new in VBs and HTA scripting, so here's a newbie question.
Why can't I call e.g. the WScript.sleep method when calling my VBs function
through a HTA file? Tag: Script for scanning the structure of the AD Tag: 197395
using AbsolutePosition to take an action
Suppose you have a recordset, and a table where you show all the
"lines" of the recordset.
But you don't want to show a record, let's say the first. Or maybe you
want to show an additional text for that record (including a new
"<tr></tr> before the record for example)
No matther what the action would be, the thing is to make an action. My
idea was:
If pobjRs_LinInc.AbsolutePosition = 1 Then
' action
End If
But it does'nt work.Well, I just can't figure out how to use correctly
this property. Tag: Script for scanning the structure of the AD Tag: 197391
Ping Request in VBScript
Hi. I am trying to make a VBS file that pings my wireless router. I
want to be able to put this in my Windows Schedule (Start>Program
Files>Accessories>System Tools>Scheduled Tasks) that runs every 10
minutes. Is this possible and how would I go about doing this.
Thanks very much for your help. Tag: Script for scanning the structure of the AD Tag: 197388
want to learn scripting!
Hi Pro's,
im a novice exchange 2003 admin. im interested in learning vb scripting for
exchange administration. im new to programming too can anybody suggest me a
book or a resource where i can get a good platform for the same.
if this forum is not the right place to ask this question, please suggest me
one where i can get it.
thanks in advance. Tag: Script for scanning the structure of the AD Tag: 197387
window2003 server and interDev 6
My Win 2000 with IIS and interDev 6 worked fine. I installed Win 2003
server and interDev 6 (together with bachoffice componets "MD Data
Access", "Remote Machine Debuging", "Frond Page Server Extensions" and
"Visual InterDev Server" as I did in win2000). Now after starting
interDev and it can not connect to localhost. Can you give me any
advice? Tag: Script for scanning the structure of the AD Tag: 197384
Disable NetBIOS on backup NIC
We have multi-homed servers, with a public interface and a
second NIC dedicated to only backups. I would like to programmatically do the
following to only the backup interface:
disable client for Microsoft networks
disable file and print sharing
disable 'register this connections address in DNS'
Set 'disable NetBIOS over TCP/IP'
A future wish would be to confirm and/or set the binding order as well.
Anybody have the code?
(Doesn't have to be vb script - if netsh.exe or any other command-line
utility can do that, just as well!)
Thanks! Tag: Script for scanning the structure of the AD Tag: 197381
I want a script which scans the AD and outputs the structure of the Active
directory groups and users. Does anyone know of any script.