Getting time from a SNTP time server
Hi,
Is it possible to get time from a SNTP time server.
I need a script to receive the precise time from a time server to calculate
the difference with the locale (machine) time.
Thanks in advance,
Robertico Tag: VBScript and WebDAV Tag: 192438
VB Script Error
When I run this through group policy as a user script, I get an error at line
80 Char 3..... Permission Denied. Can anyone explain what may be
happening.... the script is trying to write a license file and .dll to a
Lotus Notes directory, but shouldn't any logon script be performed through
Domain Administrator privileges?
Here is a copy of the script.......
Option Explicit
Const EVENT_TYPE_SXS = 0
Const EVENT_TYPE_ERR = 1
Const EVENT_TYPE_WRN = 2
Const EVENT_TYPE_INF = 4
Const REG_KEY = "HKEY_LOCAL_MACHINE\SOFTWARE\Lotus\Notes\Path"
Const REMOTE_PATH = "\\mydomain.com\share"
Const TARGET_DRV = "G:"
Const TARGET_DIR = "\Midas LSX\"
Dim objShell
Dim objNetwork
Dim objFileSys
Dim objFileInstalled
Dim objFileTarget
Dim strNotesPath
Dim strFileArray
Dim strFileName
'// CREATED:
'// 04/12/2006
'//
'// AUTHOR:
'// Developer
'//
'// DESCRIPTION:
'// This script is intended to be used as a login script. It checks for the
presence
'// of a license file and the dll file comprising the Midas LSX (LotusScript
Extension)
'// for use in Lotus Notes client and server applications.
'// Create required WSH objects
Set objShell = CreateObject("WScript.Shell")
Set objNetwork = CreateObject("WScript.Network")
Set objFileSys = CreateObject("Scripting.FileSystemObject")
Call objShell.LogEvent(EVENT_TYPE_INF, "Attempting to verify Midas LSX
installation.")
'// Read the registry value for the Notes program directory
On Error Resume Next '// disable error reporting (e.g., if registry key
doesn't exist)
strNotesPath = objShell.RegRead(REG_KEY)
'// If Notes isn't installed, quit the script
If Len(strNotesPath) = 0 Then
MsgBox "Unable to read the following registry key:" & vbCr & vbTab &
REG_KEY & vbCr & "If this condition persists, please notify Networking
Support.", , "Unable to read registry key . . ."
Call objShell.LogEvent(EVENT_TYPE_ERR, "Login script - unable to read the
following registry key: " & vbCr & REG_KEY)
Call WScript.Quit()
End If
'// Attempt to map network drive
On Error Resume Next '// disable error reporting (e.g., if drive is in use)
Call objNetwork.MapNetworkDrive(TARGET_DRV, REMOTE_PATH)
'// Re-enable error reporting
On Error GoTo 0
'// Create an array of the target file names
strFileArray = Array("licmidas.lic", "nlsxrtc.dll")
'// Initialize file objects to nothing
Set objFileInstalled = Nothing
Set objFileTarget = Nothing
'// Check the dates on the required files
For Each strFileName in strFileArray
Set objFileTarget = objFileSys.GetFile(TARGET_DRV & TARGET_DIR & strFileName)
On Error Resume Next '// disable error reporting (e.g., if file isn't found)
Set objFileInstalled = objFileSys.GetFile(strNotesPath & strFileName)
On Error GoTo 0 '// Re-enable error reporting
'// If a version of the file exists, compare dates to determine if an
update is needed
If Not(objFileInstalled Is Nothing) Then
If objFileTarget.DateLastModified > objFileInstalled.DateLastModified Then
'MsgBox "Target file " & objFileTarget.Path & " date modified: " &
objFileTarget.DateLastModified & vbCr & _
'"Installed file " & objFileInstalled.Path & " date modified: " &
objFileInstalled.DateLastModified, , "DEBUG . . ."
Call objFileTarget.Copy(objFileInstalled.Path, True)
Call objShell.LogEvent(EVENT_TYPE_INF, "File " & strFileName & " updated
successfully . . .")
End If
Else '// If a version of the file doesn't exist, copy it to the destination
directory.
Call objFileTarget.Copy(strNotesPath & strFileName, True)
Call objShell.LogEvent(EVENT_TYPE_INF, "File " & strFileName & " added
successfully . . .")
End If
Set objFileInstalled = Nothing
Set objFileTarget = Nothing
Next
'// Dereference WSH objects
Set objShell = Nothing
Set objNetwork = Nothing
Set objFileSys = Nothing
'// Quit the script
Call WScript.Quit()
This script was developed by a programmer and he is certain his script is
perfect. Any help would be greatly appreciated. Thanks Tag: VBScript and WebDAV Tag: 192437
How can I write a screensaver in VBScript? TIA
Want to write a countdown clock to use as either a screensaver or a
wallpaper. I would like to do this in VBScript. Anyone know how to do this?
TIA Tag: VBScript and WebDAV Tag: 192436
creating users in AD programmatically
Hello
I am programmatically creating users for my active directory using vb
scripting. Although I am
able to set simple properties like name, email etc , I am not able to
set other property pages of user programmatically.
I am unable to find the attribute names to set.
I read somewhere that using ADSI I can get the names of attributes.
Any Help??
Madhur Ahuja Tag: VBScript and WebDAV Tag: 192433
enumerating files
To All:
I have found the following script on enumerating files, however I would
like to modify it so that the files are output to a log file (including
the computer name).
Const ALL_USERS_DESKTOP = &H19&
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(ALL_USERS_DESKTOP)
Set objFolderItem = objFolder.Self
' the following is what I would like to change to output to a file
'instead of stdout.
Wscript.Echo objFolderItem.Path
Set colItems = objFolder.Items
For Each objItem in colItems
Wscript.Echo objItem.Name
Next
Any pointers in the right direction would be appreciated.
Thanks for listening..
Mark Tag: VBScript and WebDAV Tag: 192428
Run a vbscript with a specific set of credentials
Hi all,
I have a vbscipt which uses cacls to set some custom permissions on a
folder. However the user that would be running the script doesn't have
sufficient rights to change the permissions. So I want to run the script
using the credentials of another user. Can anyone help? Tag: VBScript and WebDAV Tag: 192426
why ending cscript is so long?
Hello,
After the last command in a vbs, cscript make near then 5 secondes to
return to prompt.
I test with a script with only theses 2 lines:
WScript.Echo "toto"
wscript.quit (0)
I can't use wscript because i need the return code of the action in vbs
( for synchro)
Thanks Tag: VBScript and WebDAV Tag: 192424
Scripting.Dictionary object Issue
Hello All,
I am facing a very strange problem in one of our vb6 apps. The problem
details are as follows.
We have a reporting application written in VB6.
We connect to a database at the end of the day and pull all the records
entered during the day from a table. We then load them in a
Scripting.Dictionary object with recordId as the key and generate a
report.
When the application runs on a Win 2000 or windows XP box it works fine
but when we put the same built on a WinNT box the application pulls
maximum of 65338 records into the report whereas the actual no. of
records are over 90000.
All 90000 reocrds are pulled in Win2000 and XP but it fails on WinNT
box and app. does not log any errors.
What additional should I do to fix this problem for WinNT.
Help is appreciated.
Nadeem Tag: VBScript and WebDAV Tag: 192423
File Search!!
i change to "c:\" only search root file
i want search all file in volume by my set
all file in root,subfolder.....
thanks
"JakeDAHS" <jskiba99@gmail.com>
???????:1150168428.243545.115520@c74g2000cwc.googlegroups.com...
>
>
>
> Joey Chen wrote:
>> how to set search all files in drive C ?
>>
>> thanks alot
>>
>> "JakeDAHS" <jskiba99@gmail.com>
>> ???????:1149999550.912097.24370@m38g2000cwc.googlegroups.com...
>> >
>> > Joey Chen wrote:
>> >> office has some Mac Computer
>> >>
>> >> when use file share will Mac will make the ._XXXXX Files
>> >>
>> >> How to make a script when i run this script will find all ._xxxxx file
>> >>
>> >> and delete
>> >>
>> >> then log to a file what file been delete
>> >>
>> >> thanks alot
>> >
>> > Dim oFSO, oFolder, oLog
>> > Dim sFolder, sLog
>> >
>> > sFolder = "C:\temp1"
>> > sLog = "c:\temp1\log.txt"
>> >
>> > Set oFSO = CreateObject("Scripting.FileSystemObject")
>> > Set oFolder = oFSO.GetFolder(sFolder)
>> > Set oLog = oFSO.OpenTextFile(sLog,8,1)
>> >
>> > For Each oFile in oFolder.Files
>> > If Left(oFile.Name, 2) = "._" Then
>> > sLogLine = Now & "," & oFile.Path
>> > x = oFSO.DeleteFile(oFile.Path)
>> > If x = 0 Then
>> > oLog.writeline sLogLine & ", Success"
>> > Else
>> > oLog.writeline sLogLine & ", Failure"
>> > End If
>> > End If
>> > Next
>> >
>
>
> Change sFolder = "C:\temp1" to directorty to run against.
>
> -Jake
> Tag: VBScript and WebDAV Tag: 192422
Deleting Events from Event Log
Does anybody know if it's possible to delete specific events from the
Application Log?
For example: I need to delete all events logged with ID 1001.
Thanks folks!!!
Felipe Tag: VBScript and WebDAV Tag: 192421
monitor cpu of w3wp and perform iisreset when level is reached
Hello,
i have a need to monitor the w3wp.exe process on my IIS box so that when it
reaches 90% cpu utilization, it would automatically perform an iisreset.
Simple enough, right? Adsutil.vbs has some components of what i'm looking
for, but it only allows for a shutdown of anapplication pool, not a restart.
Thanks!
Troy Tag: VBScript and WebDAV Tag: 192419
Wait for Page Loading within Apps
Hi
Beginner scripter grappling with the idiosyncrasies of vbscript.
I have seen how the time to load a web page in scripts incorporating IE
Automation can be handled in scripts via loops such as:
1) While IE.ReadyState <> READYSTATE_COMPLETE : Wscript.Sleep tDoEvents
Wend
and
2) Do While objIE.Busy
WScript.Sleep(1000)
Loop
However, I am just now putting the finishing touches to a small script
(Macro) to Print a (Printer) Test Page which does not at all involve
Internet Explorer.
Nevertheless, because of the time to "load" the pages in the various
stages (16 in all) in the script, I have had to insert Wscript.Sleep
commands of arbitrary length (usually 1-3 seconds) between all of the
stages.
Is there anything equivalent to the Do While objIE.Busy....Loop which I
can use while working (completely offline) with a Windows Explorer
application?
TIA
Paul Tag: VBScript and WebDAV Tag: 192415
Script to delete computer accounts not working
I'm trying to use a version of Richard's script that I bastardized to delete
computer accounts that are disabled and haven't been modified for 30 days.
This script works fine for user accounts, but it's not running and not
throwing out any errors.
We disable the computer accounts and move them to a separate OU at the time
an employee leaves.
I'm hoping a scripting guru will see the problem right away.
Note that I have the DateDiff variable set to "h" for hours while testing.
Script begins below
===================================================
Option Explicit
Dim objConnection, objCommand, objRootDSE
Dim strDNSDomain, strFilter, strQuery, objRecordSet, strDN, strDN2, HowLong,
mail
Dim intFlag, dtmWhenChanged, objComputer, objParent, objEmail
Const ADS_UF_ACCOUNTDISABLE = &H02
' Use ADO to search the domain for all computers.
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOOBject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
' Determine the DNS domain from the RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("DefaultNamingContext")
strFilter = "(objectCategory=computer)"
strQuery = "<LDAP://ou=gpo
testing,ou=dallas,ou=us,dc=xxxx,dc=xxxxx,dc=xxx>;" & strFilter _
& ";cn,distinguishedName,userAccountControl,whenChanged"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 100
objCommand.Properties("Timeout") = 30
objCommand.Properties("Cache Results") = False
' Enumerate all computers. Check if account disabled.
Set objRecordSet = objCommand.Execute
Do Until objRecordSet.EOF
strDN = objRecordSet.Fields("distinguishedName")
strDN2 = objRecordSet.Fields("cn")
intFlag = objRecordSet.Fields("userAccountControl")
dtmWhenChanged = objRecordSet.Fields("whenChanged")
HowLong = DateDiff("h", dtmwhenChanged, Now)
If (intFlag And ADS_UF_ACCOUNTDISABLE) <> 0 Then
If DateDiff("h", dtmWhenChanged, Now) > 1 Then
Set objComputer = GetObject("LDAP://" & strDN)
Set objParent = GetObject(objComputer.Parent)
objParent.Delete "Computer", objComputer.Name
' Wscript.Echo "Deleted " & strDN
mail = "The account for " & strDN2 & " has been deleted"
'Send Mail
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "AccountDeleted@xxxxx.xxx"
objEmail.To = "networknotifications@xxxxx.xxx"
objEmail.Subject = "Deleted User Account: " & strDN2
objEmail.TextBody = mail
objEmail.Configuration.Fields.Item
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "172.xx.x.xx"
objEmail.Configuration.Fields.Item
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
End If
End If
objRecordSet.MoveNext
Loop
' Clean up.
Set objConnection = Nothing
Set objCommand = Nothing
Set objRootDSE = Nothing
Set objRecordSet = Nothing
Set objComputer = Nothing
Set objParent = Nothing
'Wscript.Echo "Done"
===================================================
Any suggestions or glaring obvious bad code?
Thanks Tag: VBScript and WebDAV Tag: 192411
Script to defrag hard-drives
I got this script from the Microsoft Script Center
----------------------------------------
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set colVolumes = objWMIService.ExecQuery _
("Select * from Win32_Volume Where Name = 'D:\\'")
For Each objVolume in colVolumes
errResult = objVolume.Defrag()
Next
------------------------------------------
However when I try to run the script I get the error:
Line: 8
Char: 1
Error: 0x80041010
Code: 80041010
Source: Null
Any Ideas about getting this script to run? What I'm tring to do is
create a .hta that will defrag the hard-drive (and other things). Tag: VBScript and WebDAV Tag: 192408
Launch hta file from within vbscript
Hi all,
Is there any way to load and control a hta file from within VBScript like
can be done for html?
This works for IE
Set objIE = CreateObject("InternetExplorer.Application")
objIE.navigate "file://c:\test.html"
objIE.left=200
objIE.top=200
objIE.height=225
objIE.width=440
objIE.menubar=0
objIE.toolbar=0
objIE.addressbar=0
objIE.statusbar=0
objIE.visible=1
etc, etc
What to do with *.hta so can load "do some work" then close the object?
Any help warmly appreciated,
Pete Gomersall Tag: VBScript and WebDAV Tag: 192405
How can I enable/disable a device wtih VBScript? TIA
I'm currently using DEVCON in a .BAT file to enable/disable a device at
logon/logoff. Is there a way with VBScript to do this? TIA Tag: VBScript and WebDAV Tag: 192402
Persistent Process Kill
To All:
I was wondering if there is anything such as a 'persistent process kill'
in VBScript?
Say that I am upgrading software, and the user decides (after I kill
their application) that they want to double-click on it and restart it
while the upgrade/install process is going?
That would prevent msiexec from being able to write the installation
files and the install may fail.
Has anyone else in this forum taken care of this problem?
Is there some sort of a while/do loop that can run or that the
installation can be sandwitched in between?
Thanks again for listening!
Mark Withers Tag: VBScript and WebDAV Tag: 192401
Map to a network drive
I am trying to create an easy method for our end users to map to a
network drive via our company's intranet web-page. We are using
Microsoft Front Page as our web site software. Is there a way I can
have the users click on a hyperlink which will guide them through the
mapping process. Thanks for your help. Tag: VBScript and WebDAV Tag: 192400
login script for TS but not regular windows
I have a login script that I want to run during a terminal services session
but not for regular windows session. I can't figure out how to make this
happen. Is there something in the script I can tell it if there is no
clientname or no session to skip to the end? Otherwise, my users will get an
error when they login to their normal windows session.
Thanks,
Kathy Spier
Hillcrest Health Systems
Bellevue, NE Tag: VBScript and WebDAV Tag: 192396
hta help
Hai friends,
We are using hta to launch our application and i am able to do that.
There is a scenario,where if the user selects a store a new instance of
the application should be opened.
If we are using IE then normal window.open will work but in this case i
have to open a new instance with hta.
That is opening hta from an hta.
I'm using WScript to open hta which is as follows,
var winShell = new ActiveXObject("WScript.Shell");
winShell.Run("HomePage.jsp");
But this is not working,i've tried using
winShell.Run("http:localhost:...../HomePage.jsp");
but in vein.
Please help me what is the mistake im doing,
Thanks in advance, Tag: VBScript and WebDAV Tag: 192389
supress cmd line warnings from vbscript !!
Hi,
I have a vbscript that runs an attrib comand to change the readonly
property of a folder as follows
runattribcmd = "attrib -r " + LogsFolder + " /S /D"
dim wsh
Set wsh = CreateObject("WScript.Shell")
wsh.run runattribcmd, 7, false
now my problem is that when this vbscript is run i get a popup command
line window with "Are you sure?" on it and I have click "y" to continue
..
is there a way i can suppress this popup window. i always want to
answer y for the warning .
how do i do this ..
thanks,
mav Tag: VBScript and WebDAV Tag: 192386
im sorry.. yet another array question.
This one keeps coming back to hit me in the face over again.
' This is the only way I could get this to work. Although, I will not
know what the values in that split statement are. More importantly the
string in the split statement could be null.
Dim strVal : strVal = "one,two,three"
Dim arrOne
arrOne = split(strVal,",")
Ubound(arrOne) ' returns 2
Response.Write arrOne(1) ' prints two
Dim arrOne()
arrOne = split(strVal,",") <---- Type mismatch
Dim arrOne()
arrOne() = split(strVal,",") <------ Subscript out of range
' Here's another one.
Dim arrOne()
Response.Write Ubound(arrOne) <---- subscript out of range
Dim arrOne()
arrOne = Array() <----- Type mismatch
Dim arrOne()
arrOne() = Array() <-------- Subscript out of range
Dim arrOne
arrOne = Array()
Response.Write Ubound(arrOne) <---- Returns -1
' So why is it that the Only way that works, is the way that i've always
been told not to do it.
And I still have yet to find a function that can properly see if an
array is empty.
Ie: if an array is populated from a recordset using GetRows, and no rows
are returned.
isArray = true
isEmpty = false
varType = 8204
typeName = variant()
Ubound <--- Out of range.
I have no way of knowing if the array is populated or not. I have to
use a For loop on the record set to see if it's populated.. There has to
be a better way. Tag: VBScript and WebDAV Tag: 192381
Changing Variable Content
I am working on the following Script and could use a little help.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE " _
& "Targetinstance ISA 'CIM_DirectoryContainsFile' AND " _
& "TargetInstance.GroupComponent= " _
& "'Win32_Directory.Name=""C:\\\\2300""'")
Do
Set FSO = CreateObject("Scripting.FileSystemObject")
Set objLatestEvent = colMonitoredEvents.NextEvent
strFilename = ObjLatestEvent.TargetInstance.PartComponent
WScript.Echo strFilename
Replace
strFilename,"\\PFINN-SECXP02\root\cimv2:CIM_DataFile.Name=","C:"
WScript.Echo strFilename
'strLocation = "C:\Moved"
'FSO.CopyFile strFilename strLocation
Loop
The purpose of this script is to monitor a specific directory for new
files. Once and new file appears i want to move it to another server.
This is just the monitoring portion of the script the problem is that
the variable strFilename is storing more then just he file name.
strFilename =
\\MachineName\root\cimv2:CIM_DataFile.Name="C:\\2300\\boss.txt"
I want to either remove everything but the file name or replace
everything but the filename with "C:\". I can not seem to find a way
to do this. Tag: VBScript and WebDAV Tag: 192380
get dialup phone number information
Hi,
How can I get the phone number information for a Windows98 dial-up
networking connection?
Thanks. Tag: VBScript and WebDAV Tag: 192378
Script to find network shortcuts on desktops
Possible to script a way to discover network UNC shortcuts on peoples
desktops. This is because when we move their data from 1 server to another,
there is no way to update their desktop shortcuts. It is okay if shortcuts
are based on network drive but not all are. Had this issue when changing
servers at a customer and released many had UNC paths on desktop. If we could
script to delete (being careful on selections) then they would have to
re-create after new server change.
Shortcut files are .LNK Tag: VBScript and WebDAV Tag: 192374
Find the number of elements
Hello,
Please can you tell me how I can determine the number of elements
returned from an HTML form submitted via the GET method?
thanx in advance
Robbie Tag: VBScript and WebDAV Tag: 192373
Show only one folder contents
To All:
I wish to find the contents of only one folder under the ALL_USERS
program files folder.
I have the following:
Const ALL_USERS_PROGRAMS = &H17&
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(ALL_USERS_PROGRAMS)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path
Set colItems = objFolder.Items
For Each objItem in colItems
Wscript.Echo objItem.Name
Next
I would like to only enumerate ONE folder's contents under the
"%allusersprofile%\Start Menu\Programs" folder.
I would also like to output the data to a file instead of echoing it.
Any help would be appreciated...
Thanks!
Mark Tag: VBScript and WebDAV Tag: 192371
Domain Joining.
Hi,
I have created a script for joining a PC to domain. It works fine when
I run it on a single machine. But when I run it remotely on networked
PC it is not working.
Any Idea....?
Thanks
Jaydeep Tag: VBScript and WebDAV Tag: 192368
System Tray Icons
Is it possible to create a system tray icon via vbscript (as opposed to
visual basis itself)?
I would like to place an icon in the system tray while one of my scripts are
running. Tag: VBScript and WebDAV Tag: 192367
Re: Problems in Waiting for Web page to Open
"PaulFXH"
>As you can imagine, I have some questions about exaclty what you did:
>1) Why do you navigate to a HTML page rather than the .COM page I was
>using?
if you click on >> KasperskyOnlineScanner vou will be redirdct to thr Html page
>2) Can I assume that "item(58)" in "objIE.Document.all.item(58).click"
>refers to the Button to be clicked? If so, how did you get that number (58)?
[1]
>Note that I tried to save the page concerned (in order to look for
>relevant HTML information) but found that Right-Click did not bring up
>any context menu on any of the pages I would have liked to have
>searched for HTML information (such as item number, or ID, for Buttons
>to be clicked).
I have a Italian OS .. but i desume HTML view is disabled but vou can
APPSKEY >>> html or select View >>html on the ToolbarWindow
[1]
As I said ... Autoit can simplifying your live :
I upload also the source but you can use the exe without installing
autoit .. it's fron DaleHohm : http://www.filegone.com/7va1
click on Wowww.exe and wait 30 sec/ 1 min :
in the first page >> Characteristics of all HTML Elements on page
you have
Element Characteristics Index Tag Name Id Extra Information
58 INPUT Form Input Type: button Value: Accept
--
Fosco Tag: VBScript and WebDAV Tag: 192363
SetGateways Not Working Correctly
I am using the following function in a HTA to change IP information on
Windows Server 2003 and Windows 2000 Servers. All the IP information
appears to change to the correct values. I can even open Windows
Explorer and see the Windows Domains and other servers on the network.
But I can not see this server that I have performed the change on from
other systems on the network. I can not ping this server either. The
only way to correct this is to simply make a manual modification to the
default gateway setting and save the modification. This immediately
corrects the issue. I do not have to change the default gateway, just
retype the last octet and click ok. From all the examples that I have
seen, this function should work just fine. I do not see what I am doing
wrong/different.
(Note: Watch for wrap)
Sub setTCPIP(strAdapter)
Dim oNetwork, Adapter, a_Pro_DNS, a_Pro_IP, a_Pro_Subnet,
a_Pro_GateWay, msg
Dim Pro_IP, Pro_Subnet, Pro_Gateway, Pro_DNS, retValue, strDNS,
a_DNS_Suffix
Dim oWMI, sQuery, oClass
Dim iRC, aRegKeys, sKeyName, sValue
a_Pro_IP = Array (document.body.all("pIP").innerText)
a_Pro_Subnet = Array (document.body.all("pSubNet").innerText)
a_Pro_Gateway = Array (document.body.all("pGW").innerText)
a_Gateway_Metric = Array(1)
a_DNS_Suffix = Split (document.body.all("Suffix").innerText, ",")
a_Pro_DNS = Split (document.body.all("pDNS").innerText + ","
+document.body.all("sDNS").innerText, ",")
a_WINS = document.body.all("WINS").innerText
Set oWMI = GetObject("winmgmts:\\.\root\cimv2")
sQuery = "Select * From Win32_NetworkAdapterConfiguration WHERE Index
= " & strAdapter
Set oNetwork = oWMI.Get("Win32_NetworkAdapterConfiguration")
retValue = oNetwork.EnableWINS(DNS_ENABLED_FOR_WINS_RESOLUTION,
USE_LMHOST_FILE,"","")
Set oNetwork = oWMI.ExecQuery(sQuery)
For Each Adapter in oNetwork
if not testing then
retValue = Adapter.EnableStatic(a_Pro_IP, a_Pro_Subnet)
if retValue = 0 then
document.body.all("Prompt").innerHTML="The IP address has been
changed."
elseif retValue = 1 then
document.body.all("Prompt").innerHTML="The IP address has been
changed, reboot needed"
else
document.body.all("Prompt").innerHTML="The IP address could not
be changed, error # " & retValue
end if
HTASleep 3
retValue = Adapter.SetGateways(a_Pro_Gateway, a_Gateway_Metric)
if retValue = 0 then
document.body.all("Prompt").innerHTML="The Gateway has been
changed."
elseif retValue = 1 then
document.body.all("Prompt").innerHTML="The Gateway has been
changed, reboot needed"
else
document.body.all("Prompt").innerHTML="The Gateway could not be
changed, error # " & retValue
end if
HTASleep 3
retValue = Adapter.SetDNSServerSearchOrder(a_Pro_DNS)
if retValue = 0 then
document.body.all("Prompt").innerHTML="The DNS Search Order has
been changed."
elseif retValue = 1 then
document.body.all("Prompt").innerHTML="The DNS Search Order has
been changed, reboot needed"
else
document.body.all("Prompt").innerHTML="The DNS Search Order
could not be changed, error # " & retValue
end if
HTASleep 3
retValue = Adapter.SetWINSServer(a_WINS,"")
if retValue = 0 then
document.body.all("Prompt").innerHTML="The WINS Server has been
changed."
elseif retValue = 1 then
document.body.all("Prompt").innerHTML="The WINS Server has been
changed, reboot needed"
else
document.body.all("Prompt").innerHTML="The WINS Server could
not be changed, error # " & retValue
end if
HTASleep 3
Set oClass = oWMI.Get(Adapter.Path_.class)
retValue = oClass.SetDNSSuffixSearchOrder(a_DNS_Suffix)
if retValue = 0 then
document.body.all("Prompt").innerHTML="The DNS Suffix Search
Order has been changed."
elseif retValue = 1 then
document.body.all("Prompt").innerHTML="The DNS Suffix Search
Order has been changed, reboot needed"
else
document.body.all("Prompt").innerHTML="The DNS Suffix Search
Order could not be changed, error # " & retValue
end if
HTASleep 3
end if
gmsg= Adapter.Description + vbcrlf + " has been configured for use
with the following values:" + vbcrlf + vbcrlf + _
"IP Address:" + chr(9) + chr(9) +
document.body.all("pIP").innerText + vbcrlf + _
"Subnet Mask:" + chr(9) + chr(9) +
document.body.all("pSubNet").innerText + vbcrlf + _
"Gateway:" + chr(9) + chr(9) + chr(9) +
document.body.all("pGW").innerText + vbcrlf + _
"DNS Search Order:" + chr(9) + chr(9) +
document.body.all("pDNS").innerText + ","
+document.body.all("sDNS").innerText + vbcrlf + _
"WINS Server(s):" + chr(9) + chr(9) +
document.body.all("WINS").innerText + vbcrlf + _
"DNS Suffix Search Order:" + chr(9) +
document.body.all("Suffix").innerText + vbcrlf + vbcrlf
Exit For
Next
End Sub
I have verified that the text that I am retrieving for the values are
correct and free from any invalid characters.
Any idea what I am missing here?
Thanks for any assistance,
B-Mann Tag: VBScript and WebDAV Tag: 192361
SetGateways Not Working Correctly
I am using the following function in a HTA to change IP information on
Windows Server 2003 and Windows 2000 Servers. All the IP information
appears to change to the correct values. I can even open Windows
Explorer and see the Windows Domains and other servers on the network.
But I can not see this server that I have performed the change on from
other systems on the network. I can not ping this server either. The
only way to correct this is to simply make a manual modification to the
default gateway setting and save the modification. This immediately
corrects the issue. I do not have to change the default gateway, just
retype the last octet and click ok. From all the examples that I have
seen, this function should work just fine. I do not see what I am doing
wrong/different.
(Note: Watch for wrap)
Sub setTCPIP(strAdapter)
Dim oNetwork, Adapter, a_Pro_DNS, a_Pro_IP, a_Pro_Subnet,
a_Pro_GateWay, msg
Dim Pro_IP, Pro_Subnet, Pro_Gateway, Pro_DNS, retValue, strDNS,
a_DNS_Suffix
Dim oWMI, sQuery, oClass
Dim iRC, aRegKeys, sKeyName, sValue
a_Pro_IP = Array (document.body.all("pIP").innerText)
a_Pro_Subnet = Array (document.body.all("pSubNet").innerText)
a_Pro_Gateway = Array (document.body.all("pGW").innerText)
a_Gateway_Metric = Array(1)
a_DNS_Suffix = Split (document.body.all("Suffix").innerText, ",")
a_Pro_DNS = Split (document.body.all("pDNS").innerText + ","
+document.body.all("sDNS").innerText, ",")
a_WINS = document.body.all("WINS").innerText
Set oWMI = GetObject("winmgmts:\\.\root\cimv2")
sQuery = "Select * From Win32_NetworkAdapterConfiguration WHERE Index
= " & strAdapter
Set oNetwork = oWMI.Get("Win32_NetworkAdapterConfiguration")
retValue = oNetwork.EnableWINS(DNS_ENABLED_FOR_WINS_RESOLUTION,
USE_LMHOST_FILE,"","")
Set oNetwork = oWMI.ExecQuery(sQuery)
For Each Adapter in oNetwork
if not testing then
retValue = Adapter.EnableStatic(a_Pro_IP, a_Pro_Subnet)
if retValue = 0 then
document.body.all("Prompt").innerHTML="The IP address has been
changed."
elseif retValue = 1 then
document.body.all("Prompt").innerHTML="The IP address has been
changed, reboot needed"
else
document.body.all("Prompt").innerHTML="The IP address could not
be changed, error # " & retValue
end if
HTASleep 3
retValue = Adapter.SetGateways(a_Pro_Gateway, a_Gateway_Metric)
if retValue = 0 then
document.body.all("Prompt").innerHTML="The Gateway has been
changed."
elseif retValue = 1 then
document.body.all("Prompt").innerHTML="The Gateway has been
changed, reboot needed"
else
document.body.all("Prompt").innerHTML="The Gateway could not be
changed, error # " & retValue
end if
HTASleep 3
retValue = Adapter.SetDNSServerSearchOrder(a_Pro_DNS)
if retValue = 0 then
document.body.all("Prompt").innerHTML="The DNS Search Order has
been changed."
elseif retValue = 1 then
document.body.all("Prompt").innerHTML="The DNS Search Order has
been changed, reboot needed"
else
document.body.all("Prompt").innerHTML="The DNS Search Order
could not be changed, error # " & retValue
end if
HTASleep 3
retValue = Adapter.SetWINSServer(a_WINS,"")
if retValue = 0 then
document.body.all("Prompt").innerHTML="The WINS Server has been
changed."
elseif retValue = 1 then
document.body.all("Prompt").innerHTML="The WINS Server has been
changed, reboot needed"
else
document.body.all("Prompt").innerHTML="The WINS Server could
not be changed, error # " & retValue
end if
HTASleep 3
Set oClass = oWMI.Get(Adapter.Path_.class)
retValue = oClass.SetDNSSuffixSearchOrder(a_DNS_Suffix)
if retValue = 0 then
document.body.all("Prompt").innerHTML="The DNS Suffix Search
Order has been changed."
elseif retValue = 1 then
document.body.all("Prompt").innerHTML="The DNS Suffix Search
Order has been changed, reboot needed"
else
document.body.all("Prompt").innerHTML="The DNS Suffix Search
Order could not be changed, error # " & retValue
end if
HTASleep 3
end if
gmsg= Adapter.Description + vbcrlf + " has been configured for use
with the following values:" + vbcrlf + vbcrlf + _
"IP Address:" + chr(9) + chr(9) +
document.body.all("pIP").innerText + vbcrlf + _
"Subnet Mask:" + chr(9) + chr(9) +
document.body.all("pSubNet").innerText + vbcrlf + _
"Gateway:" + chr(9) + chr(9) + chr(9) +
document.body.all("pGW").innerText + vbcrlf + _
"DNS Search Order:" + chr(9) + chr(9) +
document.body.all("pDNS").innerText + ","
+document.body.all("sDNS").innerText + vbcrlf + _
"WINS Server(s):" + chr(9) + chr(9) +
document.body.all("WINS").innerText + vbcrlf + _
"DNS Suffix Search Order:" + chr(9) +
document.body.all("Suffix").innerText + vbcrlf + vbcrlf
Exit For
Next
End Sub
I have verified that the text that I am retrieving for the values are
correct and free from any invalid characters.
Any idea what I am missing here?
Thanks for any assistance,
B-Mann Tag: VBScript and WebDAV Tag: 192359
Extract from .ini file to a text file
I have a script that will display the contents of an ini file, my question
is does anyone know how to extract that info to a seperate text file? What I
want to do is have one text file with all the info from about 100 ini files?
So each line from the ini file is added to a master text file.. hope this
makes sence.
Thanks
Gavin... Tag: VBScript and WebDAV Tag: 192355
Inventory of Start Menu and Desktop Icons
To All:
I was wondering how you would approach it if you had to script something
which looked for all icons (*.lnk files) on each user profile desktop,
start menu and also the 'All Users' desktop and Start Menu??
I have found coding out there that will enumerate the icons of the
'logged in' user, but so far nothing that looks at them all.
Here is what I have found (so far):
http://www.activexperts.com/activemonitor/windowsmanagement/scripts/desktop/specialfolders/
Thanks for listening!
Mark Withers Tag: VBScript and WebDAV Tag: 192352
schedule tasks - help please
Hi
I need help to make a script that allows to run an executable file
(audit32.exe : http://itsolutions.intuit.com/Track-It.asp) throught domain
policies or schedule tasks
I can't get done none of both... :(
Teh first ideia has to take in the script bellow that were taken from the
net and adapt to Organization Units. If it was possible in each day of the
week the executable file "audit32.exe" (instead of calling notepad.exe) were
called.
--------------------------------------------------------------------------------------------------------------------------
Schedules Notepad to run at 12:30 PM every Monday, Wednesday, and Friday
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
errJobCreated = objNewJob.Create _
("Notepad.exe", "********123000.000000-420", _
True , 1 OR 4 OR 16, , , JobID)
Wscript.Echo errJobCreated
--------------------------------------------------------------------------------------------------------------------------
The other ideia was to make a "schedule task" and call the file
"audit32.exe" that is in the remote server. All to this step were right not
complicated but then i don't understant when the file "audit32.exe" is
called throught the remote server it does an audit of the server where the
shedule task is and not the remote.
I even thought to call "audit32.exe" by the bellow script but result is the
same
--------------------------------------------------------
set wshshell = CreateObject("WScript.Shell")
wshshell.Run "audit32.exe"
--------------------------------------------------------
If someone could help me appreciate
[]
Ricky Tag: VBScript and WebDAV Tag: 192351
Re: Problems in Waiting for Web page to Open
"PaulFXH"
>Although you say that "you can click buttons via
>internetexplorer.application"
go to ww.google.it and right click and select html and search for btnG
this is how to do the click :
Set objIE = CreateObject("InternetExplorer.application")
objIE.Visible = True
objIE.Navigate "http://google.it/"
Do While objIE.Busy = True
WScript.Sleep 50
Loop
objIE.document.forms.item(0).q.Value="InternetExplorer.application"
WScript.Sleep 200
objIE.document.all.btnG.Click
--
Fosco Tag: VBScript and WebDAV Tag: 192333
Error Scripting XP PCs (but works on 2000 PCs)
From my own PC, I am trying to run the following script against all PCs in my
network to get lists of what software is running on each PC. The script works
when run against Windows 2000 PCs, but does not when I try to run it against
Windows XP machines. I get the following error message: (taken directly from
the CMD output)
D:\Trashcan>cscript test.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
D:\Trashcan\test.vbs(11, 1) Microsoft VBScript runtime error: The remote
server
machine does not exist or is unavailable: 'GetObject'
I am not familiar with scripting against XP PCs. Is there a certain
permission I should enable on XP PC's to allow them to be "controlled" by a
VBS script? Any thoughts will be most appreciated. Thanks.
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
strComputer = "rpiecyk-xp"
strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
strEntry1a = "DisplayName"
strEntry1b = "QuietDisplayName"
strEntry2 = "InstallDate"
strEntry3 = "VersionMajor"
strEntry4 = "VersionMinor"
strEntry5 = "EstimatedSize"
Set objReg = GetObject("winmgmts://" & strComputer & _
"/root/default:StdRegProv")
objReg.EnumKey HKLM, strKey, arrSubkeys
WScript.Echo "Installed Applications" & VbCrLf
For Each strSubkey In arrSubkeys
intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, _
strEntry1a, strValue1)
If intRet1 <> 0 Then
objReg.GetStringValue HKLM, strKey & strSubkey, _
strEntry1b, strValue1
End If
If strValue1 <> "" Then
WScript.Echo VbCrLf & "Display Name: " & strValue1
End If
objReg.GetStringValue HKLM, strKey & strSubkey, _
strEntry2, strValue2
If strValue2 <> "" Then
WScript.Echo "Install Date: " & strValue2
End If
objReg.GetDWORDValue HKLM, strKey & strSubkey, _
strEntry3, intValue3
objReg.GetDWORDValue HKLM, strKey & strSubkey, _
strEntry4, intValue4
If intValue3 <> "" Then
WScript.Echo "Version: " & intValue3 & "." & intValue4
End If
objReg.GetDWORDValue HKLM, strKey & strSubkey, _
strEntry5, intValue5
If intValue5 <> "" Then
WScript.Echo "Estimated Size: " & Round(intValue5/1024, 3) & " megabytes"
End If
Next Tag: VBScript and WebDAV Tag: 192330
how to schedule on remote servers
I don't know what is the best way to audit servers and clients computers
with audit32.exe from Intuit. This program audit's hardware and software of
each machine.
I've already try to schedule a task from the main server to other server
and run the audit32,exe file. But didn't work once it make the audit of the
main server and not of the remote server (the audit32.exe was in the remote
server in a shared folder).
Perphaps with the script below should make easier the audit?... If so can
i put this script in the group policy domain?...
The final purphose it to shedule the audit of servers and clients
computers (local and remote) by Organization Unit in differant days
*************************************************************************************************
Create a Scheduled Task
Schedules Notepad to run at 12:30 PM every Monday, Wednesday, and Friday
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
'Here instead of call notepad.exe i'll call audit32.exe. Do you thing it
might work?...
errJobCreated = objNewJob.Create _
("Notepad.exe", "********123000.000000-420", _
True , 1 OR 4 OR 16, , , JobID)
Wscript.Echo errJobCreated
*************************************************************************************************
Thanks
Ricky Tag: VBScript and WebDAV Tag: 192328
Write to a remote event log
Hello,
Can anyone share a code snippet with me for writing to the Application
event log of a remote server?? (Windows 2000/2003).
Thanks,
Troy Tag: VBScript and WebDAV Tag: 192293
easy way to (almost)copy a recordset.
I want to open up 2 record sets. Then, copy everything from one record
set to another (excluding a few fields). Is this possible?
I need to exclude my primary key, and fields starting with "TMP_".
I'm trying this, but it's saying ADODB.Recordset error '800a0c93'
Operation is not allowed in this context.
Public Function saveChanges()
Dim strSQL : strSQL = "SELECT * FROM imf WHERE imf_id = " & Form_id
Dim strSQLTMP : strSQLTMP = "SELECT * FROM imf WHERE TMP_imf_id
= " & Form_id
Dim rs : Set rs = Server.CreateObject("adodb.recordset")
Dim rsTMP : Set rsTMP = Server.CreateObject("adodb.recordset")
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic
rs.CursorLocation = adUseServer
rs.open strSQL,DBHandle.DBConn
rsTMP.open strSQL,DBHandle.DBConn
Dim i, strF
rs.movefirst
For i = 0 To rs.Fields.Count -1
echo i & "- " & rs.Fields(i).Name & "<br>"
strF = rs.Fields(i).Name
If strF = "imf_id" Then
' do nothing
echo "skipping " & strF & "<br>"
ElseIf Left(strF,3) = "TMP" Then
' do nothing
echo "tmpskipping " & strF & "<br>"
Else
rs.Fields.Item(i) = rsTMP.Fields.Item(i)
End If
Next
rs.close : rsTMP.close
Response.End
End Function Tag: VBScript and WebDAV Tag: 192292
ADODB.Recordset error '800a0c93' Operation is not allowed in this
am i doing something wrong here. I am only updating one table. There are
102 fields in this table right now, and i don't want to have to create
an sql statement for this.
Dim strSQL : strSQL = "SELECT * FROM imf WHERE imf_id = " & Form_id
Dim rs : Set rs = Server.CreateObject("adodb.recordset")
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic
rs.CursorLocation = adUseServer
rs.open strSQL,DBHandle.DBConn
Dim i, strF
rs.movefirst
For i = 0 To rs.Fields.Count -1
echo i & "- " & rs.Fields(i).Name & "<br>"
strF = rs.Fields(i).Name
If strF = "imf_id" Then
' do nothing -- dont update the primary key
echo "skipping " & strF & "<br>"
ElseIf Left(strF,3) = "TMP" Then
' do nothing -- don't update temp fields
echo "tmpskipping " & strF & "<br>"
Else
rs.Fields.Item(i) = ...
End If
Next
rs.close
Response.End
my output prints out the expected output for all of the fields, and
after that i get this
ADODB.Recordset error '800a0c93'
Operation is not allowed in this context. Tag: VBScript and WebDAV Tag: 192291
Help!!! Date operations
Hello all, I must realize a script that it eliminates file rar older
than 5 days regarding the date retrieve by function Date(). How I can
make?
Thanks all!!! Tag: VBScript and WebDAV Tag: 192287
Download a website's source with VBS
Hello everyone,
Okay probably a simple question, but I'm very green to VBS and I can't
find this anywhere! In the Unix world I use wget to download just the
source file for a given website, but I need to do this same thing in
Windows and preferably with VBS.
Basically what we're doing is downloading an xml file from a vendor's
website then importing it into our MS SQL database via a VBS script
(using QLXMLBulkLoad). I have this part working, but I now need to
download the xml file from the web server. Ideally I'd like to put
this download routine before the code that imports the XML content, but
that's my delimma -- I dunno how to write it :)
Thanks for any suggestions or pointers into the right direction. Take
care --
Alex Tag: VBScript and WebDAV Tag: 192283
Cycle through variables
Is there a way to specify a list of say 20 variables in a script and run the
same command for all variables without copying pasting the command 20 times
in a script? Below is an example of my current script - I'd really like to
simplify it to make future modifications much easier. It looks like there
are two options that may produce my desired end result - using an array
and/or using multiple instances of the same variable, for example: Group(1)
= group in domain1, Group(2) = group in domain2, etc.
Can anyone shed some light on how to cycle through many variables to the
same command?
Group01="cn=somegroup,ou=somou,dc=domain1,dc=com"
Group02="cn=somegroup,ou=somou,dc=domain2,dc=com"
(etc.)
Set objGroup = GetObject ("LDAP://"&Group01)
For each objMember in objGroup.Members
i = i + 1
AlertReportXX = i&". "&objMember.sAMAccountName&" (domain.com)"
objTextFile2.WriteLine(AlertReportXX)
EchoXX = "domain.com,,"&objMember.sAMAccountName
objTextFile.WriteLine(EchoXX)
Next
Set objGroup = GetObject ("LDAP://"&Group02)
For each objMember in objGroup.Members
i = i + 1
AlertReportXX = i&". "&objMember.sAMAccountName&" (domain.com)"
objTextFile2.WriteLine(AlertReportXX)
EchoXX = "domain.com,,"&objMember.sAMAccountName
objTextFile.WriteLine(EchoXX)
Next
(etc.)
wscript.echo i
wscript.quit Tag: VBScript and WebDAV Tag: 192282
Creating excel file on server
I understand that vbscript is a client side scripting language, but is
there a way to create the file on the server side instead? I'm using
php on my website, and am generating excel files for users to download.
The problem with creating excel files with vbscript is that all users
needs to be using internet explorer and must adjust their security
settings before they can take advantage of this feature. I would
rather have the excel file be created on the server and just upload it
to clients rather than having them go through so much. (Even though it
is a one time setup)
Any other solutions is appreciated. I prefer vbscript because I have
full control over the access file such as formats, merged fields,
formulas, font color, size, print size, etc. I know i can create an
excel file using php with headers, but I don't have as much control
over the appearance of the excel file as I do when using vbscript. Tag: VBScript and WebDAV Tag: 192279
Test for setup.exe success.
Is there a way to test for the successful completion of "setup.exe"
using either the exec or run methods? Particularly what I'm trying to
do is do a silent install of Firefox & Thunderbird 1.5.0.4. I've
extracted their installation files and made the necessary modifications
to them, and the "setup.exe" with both of them can be run in silent
mode. If I launch that, how can I determine if it completes
successfully? The following code seems to always return a zero
ReturnCode, regardless of whether setup.exe fails or completes
successfully.
If Not IsObject(oWshShell) Then Set oWshShell =
CreateObject("WScript.Shell")
ReturnCode = oWshShell.Run("setup.exe", 1, True)
Thanks... Tag: VBScript and WebDAV Tag: 192278
Is it possible to copy files (from a local pc to a server) using VBScript
and WebDAV.