Copy files up to 1Mbyte
I use this command
xcopy c:\source m:\dest\local /m/e/e/v/h/y
which works quite well.
Now I need to copy only files below 1 MByte
because files greater than 1 MByte are rare but can fill the destination too
quickly.
(Sorry for my English)
I think, the answer will be in VBS.
Thanks for all
Bernd Tag: Copy file Tag: 193450
rename a folder full of jpgs with the size of the file
Is it possible to use vbscript to rename a folder full of jpgs, giving each
one a new name with its size in kilobytes?
So "sample.jpg" would become "29.jpg" indicating that the file size of
29.jpg is 20 kb. Tag: Copy file Tag: 193449
READONLY Form fields
So, I want to have a form that gets submitted to itself adn then I set the
fields to readonly, but I want to have an "Edit" button so that people have
one last chance to fix everything without sending them to an all new page
before submitting. Does anybody out there know of away within VBscript to
change this setting within each form field w/o having to re-submit the whole
page again?
For instance:
<input type="text" name="church_phone" value="" size="16" maxlength="20"
class="dfinput" ID="Text10" <% IF request("formstatus")="locked" THEN
%>READONLY<% END IF %>>
So, when I first submit the form I set a variable formstatus to "locked",
but when I click the edit button I want it to change to "editable".
Thanks!
Willie Tag: Copy file Tag: 193446
Accessing Nodelistvalues from mssoap client with vbs
Hi
I should write a script with vbs which calls a webservice with the mssoap
client. If I call a service which returns only one value there is no
problem. But if I try to call a webservice which returns an array of objects
i get some problems.
The following code works without problems in vba but not in vbs. I found out
that i get the error if I try to access a value from a nodelist like
items(i).length. Is there an other solutions to access values from a object
array?
Does someone have an idea how I could solve this problem?
thank's
michel
Public Function TestSoap2()
Dim objSoap
Dim strReturn()
Dim strWsdl
Dim strError
Dim strEmbDate
Dim items
Dim item
Dim i
Dim z
'
' EXAMPLE calling a google web service
strWsdl = "http://www.omnisolutions.ch/SLXService/service.asmx?WSDL"
Set objSoap = CreateObject("MSSOAP.SoapClient")
objSoap.mssoapinit (strWsdl)
items = objSoap.GetDocuments2("Name")
For i = 0 To UBound(items) Step 1
For z = 0 To items(i).length - 1
MsgBox items(i).item(z).Text
Next
'item = items(i).item(0)
'MsgBox items.length
Next
' msgbox items
Set objSoap = Nothing
End Function Tag: Copy file Tag: 193445
Error Handling
Hello friends,
I have written a script that goes through folder looking for a
sub-folder named "Cookies". If it filnds Cookies then it will enumarate
all files in that folder and delete te files which are older than 7
days.
I want to implemnet error handling where it reports what is wrong if it
cannot perform the above mentioned functions and contunie with the
loop. It displays the error message if there is a directory permmission
related issue and exits the script rather than going through it. Can
youplease point out the error?
As you see I have implemented On Error Resume Next ststement pretty
much in every loop just for troubleshooting but I really cannot
pinpoint where it is not working
__________________________________________________________________________
Dim objShell, objFSO, sUserProfile, objUserProfile, sAppDataFolder,
sUserDir, SFolders Dim sAppData, objDocsAndSettings, objUser, IDate,
oCookies, oFile, File, oFilesCollection, tCookies, col
Set objShell = CreateObject("Shell.Application") Set objFSO =
CreateObject("Scripting.FileSystemObject")
set sUserDir = objFSO.GetFolder("D:\TEST")
' Get user profile folder
ShowSubFolders objFSO.GetFolder(sUserDir)
' Get Sub Folders
'On Error Resume Next
Sub ShowSubFolders(Col)
On Error Resume Next
For Each SubFolder In Col.SubFolders
If SubFolder.name = "Cookies" Then
Wscript.echo "Deleteing Files From" & Space(2) & SubFolder.Path
Set oFilesCollection = SubFolder.Files
'On Error GoTo 0
'On Error Resume Next
For Each oFile IN oFilesCollection
IF DateDiff("d",oFile.DateLastModified,Now)>7 Then
oFile.Delete(True)
If Err.Number <> 0 Then
WScript.Echo "Can't Delte the file" & Space(2) & oFile.Path
WScript.Echo "(" & Err.Number & ") " & Err.Description
'WScript.Echo ""
WScript.Quit Err.Number
End if
'Wscript.echo oFile.name
Err.clear
End If
next
'On Error GoTo 0
End If
'On Error GoTo 0
ShowSubFolders SubFolder
'Err.clear
Next
'Err.clear
End Sub
Thanks
cha Tag: Copy file Tag: 193443
Writing to Excel appending
Please Help
here is the problem this file will be on a network share when i rum the
script the top portion works fine it opens the script and finds the first
unused cell,
the second part is just an example of what i want to do. when i run this on
a computer i want it to write or append the information to the spreadsheet,
and on a second computer third ect, can you please help i will need to write
to at least 6 cells across x whatever down then the top portion will find
the last used cell and it can start over again appending
Thank you
Bob M
-----------------------------------------------------------------------------------------------------------------------------------
Const xlCellTypeLastCell = 11
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Open("C:\Scripts\Test.xls")
Set objWorksheet = objWorkbook.Worksheets(1)
objWorksheet.Activate
Set objRange = objWorksheet.UsedRange
objRange.SpecialCells(xlCellTypeLastCell).Activate
intNewRow = objExcel.ActiveCell.Row + 1
strNewCell = "A" & intNewRow
objExcel.Range(strNewCell).Activate
objRange.EntireColumn.Autofit()
'=========================================================================================
'=========================================================================================
'=========================================================================================
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Bus")
For Each objItem in colItems
Wscript.Echo "Bus Number: " & objItem.BusNum
Wscript.Echo "Bus Type: " & objItem.BusType
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "Device ID: " & objItem.DeviceID
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
Next Tag: Copy file Tag: 193440
update multiple PowerPoint files and modify ShockWave Flash page with new movies???
I'm lost trying to do this.
I need to write a script to go thru many small Powerpoint
presentations and embed new versions of movies in the ShockWaveFlash
object.
I can get to the right slide and detect the OleObject for the Flash
but I can't figure out how to reference/modify it from the script.
It's crude but I loop thru the slides looking for the OleObject
ActiveWindow.Selection.SlideRange.Shapes(i).Select
Select Case .Type
Case msoOLEControlObject 'Type 12
If it's a OLEControlObject then I have the right page (all it
contains is the ShockWave Flash movie.
I just want to embed a new movie on this slide then save the
presentation and move on.
Is this possible?. If someone has a code snippett, it would help a
lot..
Alternatively: I assume I could create a newslide and embed the movie
Many Thanks from a VBS/WSH novice! Tag: Copy file Tag: 193435
How users can update their own personal properties in Active Directory
I wonder if it is possible for users update their personal properties in
Windows 2003 - AD but only the fields i want to/choose.
Can someone give me a tip or script how can this be done?...
Thanks
[]
Ricky
(sorry for so must posts) Tag: Copy file Tag: 193434
HTA Logon Script
I'm trying to create what I think would be a simple logon script. I've
posted the general idea of what I want my log in script to do. We have AD
2003 wither xp and 2000 clients. I was assuming that it would be easy to
crate a vbscript and then convert it to HTA. But I can't find any websites
that are very clear. Can any one please suggest a beginners website?
What I want to do is:
-Have IE start with no tool bar or close button:
-Display the school logo
-Display a welcome message
-Perhaps displeay something like the date and time and the name of the
computer they're logged on to
-Map several drives and then display the drives that are mapped (i.e. "Your
home drive is H:, The Documents Drive is R:)
-Map one or two printers and display the mapping
-Display a link to report computer issues to the help desk
-Display a link that goes to another HTA to allow users to add/delete
printers
-Display a link that goes to instructions of how to upgrade their computers
to XP (a link to instructions to explain how to inititate an unattended
install)
-Then display a 'Close this window"
-Just for fun, I thought it might be fun to have it setup so that when they
click the close this window button, either it moves five inches and they
have to click it again. Or it brings up another window saying "Are you sure
you read the instructions" Or are you sure you want to close this window?
But that would only confuse/annoy people so I wouldn't do it. It's just a
passing thought. After they read it the first couple of times anyway,
they'd know just to hit enter twice so they could ignore the messages. Tag: Copy file Tag: 193433
Running a vbs file from a network path at logon
What is the proper way of executing a vbs file from a network path upon
start up of a machine in a workgroup not an ADSI? I have tried a
variety of different netlogon paths and setting the home local to the
network path, but I have not had any luck. I am sure I am missing
something very simple, Thank you in advance. Tag: Copy file Tag: 193425
capture a users home directory path to use as a folder name
Below is part of a script I'm working on. This part is supposed to
determine the user's existing home directory path so it can copy all the
contents to the user's new home drive. How can I capture the existing home
directory path?
Thanks,
Jeremy
_____________________________
' Determin existing home directory share path somehowe
' Pass existing home directory share path to variable
objOldHomeDirectory = existing home directory share path
' Determining if existing home directory share is already on my server
If InStr(objOldHomeDirectory, "\\s047") = 0 Then
' Create and share new home directory on \\s047-s0371-01
***Code not presented here***************
' Copy contents of existing home directory (including subfolders) and paste
into the new home directory
Set FSO = Wscript.CreateObject ("Scripting.FileSystemObject")
objFSO.CopyFolder objOldHomeDirectory, \\s047-s0371-01\ & objHomeDirectory
' Change the Home Directory path in the Profiles tab
objGroup.Put "HomeDirectory", \\s047-s0371-01\students\" & objHomeDirectory Tag: Copy file Tag: 193422
Wxp - Locking CD-ROM Door Closed.
Hello Everyone!
ISSUE: locking CD-Rom door. (eg: you push the button and the tray
dosn't open)
OS: Windows XP
Scripting Lang.: Visual Basic Script (.VBS)
================================
Basicly to use in a login script to lock the CD tray closed.
and keep it locked untill I run a script to unlock the tray.
I found some VB code to do this with the API's
Since I'm new to .vbs I don't know how I could convert it to a script.
can anyone help??
Thanks a million in advance.
~Marc Tag: Copy file Tag: 193418
laptop / Desktop?
Hi All,
i would write a script that have difference procedure for laptop and desktop
but i don't know which function can be check. any advise?
thanks,
William Tag: Copy file Tag: 193413
xml.send errors????
254643
cscript //nologo c:\util\ftpvbs.vbs "ftp://ftpav.ca.com/pub/inoculan/scaneng/Siglist.txt" "C:\TEMP\" "Siglist.txt"
c:\util\ftpvbs.vbs(8, 1) msxml3.dll: System error: -2146697210.
For the past 2 years, I have been successully issueing the following commands, every night, on Windows XP Pro, via the Task Scheduler.
cscript //nologo c:\util\ftpvbs.vbs "ftp://ftpav.ca.com/pub/inoculan/scaneng/Siglist.txt" "C:\TEMP\" "Siglist.txt"
cscript //nologo c:\util\ftpvbs.vbs "ftp://ftpav.ca.com/pub/inoculan/scaneng/ii_nt86.exe" "C:\TEMP\" "ii_nt86.exe"
cscript //nologo c:\util\ftpvbs.vbs "ftp://ftpav.ca.com/pub/inoculan/scaneng/iv_nt86.exe" "C:\TEMP\" "iv_nt86.exe"
cscript //nologo c:\util\ftpvbs.vbs "ftp://ftpav.ca.com/pub/inoculan/scaneng/fi_nt86.exe" "C:\TEMP\" "fi_nt86.exe"
cscript //nologo c:\util\ftpvbs.vbs "ftp://ftpav.ca.com/pub/inoculan/scaneng/fv_nt86.exe" "C:\TEMP\" "fv_nt86.exe"
The c:\util\ftpvbs.vbs file contains:
Dim objArgument
Set objArgument = Wscript.Arguments
URL=objArgument(0)
DestFolder=objArgument(1)
ImageFile=objArgument(2)
Set xml = CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", URL, False, "user", "pass"
xml.Send
set oStream = createobject("Adodb.Stream")
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Const adSaveCreateNotExist = 1
oStream.type = adTypeBinary
oStream.open
oStream.write xml.responseBody
' Do not overwrite an existing file
oStream.savetofile DestFolder & ImageFile, adSaveCreateNotExist
' Use this form to overwrite a file if it already exists
' oStream.savetofile DestFolder & ImageFile, adSaveCreateOverWrite
oStream.close
set oStream = nothing
Set xml = Nothing
About a week ago, I started to receive:
c:\util\ftpvbs.vbs(8, 1) msxml3.dll: System error: -2146697210.
I have no idea why or how to resolve this.
I can manually download the 5 files with no problem.
Prior to running the script, the previous versions of the 5 files are
deleted from C:\temp.
KB 254643 is the only article which has "System error" and -2146697210
Any help would be appreciated.
Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com Tag: Copy file Tag: 193406
VBS file imports xml into access adp
Hi everyone,
I have a vbs file on a timed WinXP scheduled task that opens up Access 2003
then deletes older data from mssql server tables and then imports from an
xml file using objAccess.ImportXML. This worked perfectly until last night
when the server with the xml on it was down. Is there a way to check to
make sure the xml is there before the routine starts?
Kindest regards,
Kevin Tag: Copy file Tag: 193404
Dim stmt
OK, first here is the code:
sqlcmd = "SELECT space_available, ministry_id, pricing_id, min_group,
max_group FROM tbl_event WHERE event_id = " + int_event + " AND (event_year
= DATEPART(YYYY,GetDate()) OR event_year = (DATEPART(YYYY,GetDate()+1)))"
set rs = conn.Execute(sqlcmd)
IF rs("pricing_id") = 0 THEN
bln_group = "false"
ELSEIF rs("pricing_id") <> 0 THEN
bln_group = "true"
END IF
'This is the IF stmt that is giving me the problems
IF num_spaces > rs("space_available") THEN
bln_space = "false"
ELSEIF num_spaces < rs("space_available") THEN
bln_space = "true"
END IF
So, I am passing form data to this form, then doing a compare on some of the
values. I pull from the database the total number of spaces available for
the specified event and then compare that to the number of people they want
to send to the event to determine if there is space available. I know this
doesn't take into account if there are already registrations, that is the
next step, but for now the compare is failing. When I write out the values,
I get that the num_spaces is right, let's say 12 and the
rs("space_available") is right, 225, but the compare is wrong, it resolves
to bln_space="false". Now, I have been working on isolating this problem for
like 18 hours (pathetic, I know), so perhaps some fresh eyes/minds can see
where I have gone astray? Any input would be most appreciated.
Willie Tag: Copy file Tag: 193399
Uninstall software through VB scrips
Trying to uninstall a software with it instead of reaching out to add and
remove programs. Tag: Copy file Tag: 193394
Stream object's Write method
I'm trying out the following code:
Set Shell = CreateObject("WScript.Shell")
Set Stream = CreateObject("adodb.stream")
adTypeBinary = 1
adSaveCreateOverWrite = 2
Stream.type = adTypeBinary
Stream.Open
Stream.Write
Shell.RegRead("HKEY_CLASSES_ROOT\.zip\CompressedFolder\ShellNew\Data")
Stream.SaveToFile "test.zip",adSaveCreateOverWrite
The code errors out at the call to Stream.Write. According to the
documentation for the Write method, it's expecting a Variant array of bytes.
A type check of the Shell.RegRead call reveals that it does return a variant
array containing bytes. The same thing happens if I replace the
Shell.RegRead call with an Array of integers converted to bytes. The only
thing that I can think of is that the Write method is expecting
strongly-typed bytes, which is not possible in script. Is that the problem?
Write method docs:
http://msdn.microsoft.com/library/en-us/ado270/htm/mdmthwrite.asp Tag: Copy file Tag: 193390
Tool to convert PERL to VBS
I am looking for a tool which can be used to convert PERL script to an
equivalent VB script. I have done some googling but did not find one yet.
If some one has done this please let me know.
I tried Scriptomatic but could not convert it fully.
Basically I have a PERL script that lists all shares on a list of servers
(500), and add a deny group to them except admin shares. If anyone has a VB
script please share.
Thanks Tag: Copy file Tag: 193388
Updating Access Information VIA VBS
I have created an Access Database with a corresponding table to a
script being executed. The vbs script will be executed at logon of a
variety of different PCs (At this time not in an ADSI). When executed
it will fill in the table with a variety of system information; comp
name, ram, cpu, ect.... I have pretty much tweaked and finish the
script to my liking, the only stage I have left is make sure that upon
logon the script will check for updates to any of the system
information, if updates exists to change the proper fields listed under
that computer name (in the row). Currently I am using the computer name
as the primary key, to avoid duplicate computer entries. (If there is a
better way to handle duplicate information please let me know!)
I found the following in TechNet Office Space. I believe the answer to
my question is some how intertwined to a Recordset.Update, but I am
unsure how to approach doing this. If anyone can help that would be
fantastic any information needed from me please let me know and I will
provide it ASAP.
On Error Resume Next
Const adOpenStatic = 3
Const adLockOptimistic = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
objConnection.Open _
"Provider = Microsoft.Jet.OLEDB.4.0; " & _
"Data Source = c:\scripts\inventory.mdb"
objRecordSet.Open "SELECT * FROM GeneralProperties" , _
objConnection, adOpenStatic, adLockOptimistic
strCriteria = "ComputerName = 'atl-ws-99'"
objRecordSet.Find strCriteria
objRecordset.Fields.Item("Department") = "Finance"
objRecordset.Update
objRecordSet.Close
objConnection.Close Tag: Copy file Tag: 193381
How to use WScript to execute DOS command line in VBScript
Hi VBScript Expert,
I am trying to execute the commandline from WScript object, but don't know
the correct syntax as well as how to retrieve the commandline output result.
Here are part of the codes for your reference:
dim obj
Set obj = WScript.CreateObject("WScript.Shell")
obj.Run "Netstat.exe -n | find ""172.16.1.186:1388"" | find /C
""ESTABLISHED"""
The whole purpose is to detect whether the connection to port 1388 has been
established or not. If yes, do someting, else exit.
Thanks for your help!!!
-adam Tag: Copy file Tag: 193380
WMI Output from different classes to CSV
Hello,
Using scriptomatic I thought it would be helpful to make a script to find
the type of machine (Dell GX60, GX520, GX260 and so on) and BIOS version.
I made the two scripts, whittled down the parts I don't need and now I want
to put it into a CSV, the problem is that since the queries run against two
different classes the For loops are seperated, making two lines per PC rather
one in my destination CSV file. Is there a way to make the second For loop
append to the correct line or have the loop run in such a way that the line I
want is created? Here's my code (ignore wrapping by the NG engine):
filePath = "C:\Temp\"
filePrefix = "BIOS"
fileExt = ".csv"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile(filePath & filePrefix & fileExt)
objFile.WriteLine "Computer Name,ID Number,Sytem Model,UUID,Serial
Number,BIOS Version,Status,Version"
arrComputers = Array("pc1","pc2","pc3)
For Each strComputer In arrComputers
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM
Win32_ComputerSystemProduct", "WQL", _
wbemFlagReturnImmediately +
wbemFlagForwardOnly)
For Each objItem In colItems
objFile.WriteLine
UCase(strComputer)&","&objItem.IdentifyingNumber&","&objItem.Name&","&objItem.UUID
Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_BIOS", "WQL", _
wbemFlagReturnImmediately +
wbemFlagForwardOnly)
For Each objItem In colItems
objFile.WriteLine
UCase(strComputer)&","&objItem.SerialNumber&","&objItem.SMBIOSBIOSVersion&","&objItem.Status&","&objItem.Version
Next
Next
Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm:
WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" &
Mid(dtmDate,13, 2))
End Function Tag: Copy file Tag: 193379
VB Script in totaling sums
I have an Access database and am using Front Page with a little SQL and VB
script to manipulate and display data. I am having some problems with a page
that is displaying data properly but is not totaling points correctly by the
desired variable. It is also not providing total points for the last entry
on the page. I'm not sure this is the correct list to get help with this or
not. Here is some of the code from the page. I need it to total points by
NWHAHP even if there is a newshow or lastshow. I also need it to provide
total
points for the last NWHAHP entry on the page. Thanks in advance for any
suggestions and assistance. If you need more information, please let me
know.......DN
<%@ LANGUAGE=VBScript %>
<%dim Lastshow, Newshow, LastNWHAHP, NewNWHAHP
Lastshow = " "
Newshow = " "
LastNWHAHP = " "
NewNWHAHP = " "
%>
<%dim Totalpoints
Totalpoints = 0.0
%>
Within this area is the Database Results info.
<!--webbot bot="DatabaseRegionStart" endspan -->
</font>
</font>
<% Newshow = FP_FieldVal(fp_rs,"Name")%>
<% NewNWHAHP = FP_FieldVal(fp_rs,"NWHAHP")%>
<%if ((NewNWHAHP <> LastNWHAHP) and (LastNWHAHP <> " ")) or ((Newshow <>
Lastshow) and (Lastshow <> " ")) then%>
<tr><td nowrap colspan="3"> </td><td nowrap colspan="2"><font face="Arial"
size="1" >Total Points</font></td><td nowrap ><font face="Arial" size="1" >
<%=Totalpoints%></font></td></tr>
<tr><td colspan="6"><hr width="100%"></td></tr>
<% Totalpoints = 0%>
<% end if %>
<td nowrap ><font face="Arial" size="1" color="#000080">
<% Totalpoints =Totalpoints + FP_FieldVal(fp_rs,"Points")%>
<%if ((NewNWHAHP <> LastNWHAHP) ) then%>
<!--webbotbot="DatabaseResultColumn" startspan
<%elseif Newshow <> Lastshow and ((NewNWHAHP = LastNWHAHP) or (LastNWHAHP =
" "))then%>
<%=FP_FieldVal(fp_rs,"Name")%>
<% end if %>
</td>
<% Lastshow = FP_FieldVal(fp_rs,"Name")%>
<% LastNWHAHP = FP_FieldVal(fp_rs,"NWHAHP")%>
<!--webbot bot="DatabaseRegionEnd" endspan -->
</tbody>
<tr><td nowrap colspan="3"> </td><td nowrap colspan="2"><font face="Arial"
size="1" >Total Points</font></td><td nowrap ><font face="Arial" size="1" >
<%=Totalpoints%></font></td></tr> Tag: Copy file Tag: 193378
Mapnetwork drive (not on the own machine)
Hi,
I'm a beginner in scripting and have a question about mapping a network
drive.
On my local machine (or as a logon script) this code works exactly as
it should :
Dim NetworkObject
Set NetworkObject = CreateObject("Wscript.Network")
NetworkObject.MapNetworkDrive "Z:", "\\server\user\LogFiles"
But how can i do this e.g. from my machine on a remote machine ?
I though that
strComputer = "computername"
defines the machine on which this script should run, but when i add
this line to this basic script, it still runs on my machine.
Please apologize for this question, but i'm just learning how to script
in VB and currently i can't explain myself why this is not running in
that case, in some other script i used this variable already and there
it worked ?
Best regards
Uwe Tag: Copy file Tag: 193374
Left join not working properly?
I must be missing something simple but I have a SELECT query with a
LEFT JOIN that works fine when I run it in Access but not when I run it
from an ASP page against the exact same database.
Here's a basic example that I can't get to work - the tables are set up
like this:
CUSTOMERS
==========
ID NAME WARRANTY_PLAN_ID
1 John Smith 1
2 Jane Jones 0
3 Fred Johnson 2
WARRANTY
==========
WARRANTY_PLAN_ID WARRANTY_TYPE
1 basic
2 extended
3 complete
If I run this query:
SELECT CUSTOMER.*, WARRANTY.*
FROM CUSTOMER
LEFT JOIN WARRANTY ON CUSTOMER.WARRANTY_PLAN_ID =
WARRANTY.WARRANTY_PLAN_ID
WHERE CUSTOMER_ID = 1
I get a single row back as you'd expect. But if I run this:
SELECT CUSTOMER.*, WARRANTY.*
FROM CUSTOMER
LEFT JOIN WARRANTY ON CUSTOMER.WARRANTY_PLAN_ID =
WARRANTY.WARRANTY_PLAN_ID
WHERE CUSTOMER_ID = 2
It returns nothing. EOF. But that same query DOES work when I run it
in Access.
What am I missing?
Thanks,
Tom Tag: Copy file Tag: 193369
wmic
WMIC CALL allows execution of the methods available to a class. Can the
GETSECURITYDESCRIPTOR method method of win32_logicalsharesecuritysetting be
called using WMIC? Below is the result when I try - it isn't clear how to
pass parameters to the method from the documentation.
Anyone have experience with this?
TIA
Dave
--------------------------------------------------------------------------------------------
wmic:root\cli>path win32_logicalsharesecuritysetting
Caption ControlFlags Description
Name SettingID
Security settings of print$ 32772 Security settings of print$
print$
Security settings of HPOffice 32772 Security settings of HPOffice
HPOffice
Security settings of downloads 32772 Security settings of
downloads downloads
Security settings of recordings 32772 Security settings of
recordings recordings
Security settings of stuff (E) 32772 Security settings of stuff
(E) stuff (E)
wmic:root\cli>path win32_logicalsharesecuritysetting call /?
Method execution operations.
USAGE:
CALL <method name> [<actual paramlist>]
NOTE: <actual paramlist> ::= <actual param> | <actual param>, <actual
paramlist>
The following verb(s)/method(s) are available:
Call [ In/Out ]Params&type Status
==== ===================== ======
GetSecurityDescriptor [OUT]Descriptor(object:Win32_SecurityDescriptor)
Implemented
[OUT]ReturnValue(uint32)
SetSecurityDescriptor [IN ]Descriptor(object:Win32_SecurityDescriptor)
Implemented
[OUT]ReturnValue(uint32)
wmic:root\cli>path win32_logicalsharesecuritysetting call
getsecuritydescriptor
Executing (win32_logicalsharesecuritysetting)->getsecuritydescriptor()
ERROR:
Code = 0x8004102f
Description = Invalid method Parameter(s)
Facility = WMI Tag: Copy file Tag: 193366
Logon Script
I am trying to create logs of user logon and logoff events to track for
our employees to verify hours timecards hours. I have the following
script applied as a logon script in a GPO:
ECHO %username%,LogOn, %TIME%, %DATE%, %COMPUTERNAME% >>
C:\%username%.csv
I was wondering if there was a way to determine if the logon was via
remote desktop or console. I know how to verify in the event log based
on logon type but is there a way to get that information progmatically?
Thank you for any help. I am new to scripting so any direction or code
snippets would be greatly appreciated. Thank you again. Tag: Copy file Tag: 193365
write to html text box vbscript
Hi Guys,
Im attempting to populate a text box in my asp.net solution using
vbscript. Im able to read values from the text boxes using the
following code (document.form1.txt_Product1.Value)
im using the following code to try and write to it
document.getElementById("lbl_ErrorHTML").value ="eeee"
it doesnt work and gives the following error
Microsoft VBScript runtime error: Object doesn't support this property
or method: 'document.getElementById(...).value'
can anyone help me with this ???
thanks
C Tag: Copy file Tag: 193358
RegEx Replace text not inside HTML tag
Hi,
My app generates a HTML results page and, while building up the page
prior to writing it to disk, I want to add some extra HTML to highlight
the text that has been matched via the search criteria of my app using
RegExp. I am trying to create a pattern that will exclude HTML tags so
that I can do a replace without junking the HTML.
For example, if my result page looked like this:
<HTML>
<HEAD></HEAD>
<BODY>
<TABLE width=500>
<TR>
<TD>This is my sample page with a table and some text</TD>
</TR>
</TABLE>
</BODY>
</HTML>
and a user types a lone "t" as the search criteria then the pattern
needs to be able to search
the entire page but only match the text not between a "<" and ">" so
that the re-formatted page would look like this:
<HTML>
<HEAD></HEAD>
<BODY>
<TABLE width=500>
<TR>
<TD><span style='background-color:yellow;'>T</span>his is my sample
page with a <span style='background-color:yellow;'>t</span>able and
some <span style='background-color:yellow;'></span>ex<span
style='background-color:yellow;'>t</span></TD>
</TR>
</TABLE>
</BODY>
</HTML>
Cant for the life of me work out how to do this without junking the
HTML!
Thanks heaps Tag: Copy file Tag: 193353
need to copy file to pc's in login script
Hello,
I need to copy a file to pc's in a login script.
On the Pc the error that i get on the pc in eventvwr is
Unable to copy screensaver to C:\Scsaver.scr:
Object required
Source WSH Event ID 4
Any ideas?
All my research indicates that the logon GPO script runs using the
Everyone Permission from the PC which has Read & Execute.
I also added Write permission this did nothing. Tag: Copy file Tag: 193345
VBS Newbie
Hi,
I am a total newb when it comes to programming. I am wondering if anybody
can point me to a comprehensive guide to VBscript. I am having particular
trouble with, objects, classes, methods, parameters, and properties.
Is is a prerequisite that I know some other programming language before
learning VBscript? Tag: Copy file Tag: 193340
Clear cscript window output
Is there a way to clear the screen when running a vbs script in cscript, like
the cls command in dos and the syscls in rexx? Tag: Copy file Tag: 193333
Multiple IP Address to Output into an Access Table
I have been using the following script to gather IP information.
Unfortunately now I need a script that can pull and separate the wired
and wireless ip addresses for a local machine. When I implement the
following script to write to an access database the database will only
capture one of the two ip address, or it will use two rows to repeat
the system information to display both IP address. I have used all the
tricks I know and I have decided to seek help! If anyone has any input,
it would be greatly appreciated. The temporary fix I have been using is
to delimit the ips with a space, unfortunately I do need them to
displayed in different fields for certain reports I will run from the
database.
So to recap: I need a script that can write both the IP Physical and
the IP Wireless address to a table in two different columns not rows.
If you need any information from me please ask, I am very interested in
a solution to this problem.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where
IPEnabled=TRUE")
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
WScript.Echo IPConfig.IPAddress(i)
Next
End If
Next Tag: Copy file Tag: 193332
Creating database reports in MS Word using ASP
I want to create an ASP page that will dynamically create a Word document
based on a Recordset, and then display the document as an instance of Word in
the browser. This is on an internal Web server, with everyone using Word 2000
and IE6. My goal is to have a page that can generate a printable report for
any month or year selected.
I tried using the script in this KB article
(http://support.microsoft.com/default.aspx?scid=kb;EN-US;q301044) but it
didn't create an instance of Word or Excel. It just dumped the content into
the browser window.
If creating an instance of an Office app involves too much programming
overhead, is there a simple way of generating the necessary formatting so all
content is formatted for printing on letter-size paper? Tag: Copy file Tag: 193331
date time conversiton
I have a column with value as timestamp. e.g. 2006-07-06 13:30:55.773000
I want to covert this to 24 hr clock timing how can I do this in scripting
like VBscript
thanks Tag: Copy file Tag: 193321
group membership
I'd like to create a script that loop through all of the groups in a
particular OU and lists out members of each group. I've found scripts that
do member lists, but you had to input the group name.
Any help/links would be appreciated.
Mar Tag: Copy file Tag: 193317
Function Help
Hi Everybody,
I need to return "4,5,6,7,8" from "1,2,3,4,5,6,7,8,9,10" using a VB Script
function.
How can I achieve this.
Any help is appreciated.
TIA,
Sunny Tag: Copy file Tag: 193312
How to create a lookup table in VBScript
Hi all,
I am new to VBScript. I have, say 100, IP addresses, which are divided
into
4 groups. E.g.
UNIX_GRP: 192.168.1.2 192.168.2.3 192.168.8.200 ... (20 addresses in
total)
WINDOWS_GRP: 192.168.6.9 192.168.12.13 192.168.18.20 ... (65 in total)
ROUTER_GRP: 192.168.1.1 192.168.2.1 ... (10 in total)
FIREWALL_GRP: 192.168.1.2 ... (5 in total)
Then I have a log file, which contains say 10,000 lines and each line
contains
an IP address (must in the above 100 addresses). I have to parse each
line,
get the IP address, and copy each log line into one of 4 files
depending on
which group the IP addres is in.
I am thinking to create a lookup table for these 100 ip addresses, e.g.
192.168.1.1 ROUTER_GRP
192.168.1.2 UNIX_GRP
...
So my script could easily figure out the ip address belongs to which
group.
I could do this quickly in unix shell or Perl, but I have to use
VBScript for this
project. I was wondering how to create a lookup table in VBScript, how
to
use IP-address as the array index or I have to use 2-d array. Or you
might
have suggestions to solve the problem.
Thanks in advance.
James Tag: Copy file Tag: 193311
Sending data to a printer
This seems like it should be easy, but I can't find any information in my
documentation. Can somebody show me how to send "Hello, World!" to my printer?
--
Crash Tag: Copy file Tag: 193307
AJAX type databinding
I have created a asp page that allows me to add records successfully to
a database using a ajax methods. This works for me but i need to update
the data table that is on the same page with the new record without
refreshing the page. Does anybody know good methods for vbscript and
ajax? Any help would be appreciated. Thanks. Tag: Copy file Tag: 193299
VBScript deletes folder by date in the filename?
Hello,
I have looking for a script that will delete folders by the date in the
name. 06022006 would be the folder name. We need to delete any folder that is
30 days old. I have something that is kind of like it but it only deletes
files. Can someone take a look and tell what needs to be changed? Thanks for
you help
Shawn
************************************************************
Option Explicit
'*
'* Declare Constants
'*
Const cVBS = "DeleteFilesByDateInName.vbs"
Const cFIL = "Stats_yyyymmdd.zip" '= Filename template
Const cFOL = "D:\temp\" '= Folder with files
Const cOLD = 30 '= Delete if days >
'*
'* Declare Variables
'*
Dim strDAT
Dim intFIL
intFIL = 0
Dim strFIL
Dim strGFO
Dim strMSG
strMSG = " file(s) older than " & cOLD & " days deleted from " &
cFOL & vbCrLf
Dim strNAM
Dim strNOW
strNOW = Now
Dim intPOS
intPOS = InStr(cFIL,"yyyymmdd")
Dim strYMD
'*
'* Declare Objects
'*
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objGFO
Set objGFO = objFSO.GetFolder(cFOL)
Dim objGFI
Set objGFI = objGFO.Files
'*
'* Delete files from folder "cFOL" older than "cOLD" days if their
filename
'* is in the "cFIL" format and it contains a date in the format
"yyyymmdd".
'*
For Each strFIL In objGFI
'*
'* Is format of filename valid?
'*
strNAM = strFIL.Name
strNAM = Left(strNAM,intPOS-1) & "yyyymmdd" & Mid(strNAM,intPOS+8)
If strNAM = cFIL Then
'*
'* Is "date" in filename numeric?
'*
strDAT = Mid(strFIL.Name,intPOS,8)
If IsNumeric(strDAT) Then
'*
'* Is "date" in filename valid and old enough to delete?
'*
strYMD =
DateSerial(Left(strDAT,4),Mid(strDAT,5,2),Right(strDAT,2))
If IsDate(strYMD) _
And DateDiff("d",strYMD,strNOW) > cOLD Then
strMSG = strMSG & vbCrLf & strFIL.Name & " (" & strYMD &
" = "
strMSG = strMSG & DateDiff("d",strYMD,strNOW) & " days
old)"
objFSO.DeleteFile cFOL & strFIL.Name, True
intFIL = intFIL + 1
End If
End If
End If
Next
'*
'* Destroy Objects
'*
Set objGFI = Nothing
Set objGFO = Nothing
Set objFSO = Nothing
'*
'* Message
'*
MsgBox intFIL & strMSG,vbInformation,cVBS
************************************************************ Tag: Copy file Tag: 193298
Reading cookie vbscript dotnet
Hi Guys,
I am trying to read a cookie set in asp.net using client side vbscript.
Unfortunately i constantly get an error. Can anyone help me get this
right ???
i have tried the following code but it just doesnt work correctly
msgbox(<%=Request.cookies("ClientCode")%>)
error message
Microsoft VBScript runtime error: Object required: 'System'
Any help appreciated
CG Tag: Copy file Tag: 193296
CSV to access in ASP... making my head spin
I've been trying to figure this out on my own for two days and I give
up at this point. I'm creating a web administration interface, and the
user would like to be able to upload a CSV file, and have it post to
the database.
I originally tried using the microsoft text driver, and that worked
great. However, putting the CSV in an array to save the information and
then open the access database didn't work, because the CSV is so huge,
I'm getting out of memory errors when running the array... and of
course the client isn't interested in my ideas of why they should
change hosts.
Anyway, my problem is this. I need to find a way to add the records in
a CSV file on the server (I've already got the uploading working) to
the database, without using an array. I'm stumped
Thanks so much for any advice you can give in advance!
- Ann Tag: Copy file Tag: 193291
Split memberof to multiple arrays
Hi
I have retrieved, from AD, the field memberOf into a RecordSet.
This works without problems.
In AD all my groups is starting with a code.
i.e. A_ , B_ & C_
What I want is, when i loop through my Recordset all records starting
with A_ should to into one array, all starting with B_ in another and
so on...
How do I do that? I'm using vbs script.
Hope for some help.
Henrik Tag: Copy file Tag: 193288
can i remove a certificate via vbs?
i have an encrypting file system certificate that i need to delete/remove
from the certificate store via a script... can this be done somehow? Tag: Copy file Tag: 193286
script to remove machines from domain and add them to a different domain that is not in forest
Hello,
I need to create a script to remove machines from 1 domain and add them
to a different domain that is not in forest.
Any ideas. I guess i will have to make a bat file and put this on each
machine as there is no way I will be able to administer this from the
network.
Any ideas on this one? Can it be done?
Thanks Tag: Copy file Tag: 193284
Bulk OU creation from csv file?
I have no problems creating bulk users but we find ourselves needing to
create bulk OU's according to the same csv list.
Is this possible using an existing excel vba setup or is another
solution better?
Any pointers in the right direction would be appreciated. Tag: Copy file Tag: 193276
Check for Existing Printer Port
I have successfully created a script to create a IP printer port and install
the printer, however it will error out if the printer port is already
created. Does anyone know what I can add to the script to check if the port
exists already and if so then move on to the next step?
Script Example:
â??*****VBS This VBS Script will install multiple TCP/IP Printers on a local
computer
'***** Register prnadmin.dll file on local computer
Set WshShell = Wscript.CreateObject("Wscript.Shell")
WshShell.Run "regsvr32 /s \\X.X.X.X\public\printers\Prnadmin.dll",1,TRUE
'******************* Set environments variables
dim oPort
dim oMaster
dim oDriver
dim oPrinter
'******************** Install the first Printer
'***** Create the TCP port *****
set oPort = CreateObject("Port.Port.1")
set oMaster = CreateObject("PrintMaster.PrintMaster.1")
oPort.ServerName = ""
oPort.PortName = "IP_X.X.X.X"
oPort.PortType = 1
oPort.HostAddress = "X.X.X.X"
oMaster.PortAdd oPort
if Err <> 0 then
msgbox "There was an error creating the port."
end if
'***** Add the printer Driver *****
set oDriver = CreateObject("Driver.Driver.1")
oDriver.ModelName = "HP LaserJet 8000 Series PCL 5e"
oDriver.InfFile = "\\X.X.X.X\Public\Printers\hp8000\hpbf021i.inf"
oMaster.DriverAdd oDriver
'***** Create the Printer *****
set oMaster = CreateObject("PrintMaster.PrintMaster.1")
set oPrinter = CreateObject("Printer.Printer.1")
oPrinter.PrinterName = "HP_8000"
oPrinter.DriverName = "HP LaserJet 8000 Series PCL 5e"
oPrinter.PortName = "IP_X.X.X.X"
oDriver.InfFile = "\\X.X.X.X\Public\Printers\hp8000\hpbf021i.inf"
oMaster.PrinterAdd oPrinter
oPrinter.Shared = false
oMaster.PrinterSet oPrinter
If Err <> 0 then
msgbox "There was an error creating the printer."
end if Tag: Copy file Tag: 193275
netbootGUID - WMI UUID lookup and comparison
Does anyone have any idea how to lookup the netboodGUID of a PC in Active
Directory and compare it to the local WMI UUID? I'm wanting to write a
script that will lookup the PC Name based on the netbootGUID (which should
be the same as the local UUID if it was pre-staged properly) then rename the
local PC. This will save us from having to know what OU it's in as well as
being able to quickly rename if re-imaged.
I have the below WMI UUID piece but can't seem to get the netbootGUID piece.
On Error Resume Next
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
arrComputers = Array("LocalPCName")
For Each strComputer In arrComputers
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM
Win32_ComputerSystemProduct", "WQL", _
wbemFlagReturnImmediately +
wbemFlagForwardOnly)
For Each objItem In colItems
WScript.Echo "UUID: " & objItem.UUID
Next
Next Tag: Copy file Tag: 193272
Delete file in all profiles
hi all, i'm trying to delete a file (extend.dat) from the application data
folder for all users but i cant seem to make this work. i can't use the env
variable, because when i run the script i get an error message. however, if i
put the user profile name it works fine. why wont this script work with the
variable %userprofile%? can somebody help?
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colFileList = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='c:\documents and
settings\%userprofile%\Application Data\Microsoft\Outlook'} Where " _
& "ResultClass = CIM_DataFile")
For Each objFile In colFileList
If InStr(objFile.FileName, "extend") Then
objFile.Delete
End If
Next Tag: Copy file Tag: 193270
Hello!
I'm writing a script, that will copy 3 files.
I need to do this in order (not in the same time).
How can i check, that copy of first file ended?