Interactive FTP VBScript
I know I could use FTP from VBScript using something like the following.
However, is there a better way to do this so it's a little more
"interactive" (i.e., allow the script to interpret intelligently the
response from the server after issuing each command before continuing. e.g.
iff cannot open connection to servername, then it might be worth waiting a
while and then retrying instead of sending a username).
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")
sFtpCmds = "c:\ftp.inp"
Set fFtpCmds = oFSO.CreateTextFile(sFtpCmds, _
OverwriteIfExist, OpenAsASCII)
' server to open
fFtpCmds.WriteLine "open servername"
' username
fFtpCmds.WriteLine "username"
' password
fFtpCmds.WriteLine "password"
fFtpCmds.WriteLine "GET testfile.txt"
fFtpCmds.WriteLine "quit"
fFtpCmds.Close
sCmd = "ftp -i -s:" & sFtpCmds
oShell.Run sCmd, 0 Tag: Font Tag: 151516
AddressEntries Not Working for Server-Side Script
I have an Agent Server-Side Script running to process new messages arriving
in a Public Folder. This includes accessing the Members for a Recipient that
is a Distribution Group located in the Global Address List.
This portion of code works just fine:
Set oAddrEntry = oRecip.AddressEntry
But this line fails with error MAPI_E_NO_SUPPORT:
Set oAddrEntries = oAddrEntry.Members
We weren't getting this error when we were using WinNT 4.0 Server and
Exchange 5.5. But we're now planning a switch to Windows 2000 Server
5.00.2195 SP2 and Exchange 2000 Ver 6 Build 5762.4 SP2 and the error occurs
on our test setup.
I believe that I've got the permissions set correctly. We've got the Event
Service running under the Administrator account, and the Administrator
permissions on the container that holds the Distribution Groups looks okay.
I'd appreciate any suggestions.
Thanks. Tag: Font Tag: 151513
SNMP vbscript assistance
Thanks to all that replied to my first SNMP script question. Well I
have tweaked the script and it works fine, but now I need to filter
the result. When I run the script I can see all of the ip addresses
connected to the remote servers ports, but I only care about one
address in particular. I aslo only need to know how many established
connections from this ip address there are. Basically I only need a
count of the instances of the ip address that are returned. Here is my
code.
Note, if you want to test this, you need to install the wmi snmp
provider on your workstation.
The area I 'm having difficulty with is near the end witht he For Each
line. I believe this is the area I need to focus on with the filter
function, or maybe I can perform something other than a "for each"
loop?
I have not figured out how to only request specific data, kind of like
an is, or equals statement. So I only get the ip address and the
count, with the count staement I guess?
One more thing, did I end the script correctly?
On Error Resume Next
Set objArgs = Wscript.Arguments
If objArgs.Count < 1 Then
MsgBox ("Syntax is : scriptname.vbs <Machine name> or <IP Address>")
Wscript.Quit 0
End If
strTargetSnmpDevice = objArgs(0)
Set objWmiLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWmiServices = objWmiLocator.ConnectServer("",
"root\snmp\localhost")
Set objWmiNamedValueSet =
CreateObject("WbemScripting.SWbemNamedValueSet")
objWmiNamedValueSet.Add "AgentAddress", strTargetSnmpDevice
objWmiNamedValueSet.Add "AgentReadCommunityName", "public"
Set colTcpConnTable = _
objWmiServices.InstancesOf("SNMP_RFC1213_MIB_tcpConnTable", , _
objWmiNamedValueSet)
Set colUdpTable = _
objWmiServices.InstancesOf("SNMP_RFC1213_MIB_udpTable", , _
objWmiNamedValueSet)
'WScript.Echo "TCP Connections and Listening Ports" & vbCrLf & _
' "-----------------------------------"
For Each objTcpConn In colTcpConnTable
WScript.Echo objTcpConn.tcpConnRemAddress & ":" & _
"[State: " & objTcpConn.tcpConnState & "]"
Next
Also using the same script, there is another issue.
Script purpose: Using the WMISNMP provider, remotely request tcp
connection data, and return the results of onlya specific ip address.
Problem: I cannot figure out the cleanest way to only request the data
I need. Since I know what the ip address should be, I do not care
about any other results the script may return. I only need the ip
address, for example, 10.10.1.1, regardless of any other addresses it
might find.
Script code: Sanatized for safety.
strTargetSnmpDevice = "127.0.0.1"
Set objWmiLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWmiServices = objWmiLocator.ConnectServer("",
"root\snmp\localhost")
Set objWmiNamedValueSet =
CreateObject("WbemScripting.SWbemNamedValueSet")
objWmiNamedValueSet.Add "AgentAddress", strTargetSnmpDevice
objWmiNamedValueSet.Add "AgentReadCommunityName", "public"
Set colTcpConnTable = _
objWmiServices.InstancesOf("SNMP_RFC1213_MIB_tcpConnTable", , _
objWmiNamedValueSet)
Set colUdpTable = _
objWmiServices.InstancesOf("SNMP_RFC1213_MIB_udpTable", , _
objWmiNamedValueSet)
'WScript.Echo "TCP Connections and Listening Ports" & vbCrLf & _
' "-----------------------------------"
For Each objTcpConn In colTcpConnTable
WScript.Echo objTcpConn.tcpConnRemAddress & ":" & _
"[State: " & objTcpConn.tcpConnState & "]"
Next
WScript.Echo vbCrLf & "UDP Ports" & vbCrLf & "---------"
For Each objUdp In colUdpTable
WScript.Echo objUdp.udpLocalAddress & ":" & objUdp.UdpLocalPort
Next Tag: Font Tag: 151511
How to E-mail an IP Address
Hi All
This is my first post so let me know if i'm not doing this right. I have a small problem, sometime when my users call with a problem I have to tell them how to get their IP address. I want to eliminate me having to tell them,,,ok so call me lazy. I was thinking about writing a script in which I can e-mail them, they then double click on it and it will get their IP address and e-mail it to me. I'm running Exchange 2000 as my e-mail server and all of my clients are running Outlook 2000 or better. Can someone get me started down the right path for this vbscript
Thanks
Jason Franks, MCSE Tag: Font Tag: 151509
Are you out there Richard M.?
I need your help again. :)
I'm trying to create some error handling and logging. I've moved some
things around. At one point it was logging all the success' but not the
failures.
Now it creates the log but does nothing else.
I know I've got something hosed up. I just need you to tell me what it is.
Thanks,
Roger
Option Explicit
Const ADS_PROPERTY_CLEAR = 1
Const ADS_PROPERTY_UPDATE = 2
Const ADS_UF_ACCOUNTDISABLE = 2
Dim strExcelPath, objExcel, objSheet, intRow, strUserDN, strUserCN,
strUserOU, strUPN, strSAM, strContainer, strName, strErr, strErrReason,
strErrCode 'strNSN, strFullName, strBoss, strMailCode, strJobTitle,
strAssignedID, strLocation, strState, strMove
Dim objUser, objOU, objContainer, objRootDSE, objOrganizationalunit, objFSO,
objCreateFile, objFile
Dim intUAC
' Check for required arguments.
If Wscript.Arguments.Count < 1 Then
Wscript.Echo "Argument <SpreadsheetName> required. For example:" _
& vbCrLf _
& "cscript UpdateADUsers.vbs D:\ADUsers\Test.xls"
Wscript.Quit(0)
End If
' Spreadsheet file.
strExcelPath = Wscript.Arguments(0)
' Bind to Excel object.
On Error Resume Next
Err.Clear
Set objExcel = CreateObject("Excel.Application")
If Err.Number <> 0 Then
Err.Clear
Wscript.Echo "Excel application not found."
Wscript.Quit
End If
On Error GoTo 0
' Open spreadsheet.
On Error Resume Next
Err.Clear
objExcel.Workbooks.Open strExcelPath
If Err.Number <> 0 Then
Err.Clear
Wscript.Echo "Spreadsheet cannot be opened: " & strExcelPath
Wscript.Quit
End If
' Bind to worksheet.
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
' The first row of the spreadsheet is skipped (column headings). Each
' row after the first is processed until the first blank entry in the
' first column is encountered. The first column is the Distinguished
' Name of the user, the second column is the new profilePath. The loop
' binds to each user object and assigns the new value for the attribute.
' intRow is the row number of the spreadsheet.
'Create log file
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objCreateFile = objFSO.CreateTextFile("C:\temp\createuser.log")
objCreateFile.Close
Set objFile = objFSO.OpenTextFile("C:\temp\createuser.log", 8)
intRow = 2
Do While objSheet.Cells(intRow, 1).Value <> ""
strUserDN = Trim(objSheet.Cells(intRow, 1).Value)
strUserCN = Trim(objSheet.Cells(intRow, 2).Value)
strUserOU = Trim(objSheet.Cells(intRow, 3).Value)
strUPN = Trim(objSheet.Cells(intRow, 4).Value)
strSAM = Trim(objSheet.Cells(intRow, 5).Value)
strContainer = strUserOU
strName = strUserCN
'***********************************************
'* Connect to a container *
'***********************************************
Set objRootDSE = GetObject("LDAP://rootDSE")
If strContainer = "" Then
Set objContainer = GetObject("LDAP://" & _
objRootDSE.Get("defaultNamingContext"))
Else
Set objContainer = GetObject("LDAP://" & strContainer)
End If
'***********************************************
'* End connect to a container *
'***********************************************
Set objUser = objContainer.Create("user", "cn=" & strName)
objUser.Put "sAMAccountName", strName
objUser.Put "userPrincipalName", strUPN
On Error Resume Next
objUser.SetInfo
If Err.Number <> 0 Then
' Error raised, alert and skip this entry.
strErr = "can't be created"
strErrReason = "User may already exist"
strErrCode = Err.Number
On Error GoTo 0
Else
' No error, continue and assign other attributes.
strErr = "User created successfully"
strErrReason = "Done"
strErrCode = Err.Number
On Error GoTo 0
objUser.SetPassword "password"
intUAC = objUser.Get("userAccountControl")
If intUAC And ADS_UF_ACCOUNTDISABLE Then
objUser.Put "userAccountControl", intUAC XOR ADS_UF_ACCOUNTDISABLE
End If
objFile.WriteLine strName & "^" & strErr & "^" & strErrReason & "^" &
strErrCode
Err.Clear
objUser.SetInfo
WScript.Echo strUserOU
WScript.Echo strUserDN
WScript.Echo strUserCN
WScript.Echo strSAM
WScript.Echo strUPN
On Error GoTo 0
End If
intRow = intRow + 1
Loop
' Close the workbook.
objExcel.ActiveWorkbook.Close
' Quit Excel.
objExcel.Application.Quit
'Close log file
objFile.Close
' Clean up.
Set objUser = Nothing
Set objExcel = Nothing
Set objSheet = Nothing
Wscript.Echo "Done" Tag: Font Tag: 151506
Folder Redirection and VBScript
We have our My Documents folder redirected to a network share using
group policies. The network share is different depending upon which
OU the user is located. I am creating one script for all users and
this script needs to be able to determine the location of the
redirected My Documents. How can I do this? Is there an environment
variable which will tell me the location of the redirected My
Documents? I can not hard code this into the code because it is a
different location for different users. Tag: Font Tag: 151502
Update --- User Environment variables ... a more precise description of the problem
Hi guys, I posted in the VB Script group several times about a problem that
I had with a script that would set environment variables, but it finally
seems that it's not a script problem...
If I run the script as a normal Logon script on user's account, it works,
but if I run the logon script from a GPO... no good...
The script runs, the variables are set in the registry and visible trough
the user's environment variable window in My
computer\properties\advanced\Environment variable...
But if I go to a cmd and type set... the variables are not known here... If
I go back to the environment variables windows and say ok, the variables
then become available when doing a cmd \ set
Any one has an idea why ???
Thanks !!!
Here is the original post :
*************
need to reload user environment variables after a script is run...
The script adds user environment variables, and they appear to be there, but
not loaded into the system...
I have tried : "%windir%\System32\RUNDLL32.EXE
user32.dll,UpdatePerUserSystemParameters", _
1, True
But it doesn't seem to work...
Can anyone help me...
Or another way, is there a way to open up environment variables windows and
say OK to it within a script ( invisibly I guess )...
Because when this is done manually, it works very well..
****
Thanks !!!
--
--
Houman Yahyaei ( CCNA, MCSE Win 2000/NT 4.0, MCT )
IT Training and Consulting
www.formationhy.com
Houman@formationhy.com Tag: Font Tag: 151500
Cross Post: MS Project 2002 Pro Email Address Field Storage
Sorry for the cross-posting but I am really stuck in a rut on this one. Any
help greatly appreciated.
From: "Aaron G. Krueger" <agkrueger@imcglobal-bogus.com>
Subject: Email Address Field storage
Date: Tuesday, January 20, 2004 2:55 PM
I am working on a scripted configuration of MS Project 2002 Pro's Project
Server/Collaboration settings. I am getting hung up on one aspect:
email address: I can not for the life of me figure out where this
information is being stored. I have searched the registry as well as the
file system and can find no reference to the test email address I used
during configuration. Microsoft KB yeilded nothing, Google nothing either.
If anyone has any experience with this, please advise.
Thanks
Aaron G Krueger
agkrueger@imcglobal-bogus.com Tag: Font Tag: 151496
Running Windows Script Debugger!!
Hello,
I've downloaded Window Script Debugger but I don't know how to open it (run
it). I want to start using it to debug VBS files UI am working on.
Anybody help please? I am really getting frustrated..
Thanks in advance.
Fouad. Tag: Font Tag: 151494
Reading a registry Value
Hello
I was wondering if it's possible to use VBscript as a means to get a value from the registry and if not, how it can be done using VB6
Thanks a lot
-Dany Tag: Font Tag: 151491
Changing Numlock state
Hey all,
I want to change the default Numlock state on our PC's
I use this script
'
' Enable NumLock for NON portables
'
strKeyPath = "Control Panel\Keyboard"
strEntryName = "InitialKeyboardIndicators"
strValue = "2"
oReg.SetStringValue &H80000001,strKeyPath,strEntryName,strValue
strKeyPath = ".default\Control Panel\Keyboard"
strEntryName = "InitialKeyboardIndicators"
strValue = "2"
oReg.SetStringValue &H80000003,strKeyPath,strEntryName,strValue
The Current User setting is changed, but not when the PC starts.
I can't seem to change the Default User setting...
What is wrong?
Marc Tag: Font Tag: 151490
help with modifying select folder code
Hi,
I have this vbscript function for selecting a folder. It works well,
but i can not browse computers
on the network to select a folder. Can someone help me modify it to
allow this on a windows box.
Thanks so much!
Chuck
Const ValueRoot = "&h17"
Const sStartFolder = 17 'This value specify folder/browsing options
Call BrowseForFolder("Choose a folder", &h17, sStartFolder)
Function BrowseForFolder(strPrompt, BrowseInfo, root)
On Error Resume Next
Dim oShell, oFolder, intColonPos, oWshShell
Set oShell = CreateObject("Shell.Application")
Set oWshShell = CreateObject("WScript.Shell")
Set oFolder = oShell.BrowseForFolder(0, strPrompt, BrowseInfo, root)
BrowseForFolder = oFolder.ParentFolder.ParseName(oFolder.Title).Path
If Err.Number > 0 Then
BrowseForFolder = Null
If oFolder.Title = "Desktop" Then
BrowseForFolder = owshshell.SpecialFolders("Desktop")
End If
intColonPos = InStr(oFolder.Title, ":")
If intColonPos > 0 Then
BrowseForFolder = Mid(oFolder.Title, intColonPos - 1, 2) & "\"
End If
End If
PathFileBrowse = BrowseForFolder
End Function Tag: Font Tag: 151486
Accessing Session/Application variables in Global.asa from a VBS file???
Hi Guys,
My ASP Application has a Global.asa where some settings
(Session/Application Variables) are stored. These are used by some of
my ASP Pages in the application.
Now, my task is to write a scheduler program to send some reminders.
I have already implemented this scheduler program using a .VBS file on
the server. This .VBS file will be called from the Windows Scheduler.
In my VBS file, I need to access certain values of Session/Application
variables from Global.asa. How can I get these values in VBS file?
Regards,
Kamlesh Tag: Font Tag: 151485
Updating users
I need to build a script that will run when the pc is started up to delete
all local users except administrator in a win2000 professional. The user
somehow can run some hack program to add in administrative user even though
he is a regular users.
If possible I would like to update the administrator password as well, in
case his hack can change the password.
I don't know if this is do-able.
Please advise.
Thanks.
JW. Tag: Font Tag: 151484
run EXE from a VBS custom action
I need to run an exe file from my VBScript.
Should be simple, I know, but the script is run as a custom action from an
MSI installer, so there is no WSH and no WScript object.
How can I run an exe from my script?
Is there a way to make my script wait until the exe finishes (even if it is
a GUI exe)?
Jens Tag: Font Tag: 151479
can U make this button work
I have been working on this problem for weeks.
I just want the script to pass the form data to itself when the button is
clicked and continue with the next function.
<----------------------------------------------------->
set objExplorer = CreateObject("InternetExplorer.Application")
Do While (objExplorer.Busy)
Loop
objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width = 640
objExplorer.Height = 480
objExplorer.Left = 0
objExplorer.Top = 0
objExplorer.Visible = 1
set objDocument = objExplorer.Document
objDocument.Open
objDocument.Writeln "<FORM NAME='Form1'>"
objDocument.Writeln "<B>Choose the areas you are interested in</B>"
objDocument.Writeln "<BR><INPUT TYPE=CHECKBOX NAME='chkIS'> Information
systems"
objDocument.Writeln "<BR><INPUT TYPE=CHECKBOX NAME='chkSE'> Systems
integration"
objDocument.Writeln "<BR><INPUT TYPE=CHECKBOX NAME='chkSA'> System
administration"
objDocument.Writeln "<BR><INPUT TYPE=CHECKBOX NAME='chkMgmt'> Management"
objDocument.Writeln "<BR><INPUT TYPE=BUTTON NAME='Button1'
VALUE='Continue'>"
objDocument.Writeln "</FORM>"
Sub Button1_onclick
Dim Selections, Count
Count = 0
If Form1.elements(0).checked = True Then
Selections = "Information systems"
Count = Count + 1
End If
If Form1.elements(1).checked = True Then
If Count <> 0 Then
Selections = Selections & ", "
End If
Selections = Selections & "Systems integrations"
Count = Count + 1
End If
If Form1.elements(2).checked = True Then
If Count <> 0 Then
Selections = Selections & ", "
End If
Selections = Selections & "System administration"
Count = Count + 1
End If
If Form1.elements(3).checked = True Then
If Count <> 0 Then
Selections = Selections & ", "
End If
Selections = Selections & "Management"
Count = Count + 1
End If
If Selections = "" Then
alert "You did not select any of the choices."
Else
alert "You checked the following choice(s): " & Selections
End If
End Sub
<-----------------------------------------------------> Tag: Font Tag: 151472
Error: "ActiveX component can't create object"
I use WSH and VBScript to run login scripts in our
network. They run fine on everyone's machine expect
one. On that one, I get the error,
ActiveX component can't create object: 'Scripting:
FileSystemObject'. Code 800A01AD
everytime there's a call in my code to
Set oFSO = CreateObject("Scripting.FileSystemObject")
I've reinstalled the most recent build of WSH 5.6 and
rebooted, but no difference. All the Google hits I find
are related to ASP programming (which I'm unfamiliar
with) and don't seem to be related to my issue.
Can anyone point me to what might be wrong/different with
this one machine that I can research and correct? Thanks. Tag: Font Tag: 151464
OBJECT tag web component embedding broken since windows update
All of the sudden my code which embeds an Office Web Component stopped
working and has only done so on computers that have applied the
critical Windows update
from the week of Jan 15, 2004.
Here is the snippet of code....
<object id=ChartSpace1
classid=CLSID:0002E500-0000-0000-C000-000000000046
style="width:100%;height:450"></object>
<script language=vbscript>
Sub Window_OnLoad()
Dim oChart
Dim oSeries1
dim oConst
'Ensure ChartSpace1 is empty:
ChartSpace1.Clear
Set oConst = ChartSpace1.Constants
'Create a new chart in the ChartSpace
Set oChart = ChartSpace1.Charts.Add
'Add a series of type Column
Set oSeries1 = oChart.SeriesCollection.Add
With oSeries1
.Caption = "My Percentage"
'.SetData oConst.chDimCategories, oConst.chDataLiteral,
Array(<%=chartaxes%>)
.SetData oConst.chDimValues, oConst.chDataLiteral,
Array(<%=chartvals%>)
.Type = oConst.chChartTypeSmoothLine
End With
Set mg = oChart.Axes(oConst.chAxisPositionLeft).MajorGridlines
mg.Line.Color = "white"
mg.Line.Weight = 1
Set axs = oChart.Axes (1)
axs.Font.Name = "Arial"
axs.Font.Size = "1"
'Add a second value axis to the Chart
'oChart.Axes.Add oChart.Scalings(oConst.chDimValues),
oConst.chAxisPositionRight, oConst.chValueAxis
'Display the legend
'oChart.HasLegend = True
'oChart.Legend.Position = oConst.chLegendPositionBottom
'Display the title for the chart
oChart.HasTitle = True
oChart.Title.Caption = "My Percentage"
End Sub
</script>
The VBScript error that IE is now displaying is:
"Error: Object doesn't support this property or method:
'ChartSpace1.Clear'"
It seems that it is not able to read to OBJECT tag or associate the id
with this object, so any/all properties/methods referencing this
embedded object are failing. I thought that this may be related to
Microsoft patent lawsuit with "eolas" but I cannot find a work around
(or even if this is infact the case). Anyone else experiencing
problems?
http://msdn.microsoft.com/ieupdate/activexchanges.asp
I'm on Win 2K with IE 6.0. Again - comps that didnt get the update
last week are not having the problem. Also, it is not my Internet
Zone security settings - I know that for sure. Tag: Font Tag: 151460
Script to check local reboot
There were 2 person who wrote this script and many thanks
to them. I tried this script and I am receiving an error.
call :checkReboot \\domain1.company.com
call :checkReboot \\domain2.company.com
call :checkReboot \\domain3.company.com
call :checkReboot \\domain4.company.com
call :checkReboot \\domain5.company.com
call :checkReboot \\domain6.company.com
goto :EOF
:checkReboot
set server=%1
for /f "tokens=7 delims= " %%q in ('uptime %server%') do
(set /a
numHours=%%q)
IF %numHours% GTR 1 (shutdown.exe server% /l /r /t:f /c /y)
The syntax of the command is incorrect.
'numHours' is not recognized as an internal or external
command,
operable program or batch file.
1 was unexpected at this time.
What is the correct syntax? Tag: Font Tag: 151453
possible to resize hta window?
Hello All,
I have been experimenting with hta files and would like to
know if anyone knows if it is possible to set the size of
the window of an hta file. If this is possible, may I
request how you do that? I have experimented a little bit
with window.location, but that only gave me filepathname.
While I'm at it, if it is possible (or not possible) to
resize the hta window is it possible to set the location
on the screen?
Thanks,
Rich Tag: Font Tag: 151448
Vbscript array used as parameter to a COM method
My code is a quite as following:
DIM TaskCardList(10)
....
TaskCardList(0) = "toto"
etc ....
AGTM.AddTask TaskCardList,10
The COM server expects an array of string. Unfortunately, the COM server is
not able to retrieve the item of the array.
What's wrong? ( we manage both client script and server).
A similar code works with VC++ and DElphi client.
Any help will be appreciated. Tag: Font Tag: 151442
Vbscript array used as parameter to a COM method
My code is a quite as following:
DIM TaskCardList(10)
....
TaskCardList(0) = "toto"
etc ....
AGTM.AddTask TaskCardList,10
The COM server expects an array of string. Unfortunately, the COM server is
not able to retrieve the item of the array.
What's wrong? ( we manage both client script and server).
A similar code works with VC++ and DElphi client.
Any help will be appreciated. Tag: Font Tag: 151441
Iterate Through Registry With VBScript
Can someone please give me an example of how to iterate through the registry
using vbscript? I have the following key that I need to iterate through.
HKEY_LOCAL_MACHINE\Software\Company Name\Site\
I need to get the key names and their values into an array. Can someone
send me a snippet of code that can do this?
Thanks,
Robbie Tag: Font Tag: 151437
pb download file with xmlhttp
hello
with my script i hava an error, dit you ave an idea ?
sSource = "http://go.microsoft.com/fwlink/?LinkId=18922"
sDest = "mssecure.txt"
set oHTTP = CreateObject("Microsoft.XMLHTTP")
set oStream = createobject("adodb.stream")
oStream.type = 1
oHTTP.open "GET", sSource, False
oHTTP.send
msgbox oHTTP.getResponseHeader
oStream.open
oStream.write oHTTP.responseBody
oStream.savetofile sDest Tag: Font Tag: 151406
reading values from a text file
Hi
I need to read some values from a text file stored in the server(later
on,these values will be assigned to a set of variables).
Is there a way to do such a thing using VBScript embedded in a ASP page?
Thanx in advance.
--
remove NOSPAM to send emails
ICQ #8860533 Tag: Font Tag: 151405
Returning Error Code
I want to run a VBScript through Windows Server 2000's scheduled task. On
failing to execute certain task within the script, I want the job to show up
as "Failed" with a result of 1 on the Scheduled Task list. How could this
be done?
"Return 1" does nott work. Even when 1 is returned, the "Last Result" still
show up as 0x0. Tag: Font Tag: 151401
Registry key enumeration
Hi,
I'm familiar with calling the Windows Scripting Host fom VBScript to
maniuplate the Registry, but can anyone please tell me if there is a way,
given a known Registry key, to enumerate the sub keys and/or values beneath
it?
Any assistance gratefully received.
Mark Rae Tag: Font Tag: 151399
Spool services takes a lot of CPU usage bafter AddWindowsPrinterConnection ?
Hi!
I have a login-script where 3 printers are mapped using
AddWindowsPrinterConnection - the problem is that the spool service on
WindowsXP hosts seems to take a lot of CPU-time after this action. The only
way to bring thing sback to normal is to restart the spooler service ...
Any idea why this happens ?
Regards,
/Brian Tag: Font Tag: 151396
INSERTing cyrillic characters in Access db via ASP ?
I am having trouble INSERTing cyrillic characters in an Access db via asp.
I can list cyrillic data fine.
I have
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
for the charset on the page but gibberish is inserted when adding data to
db. English can be inserted fine as well.
Anyone know a solution ?
thanks Tag: Font Tag: 151393
printing text
Please help or point me some other direction. Thanks!
I did not get an answer from a previous post. This is where it ended:
How do you get the object "printer" and where is the docs on what I can do
with printer (methods, events, properties, etc.) Someone told me "printer"
exists in vb but not vbs.
Thanks,
Paul Temple
"JR" <XXX.X@pandora.XXXX> wrote in message
news:qX%Gb.97754$sg7.4424744@phobos.telenet-ops.be...
> print to the printer
>
> Printer.print "you text"
>
>
> --
> Met vriendelijke groeten.
> Jan
> "Paul.Temple" <paul.temple@templesystems.net> schreef in bericht
> news:%23SkhXq8yDHA.3208@tk2msftngp13.phx.gbl...
> > I have written text to lpt1 in vbs by writting to the file "LPT1:". What
> if
> > I want to write to a windows printer that is a USB printer? Also I would
> > really like to make the printer use a specific font or font size. Is
there
> > an easy way to do this? In foxpro, I created a DC and used that but I
> can't
> > do that in vbs. Any Ideas are appreciated.
> >
> > Thanks,
> > Paul Temple
> >
> >
>
> Tag: Font Tag: 151392
Edit windows host file
Not a VB programmer so I am hoping someone can help. I need a VB script that
will let me add and remove a FQDN into a windows "host" file when a user
logs on and off. When they log on I need the host file entry removed or
marked out when they log off I need it added back in .
It can even be a script that they will need to execute.
Can someone point me in the right direction.
Thanks
PB Tag: Font Tag: 151386
Forced download + IE6
I've tried a bunch of recommendations on forcing a download in IE6 rather than determine MIME type and open in browser, yet nothing works (even though it works fine in other browsers). Here's the code I've tried
Dim BlockOf, CountOf, objFile, objStrea
BlockOf = 10000
CountOf =
' Session is setup, and a file name (Request.Form("object") has been passed
If FSO.FileExists(Server.MapPath("download") & "\" & Session("username") & "\" & Request.Form("object")) The
Set objFile = FSO.GetFile(CStr(Server.MapPath("download") & "\" & Session("username") & "\" & Request.Form("object"))
' The filename you give it will be the one that is shown to the users by default when they save
Response.ContentType = "application/asp-unknown
Response.AddHeader "content-transfer-encoding", "binary
Response.AddHeader "content-disposition", "attachment; filename=" & objFile.Name & "
Response.AddHeader "content-length", objFile.Siz
Set objStream = Server.CreateObject("ADODB.Stream"
objStream.Ope
' Set as binary
objStream.Type =
Response.CharSet = "UTF-8
Response.Flus
' Load the file into the stream
objStream.LoadFromFile(CStr(Server.MapPath("download") & "\" & Session("username") & "\" & Request.Form("object"))
While objFile.Size > BlockOf + CountO
CountOf = CountOf + BlockO
Response.BinaryWrite objStream.Read(BlockOf
Response.Flus
Wen
Response.BinaryWrite objStream.Read(objFile.Size - CountOf
Response.Flus
Response.En
objStream.Clos
Set objStream = Nothin
Set objFile = Nothin
In particular, the AddHeader "Content-Disposition" line that is supposed to designate the initial filename does not work regardless of what I try. All it ends up displaying to the user is the parent folder hosting the site. Then when the download starts, the file cannot be found
As I said, if I try the code above in another browser it works fine in other browsers (both Mozilla/Firebird, and Opera) and according to the RFC, this should work
Any help would be appreciated. I've tried this on a number of different IE 6 installations, with 2000 and XP, and nothing makes any difference
fh. Tag: Font Tag: 151377
ODBC connection
Hello,
I have a ODBS defined for SQL server. How can I connect and retrieve data from a table in VBScript. Is there any examples.
Thanks.
Jim. Tag: Font Tag: 151373
how to pause code without using msgbox?
Hello all,
Many thanks to all who help me out here. Anway, I am
updating tables in an Access mdb from my app and then
copying files from a server to various workstations. What
happens is that the code will get to a FileCopy command
before various tables have finished updating where the
FileCopy command uses data from the tables. I have been
using msgbox "Pause" to stop code execution, but this is
not seamless. I believe my solution lies here:
Set Shl = CreateObject("WScript.Shell")
But what comes after Shl....?
Any suggestions how to pause code execution (without
msgbox) greatly appreciated.
Thanks in advance.
Rich Tag: Font Tag: 151359
Color sells in RDS control
Hello,
I have an old webpage that uses an RDS control. The declaration of the control looks like this:
<OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
ID=dsoWM HEIGHT=1 WIDTH=1 VIEWASTEXT></OBJECT>
And down the page I data-bind a table
<table id=wmtable datasrc="#dsoWM"><tr><td><span datafld="Name"></span> </td><td><span datafld="City"></span> </td><td><span datafld="State"></span> </td><td><span datafld="MemberSince"></span> </td></tr></table>
My client now wants to color-code certain fields of the table. For example, all the records for people with MemberSince = 2003 should be colored light blue.
I am not sure how to achieve this without re-writing the page from scratch. Is it possible to tap into the rendering of the RDS control? Or, can I data-bind a color property???
Any ideas would be greatly appreciated.
Evgueni Tag: Font Tag: 151350
Get DOS errorlevel in WSH
Hello!
I've to get the errorlevel of a DOS program.
How can I call i.e. ROBOCOPY from Windows Scriptinh Host and get the
errorlevel of it.
THX to all can help
Werner Tag: Font Tag: 151349
Prob with adodb recordset object in vbs
Hello,
I need to read data to a vbs file from an Access Table. I
tried this:
Set cmd = CreateObject("ADODB.Command")
Set rs = CreateObject("ADODB.Recordset")
cmd.ActiveConnection = "Provider =
Microsoft.Jet.OLEDB.4.0; Persist Security Info=false;" _
& "Data Source=" & ScriptFolder & "test.mdb"
cmd.CommandText = "Select * from tbl1"
rs = cmd.Execute
Do while Not rs.EOF
Error says EOF not supported here. (or movenext, etc)
Then I tried a connection object:
conn.Open "Provider = Microsoft.Jet.OLEDB.4.0; Persist
Security Info=false;" _
& "Data Source=" & ScriptFolder & "test.mdb"
Set rs = conn.Execute("SELECT * from tbl1")
This did not do it either. Finally:
rs.Open "tbl1", conn, adOpenStatic, adLockPessimistic,
adCmdTable
Error says "Open" not supported. If I use a variant with
the connection object, that sort of works but not
consistently.
Set var = conn.Execute("Select * from tbl1").
Do While Not var.EOF
How can I get my Adodb recordset object to work in vbs?
Thanks in advance for any suggestions. Tag: Font Tag: 151340
VbScript Help
how do you declare a control in a outlook form so you could just Referance it later in the code. Right now i am placeing this in each functions
Set MyInspector = Item.GetInspector
Set MyPage = MyInspector.ModifiedFormPages("confreg")
set togddc02 = mypage.controls("togddc02")
just so i can use the togddc02 button click
Need some help with this
Thanks
Chris
**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources... Tag: Font Tag: 151334
Reloading the environment variables
I need to reload user environment variables after a script is run...
The script adds user environment variables, and they appear to be there, but
not loaded into the system...
I have tried : "%windir%\System32\RUNDLL32.EXE
user32.dll,UpdatePerUserSystemParameters", _
1, True
But it doesn't seem to work...
Can anyone help me...
Or another way, is there a way to open up environment variables windows and
say OK to it within a script ( invisibly I guess )...
Because when this is done manually, it works very well..
Thanks !!!
--
--
Houman Yahyaei ( CCNA, MCSE Win 2000/NT 4.0, MCT )
IT Training and Consulting
www.formationhy.com
Houman@formationhy.com Tag: Font Tag: 151333
Help with Access and VBScript please
Hello,
I have created a WEB file with FrontPage and I find out how to get the
data from my database in Ms-ACCESS.
My question is if this is possible to execute a macro created in
ACCESS from the WEB site with VBScript?
Also, I would like to know if there is a way to execute my macro
automatically. For example, I want that one of my macro start by
itself each midnight.
Thank you for help.
Jiador Tag: Font Tag: 151332
Weird Type Mismatch Error
I'm stuck on this one - I can't figure out why it's giving me a type
mismatch error. I get the error on the line inside the "IF" statement
that assigns the value in the array to a variable: RegionNumber =
BranchCodes(x)
But if I remove that line, I'll get a type mismatch at the execution
of the SQL statement, and I *KNOW* the SQL is correct and works, as
I've tried that query directly on the DB.
Any suggestions?
/bw
--------------- CODE BELOW --------------------
DIM BranchCodes(10)
BranchCodes(0) = "R00"
BranchCodes(1) = "R01"
BranchCodes(2) = "R02"
BranchCodes(3) = "R03"
BranchCodes(4) = "R04"
BranchCodes(5) = "R05"
BranchCodes(6) = "R06"
BranchCodes(7) = "R07"
BranchCodes(8) = "R08"
BranchCodes(9) = "R09"
DIM objConn,objRS,strSQL,RegionNumber,x
'look up the region for this specific branch
Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.Recordset")
objConn.Open strDataConnect
for x = 1 to 9 'loop through once for each branch number
strSQL = "SELECT Region,RegionName,Location FROM BranchData WHERE
Region = '" & BranchCodes(x) & "'"
Set objRS = objConn.Execute(strSQL)
If NOT objRS.EOF Then
RegionNumber = BranchCodes(x)
Else
Response.Write("<P>Invalid Region Information</P>")
Response.End()
End If
Script continues.... Tag: Font Tag: 151329
I wrote a script that executes a text box at logon and I
wanted to increase the size of the font of the text that
appears in the text box.
What kind of textbox? In what? And is this after login, or before login
(at the C-A-D)?
Ray at work
"Joe" <anonymous@discussions.microsoft.com> wrote in message
news:153c01c3e03a$b2f6ce70$a301280a@phx.gbl...
> I wrote a script that executes a text box at logon and I
> wanted to increase the size of the font of the text that
> appears in the text box.
>
"Joe" <anonymous@discussions.microsoft.com> wrote in message
news:153c01c3e03a$b2f6ce70$a301280a@phx.gbl...
> I wrote a script that executes a text box at logon and I
> wanted to increase the size of the font of the text that
> appears in the text box.
>
The text box is after logon.
For example how can I change the font size and type of the
following text script:
MsgBox "Welcome" & vbCrLf _
& "This is a message from the network logon script" _
& vbCrLf & "Please click ""OK"" to continue"
>-----Original Message-----
>What kind of textbox? In what? And is this after login,
or before login
>(at the C-A-D)?
>
>Ray at work
>
>"Joe" <anonymous@discussions.microsoft.com> wrote in
message
>news:153c01c3e03a$b2f6ce70$a301280a@phx.gbl...
>> I wrote a script that executes a text box at logon and I
>> wanted to increase the size of the font of the text that
>> appears in the text box.
>>
>
>
>.
>
"Joe" <anonymous@discussions.microsoft.com> wrote in message
news:1e8b01c3e03f$da970e40$a601280a@phx.gbl...
> The text box is after logon.
> For example how can I change the font size and type of the
> following text script:
>
> MsgBox "Welcome" & vbCrLf _
> & "This is a message from the network logon script" _
> & vbCrLf & "Please click ""OK"" to continue"
>
>
>
> >-----Original Message-----
> >What kind of textbox? In what? And is this after login,
> or before login
> >(at the C-A-D)?
> >
> >Ray at work
> >
> >"Joe" <anonymous@discussions.microsoft.com> wrote in
> message
> >news:153c01c3e03a$b2f6ce70$a301280a@phx.gbl...
> >> I wrote a script that executes a text box at logon and I
> >> wanted to increase the size of the font of the text that
> >> appears in the text box.
> >>
> >
> >
> >.
> >
i don=B4t understand??
>-----Original Message-----
>See your original thread.
>
>Ray at work
>
>"Joe" <anonymous@discussions.microsoft.com> wrote in=20
message
>news:1e8b01c3e03f$da970e40$a601280a@phx.gbl...
>> The text box is after logon.
>> For example how can I change the font size and type of=20
the
>> following text script:
>>
>> MsgBox "Welcome" & vbCrLf _
>> & "This is a message from the network logon script" _
>> & vbCrLf & "Please click ""OK"" to continue"
>>
>>
>>
>> >-----Original Message-----
>> >What kind of textbox? In what? And is this after=20
login,
>> or before login
>> >(at the C-A-D)?
>> >
>> >Ray at work
>> >
>> >"Joe" <anonymous@discussions.microsoft.com> wrote in
>> message
>> >news:153c01c3e03a$b2f6ce70$a301280a@phx.gbl...
>> >> I wrote a script that executes a text box at logon=20
and I
>> >> wanted to increase the size of the font of the text=20
that
>> >> appears in the text box.
>> >>
>> >
>> >
>> >.
>> >
>
>
>.
>
You had a thread about this going on from earlier today already. Let's
stick to just the one thread.
Ray at work
"Joe" <anonymous@discussions.microsoft.com> wrote in message
news:1e6701c3e044$d4386710$a401280a@phx.gbl...
i don´t understand??
>-----Original Message-----
>See your original thread.
>
>Ray at work
>
>"Joe" <anonymous@discussions.microsoft.com> wrote in
message
>news:1e8b01c3e03f$da970e40$a601280a@phx.gbl...
>> The text box is after logon.
>> For example how can I change the font size and type of
the
>> following text script:
>>
>> MsgBox "Welcome" & vbCrLf _
>> & "This is a message from the network logon script" _
>> & vbCrLf & "Please click ""OK"" to continue"
>>
>>
>>
>> >-----Original Message-----
>> >What kind of textbox? In what? And is this after
login,
>> or before login
>> >(at the C-A-D)?
>> >
>> >Ray at work
>> >
>> >"Joe" <anonymous@discussions.microsoft.com> wrote in
>> message
>> >news:153c01c3e03a$b2f6ce70$a301280a@phx.gbl...
>> >> I wrote a script that executes a text box at logon
and I
>> >> wanted to increase the size of the font of the text
that
>> >> appears in the text box.
>> >>
>> >
>> >
>> >.
>> >
>
>
>.
>