add input description to AD computer
have excel worksheet with computer names and computer description:
A B
1 wkstation1 Bob Smith
2 wkstation2 Jane Doe
I have sometimes 100's of these to do. Moving the workstations from one OU
to another is not generally the problem. I have to go back and put in the
properties of the workstations computer description, Under the general tab,
the person or cubical with each. I can't seem to find a script to use LDAP to
get the workstation and then put the Persons name in the description. anyone?
Any link to a script? Even one that moves the pc's and adds decsription? Tag: Run visio Macro from VBScript Tag: 187843
Deleting accounts based on computer name
I'm trying to put together a script that will delete any computer
accounts that match a particular naming convention (this is in a
Windows 2003 domain). All the computers that I'm trying to remove are
named test* e.g. testaa, test01, testxyz9 etc.
I've tried the following:
================================================
Dim Container
Dim ContainerName
Dim ComputerToRemove
ContainerName = "MyDomain"
Set Container = GetObject("WinNT://" & ContainerName)
ComputerToRemove = "test*"
Call Container.Delete("Computer", ComputerToRemove)
================================================
But of course it doesn't work because it can't recognise test*.
I don't want to have to call a text file with all the names of the
test* computers as it would be fairly dynamic with new ones being added
all the time.
Can anyone help? Tag: Run visio Macro from VBScript Tag: 187834
Changing a field's datatype in Access via VBScript?
I've got an Access DB that is a back-end to an HTA. I've changed
something in the script so that requires me to change a specific field
in the DB from a TEXT to a MEMO field.
I don't want to destroy the data that's already in the field so how I
can simply update its datatype using a script? Tag: Run visio Macro from VBScript Tag: 187833
Which script is best for Hardening?
I am Dhina, I am new to scripting. I like to learn scripting for all Windows
Server administration work. Which script we can do more Admin work on Windows
Servers (like hardening - changing permission for folders, changing registery
value). Please any one advice me. . If you have any usefull documentation
links about script also let me know.
Thanks in advance.
Dhina Tag: Run visio Macro from VBScript Tag: 187831
EnumNetworkDrives and RemoveNetworkDrive doesn't work on broken network connection / share - any other ways?
If I map a driveletter to a network-share, the share can be enumerated
using EnumNetworkDrives of WScript.Network - and likewise un-mapped
using RemoveNetworkDrive (or re-mapped using MapNetworkDrive).
But if the network share is removed before the mapped driveletter is
un-mapped, the mapping is broken and appears in Windows Explorer as a
driveletter with a red cross - and if you try to access the driveletter
you get the errormessage "The network name cannot be found".
Now if you use EnumNetworkDrives the broken driveletter mapping doesn't
appear as a network drive - and you can't use RemoveNetworkDrive to
remove the connection, this results in the error
"WSHNetwork.RemoveNetworkDrive: This network connection does not
exist". If MapNetworkDrive is attempted on the same driveletter you get
the error "WSHNetwork.MapNetworkDrive: An attemp made to remember a
device that had previously been remembered".
So you're stuck with a broken connection that can't be viewed / removed
/ unmapped using EnumNetworkDrives or RemoveNetworkDrive - only through
Windows Explorer - Rightclick on driveletter - Disconnect can the
connection be removed (or using Net Use <driveletter>: /Delete)
So my question is: Does anyone know of any other way using VBScript,
WMI etc. to remove a broken networkshare?
Any help will be highly appreciated!
Thanks,
Nicolaj Tag: Run visio Macro from VBScript Tag: 187829
Search Word Doc, save file as
I have about 12,000 documents which need to be searched.
I have one main keyword "Booking" to get all the docs, but then I need
to search for "ORDER NO :" and copy the rest of the line, then "DATE :"
and copy whats left on that line into a variable.
So I can get to the point where I can open all files ending in .doc in
folders and subfolders
but the "ORDER NO" and the ":" are far away from each other, and I need
what text is after it until the end of the line. Then I need to store
that information as a string
and then save the filename as something else
If there is a free tool already witten that'd be good, but i dont think
there is, so its vbscript. Can someone help? Tag: Run visio Macro from VBScript Tag: 187827
Renaming remote machine
I have created this script to rename a remote computer, but am having
problems getting it to work.
It always fails with an error code of 5.
strComputerRmt = InputBox("Enter the Remote machine name.", "Remote Machine
Name")
strComputerNew = InputBox("Enter the new machine name.", "New Machine Name")
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"
& strComputerRmt & "\root\CIMV2")
Set colComputers = objWMIService.ExecQuery("SELECT * FROM
Win32_ComputerSystem","WQL",_
wbemFlagReturnImmediately + wbemFlagForwardOnly)
' Rename machine
For Each objComputer in colComputers
Result = objComputer.Rename(strComputerNew)
If Result = 0 Then
WScript.Echo "Successful."
' Reboot machine
Set OpSysSet = GetObject("winmgmts:{(Shutdown)}\\" & strComputerRmt &
"\root\cimv2").ExecQuery("select * from Win32_OperatingSystem where
Primary=true")
For Each OpSys In OpSysSet
OpSys.Reboot()
Next
Else
WScript.Echo "Failed, error " & Result & "."
End If
Next
WScript.Sleep 5000
WScript.Quit
Any advice will be greatly appreciated. Tag: Run visio Macro from VBScript Tag: 187826
Renaming Group Mailbox
Hi,
I need to rename 200 Group Mailboxes (configured as User Accounts)
I have been given an Excel Speadsheet which in one column contains the old
Display Name and the second column containing the New Display Name
So > USAT Indigo HR Resource Mailbox < will become > USAT Intara HR Region
Mailbox <
Does anyone know of a script I can use to rename the Display Name of these
Group Mailboxes parsing an excel spreadsheet containing a list of the new
names? Tag: Run visio Macro from VBScript Tag: 187822
Delete row from excel
Hi
Is possible to remove a specified row from an excel file using Visual
Basic ActiveX Script in a DTS package? I need to remove row 1 which
contains the title of the columns. Thanks in advance.
Joann Tag: Run visio Macro from VBScript Tag: 187818
Unable to run vbscript at system startup
Hello,
I am trying to execute following script at system startup from
SOFTWARE\Microsoft\Windows\CurrentVersion\Run. Now the problem is this script
does not have exit/end if as it is meant for monitoring due to this startup
is waiting for the script to end - which will never happen. If I run this
script from user login everything works fine - but when the user logs out the
script also gets terminated. I tried using batch file from within I called
the vbs file but the batch also gets stuck at the vbs prompt and does not
quit. I know I am missing something here but what?
The script which needs to be run....
----------------
Dim strComputerName
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServices = objWMIService. _
ExecNotificationQuery("Select * from __instancemodificationevent " _
& "within 30 where TargetInstance isa 'Win32_Service'")
i = 0
Do While i = 0
Set objService = colServices.NextEvent
If objService.TargetInstance.State <> _
objService.PreviousInstance.State Then
'Wscript.Echo objService.TargetInstance.Name & " is " &
objService.TargetInstance.State & ". The service previously was " & _
'objService.PreviousInstance.State & "."
'Wscript.Echo objService.TargetInstance.Name
if ucase(objService.TargetInstance.Name)<>"WUAUSERV" then
if ucase(objService.TargetInstance.Name)<>"WINHTTPAUTOPROXYSVC" then
if ucase(objService.TargetInstance.Name)<>"NTMSSVC" then
if ucase(objService.TargetInstance.Name)<>"CREPSRV" then
Set oWshShell = CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
strComputerName = WshNetwork.ComputerName
'Wscript.Echo strComputerName
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "ServiceStatus@adventity.com"
objEmail.To = "ServerAdmin@adventity.com"
objEmail.Subject = "Service Status Changed on " & strComputerName
objEmail.Textbody = objService.TargetInstance.Name & " is " &
objService.TargetInstance.State & ". The service previously was " & _
objService.PreviousInstance.State & "."
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
"advex01.corp.adventity.com"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
End If
End if
End if
End if
End if
Loop
------------------------------- Tag: Run visio Macro from VBScript Tag: 187813
Need to reed data into a script
I have a script that installs a TCP/IP printer port and shared printer.
The script works fine. (See Below)
However I need to install over 100 different printers to my print server.
All the printer speciffic information I need is in an Excell spread sheet,
(Port name, IP address, Driver name, Printer name, Share name, Location,
etc. ).
I want to run this script and have it create all my printer ports and
printer shares.
I know I will have to change the printer speciffic data in the script to
variables, but I am not sure how to have the script read the data form
either Excell or a .CSV file.
I assume I will then have to setup some kind of loop.
I am new to scripting and any help is appreciated.
Thanks
Chris Coates
ccoates@gfs.com
Dim oPort
Dim oMaster
Dim oPrinter
Set oMaster = CreateObject("PrintMaster.PrintMaster.1")
Set oPort = CreateObject("Port.Port.1")
Set oPrinter = CreateObject("Printer.Printer.1")
oPort.ServerName = ""
oPort.PortName = "IP_10.251.1.94"
oPort.PortType = 1
oPort.HostAddress = "10.251.1.94"
oPort.PortNumber = 9100
oPort.SNMP = false
oPort.SNMPDeviceIndex = 1
oPort.CommunityName = "public"
oPort.QueueName = ""
oPort.DoubleSpool = false
oMaster.PortAdd oPort
If Err <> 0 then
end If
oPrinter.ServerName = oPort.ServerName
oPrinter.PrinterName = "NET957"
oPrinter.Shared = True
oPrinter.ShareName = "NET957"
oPrinter.Location = "HR"
oPrinter.Comment = ""
oPrinter.EnableBidi = false
oPrinter.DriverName = "HP LaserJet 8000 Series PCL"
oPrinter.PortName = oPort.PortName
oPrinter.DriverPath = ""
oPrinter.InfFile = "c:\windows\inf\ntprint.inf"
oMaster.PrinterAdd oPrinter
oMaster.PrinterSet oPrinter
If Err <> 0 then
end If Tag: Run visio Macro from VBScript Tag: 187812
loops and tables
This is a multipart message in MIME format.
--=_alternative 0064CE658025711B_=
Content-Type: text/plain; charset="us-ascii"
I'm trying to loop through a text file that contains losts of surnames and
produce a table with all the A surnames in row 1, B surnames in row 2 etc
but I'm getting a bit stuck, I keep ending up with a table with 24 rows
and only the surnames begining with A in all the rows. I realise I need
to add another loop in somewhere to produce the table row and then move
onto the next letter but i can't get my head round it at the moment.
Here's my code:
<table border="1" width="520" align="center">
<%
for i = 65 to 89
do while objTextFile.AtEndOfStream <> True
strTextFileLine = objTextFile.ReadLine
if Left(strTextFileLine, 1) = i then
strSurnameList = strSurnameList &
strTextFileLine & ","
end if
Loop
strMain2 = "<tr><td>" & strSurnameList & "</td></tr>"
response.write strMain2
next
%>
</table>
--=_alternative 0064CE658025711B_=
Content-Type: text/html; charset="us-ascii"
<br><font size=2 face="sans-serif">I'm trying to loop through a text file that contains losts of surnames and produce a table with all the A surnames in row 1, B surnames in row 2 etc but I'm getting a bit stuck, I keep ending up with a table with 24 rows and only the surnames begining with A in all the rows. I realise I need to add another loop in somewhere to produce the table row and then move onto the next letter but i can't get my head round it at the moment.</font>
<br>
<br><font size=2 face="sans-serif">Here's my code:</font>
<br>
<br><font size=2 face="sans-serif"><table border="1" width="520" align="center"></font>
<br><font size=2 face="sans-serif"> <%</font>
<br><font size=2 face="sans-serif"> for i = 65 to 89</font>
<br><font size=2 face="sans-serif"> do while objTextFile.AtEndOfStream <> True</font>
<br><font size=2 face="sans-serif"> strTextFileLine = objTextFile.ReadLine</font>
<br><font size=2 face="sans-serif"> if Left(strTextFileLine, 1) = i then</font>
<br><font size=2 face="sans-serif"> strSurnameList = strSurnameList & strTextFileLine & ","</font>
<br><font size=2 face="sans-serif"> end if</font>
<br><font size=2 face="sans-serif"> Loop</font>
<br><font size=2 face="sans-serif"> strMain2 = "<tr><td>" & strSurnameList & "</td></tr>"</font>
<br><font size=2 face="sans-serif"> response.write strMain2</font>
<br><font size=2 face="sans-serif"> next</font>
<br><font size=2 face="sans-serif"> %></font>
<br><font size=2 face="sans-serif"> </table></font>
--=_alternative 0064CE658025711B_=-- Tag: Run visio Macro from VBScript Tag: 187809
Getting domain information in Windows 2000
Hello there. Hope someone can help me out here!
I've got a script which uses the WMI service to get information about the
domain, using this query....
Select * from Win32_NTDomain where DomainName='MYDOMAIN'
From this information, I use the DcSiteName to automatically configure the
local machine (long story). Anyway, this works fine - I can grab the domain
controller site name under windows XP, but this won't work for Windows 2000.
This is true, according to the scripting pages on Microsoft.com.
So basically, im asking if there is a way I can find out the DC Site Name
under windows 2000, using VBScript?
Thanks in advance,
Simon Tag: Run visio Macro from VBScript Tag: 187806
Modify Script to Enumerate Distribution Lists
I use this script (below) to enumerate security groups a user belongs
to.
How can I enumerate Distribution Lists? They are not included in the
Groups.
I'm on a Server 2003 Active Directory domain, single domain (2003
Native mode).
Script:
dsRoot = "WinNT://Company/jsmith"
set wshShell = Wscript.CreateObject("Wscript.Shell")
set dsObj = GetObject(dsRoot)
For Each Prop In dsobj.groups
wscript.echo prop.name
Next 'Prop
Related question: Where can I find a list of the properties /
collections used with "dsobj" ? Tag: Run visio Macro from VBScript Tag: 187804
delete dns zone
I'm trying to find a script to delete a dns zone, but have not had any
success.
I've tried
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dns/dns/dns_wmi_provider_samples_managing_dns_zones.asp
but this example seems over complicated.
And the examples in the MS script repository don't mention deleting zones
http://www.microsoft.com/technet/scriptcenter/scripts/network/dns/default.mspx
Can anyone help? I think i need to use the delete_ method but am not sure
how to implement it. Tag: Run visio Macro from VBScript Tag: 187801
How to change who can add computer to domain using vbscript
Hi,
I found the below vbscript from
http://computerperformance.co.uk/vbscript/vbscript_computer_spreadsheet.htm
which allows me to add computer accounts into Active Directory from a
spreadsheet. That part works great. What I'd like to know is how to ammend
this script so it allows a specified Group to join these computers to the
domain.
Any help would be much appreciated.
' ComputerSpreadsheetADV.vbs
' Sample VBScript to Create Computer Accounts from a Spreadsheet
' Author Guy Thomas http://computerperformance.co.uk/
' Version 1.4 - May 2005
' ------------------------------------------------------'
Option Explicit
Dim strComputer, strOU, strSheet, intRow
Dim objRootLDAP, objContainer, objComputer, objShell
Dim objExcel, objSpread
' -------------------------------------------------------------'
' Important change OU= and strSheet to reflect your domain
' -------------------------------------------------------------'
strOU = "OU=newComputers ," ' Note the comma
strSheet = "C:\newComputers.xls"
' Bind to Active Directory, Computers container.
Set objRootLDAP = GetObject("LDAP://rootDSE")
Set objContainer = GetObject("LDAP://" & strOU & _
objRootLDAP.Get("defaultNamingContext"))
' Open the Excel spreadsheet
Set objExcel = CreateObject("Excel.Application")
Set objSpread = objExcel.Workbooks.Open(strSheet)
intRow = 2 'Row 1 often contains headings
' Here is the loop to cycle through the cells
Do Until objExcel.Cells(intRow,1).Value = ""
strComputer = objExcel.Cells(intRow, 1).Value
' Build the actual computer and add error-correcting code
On Error Resume next
Set objComputer = objContainer.Create("Computer", _
"cn=" & strComputer)
objComputer.Put "sAMAccountName", strComputer & "$"
objComputer.Put "userAccountControl", 4096
objComputer.SetInfo
If err.number <> vbEmpty Then
Wscript.Echo "Error " & err.number
End If
intRow = intRow + 1
Loop
objExcel.Quit
' Optional section to launch Active Directory Uses and Computers
Set objShell=CreateObject("WScript.Shell")
objShell.Run "%systemroot%\system32\dsa.msc"
WScript.Quit
' End of Sample ComputerSpreadsheetADV VBScript.
--
Please reply to news group only. Thank you. Tag: Run visio Macro from VBScript Tag: 187800
Retrive Bios Events
Hi,
Is there a way of retriving the bios logs from a computer with a
script. We wish to run a computer startup script on win2K based computers
that would be able to look at the bios log to see if the case had been
opened at some time. If so we will then need to take certain action. If this
is at all possible could somebody be kind and show me a sample of the could
that I would need to run.
Thanks
Kenneth Tag: Run visio Macro from VBScript Tag: 187795
Trying to write a program that would collect images received as email attachments
Hello,
Desperately, I am trying to find a way to write a program that would collect
images received as email attachments and save them to a specific folder with
a changed filename into whatever was the subject of that email. There would
be one image per email.
Here is how I think it would work:
(1) Receive an image in email attachment.
(2) Retrieve the image from that attachment.
(3) Change the name of the image file into what was written in the Subject
of that email.
(4) Save the renamed image file into a specific folder.
(4) Delete the received email
I have done some research and found that the application would need to
interact with MAPI. Could you please tell me if you have seen any similar
programs written in VBScript somewhere on the internet, or could you give me
some very specific advice or directions.
P.S. I have my own Windows 2003 server, and can install anything on my
server if I need to.
Thank you,
Vanessa Lee Tag: Run visio Macro from VBScript Tag: 187793
Automated way to clear custom event log
Hi,
Anyone know how to automate clearing of custom event logs?
I've been able to clear the default logs with an modified script repository
example:
'clears the event logs.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate,(Backup,Security)}!\\" & strComputer &
"\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery ("Select * from
Win32_NTEventLogFile where LogFileName='Application'")
For Each objLogfile in colLogFiles
objLogFile.ClearEventLog()
Next
Wscript.Echo "Application Log Cleared"
Set colLogFiles = objWMIService.ExecQuery ("Select * from
Win32_NTEventLogFile where LogFileName='Security'")
For Each objLogfile in colLogFiles
objLogFile.ClearEventLog()
Next
Wscript.Echo "Security Log Cleared"
Set colLogFiles = objWMIService.ExecQuery ("Select * from
Win32_NTEventLogFile where LogFileName='System'")
For Each objLogfile in colLogFiles
objLogFile.ClearEventLog()
Next
Wscript.Echo "System Log Cleared"
Set colLogFiles = objWMIService.ExecQuery ("Select * from
Win32_NTEventLogFile where LogFileName='Scripts'")
For Each objLogfile in colLogFiles
objLogFile.ClearEventLog()
Next
Wscript.Echo "Scripts Log Cleared"
_________________________________________________________
But the custom log "Scripts" (also created from an example in the Script
Repository) doesn't get cleared:
Any idea how I can make this work? Tag: Run visio Macro from VBScript Tag: 187792
Changing Wav Files
Hi,
I have a telephone system that records all conversations as a standard
WAV file. This Wav files are good for training purposes but no good for
legal use.
To make them usable in a court of law the recordings must be in an
uneditable format. could this be done with VB Script?
Regards
Ian Tag: Run visio Macro from VBScript Tag: 187789
reggular expressions
I would like to replace a "-" in a string but only when it is surounded by
either a letter or a number. for example
"A-4" or "3-V" but not "S-D" or "4-4"
Thanks Tag: Run visio Macro from VBScript Tag: 187765
How to repeatedly check for a condition before continuing?
Hello.
In a batch file I can repeatedly check for a conditon before
continuing:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:Repeat
IF EXIST c:\temp\finished.log GOTO Continue
ECHO "Not finished yet..."
Sleep 60
GOTO Repeat
:Continue
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Can anyone provide a simple, basic code snippet that will allow me to
do the equivalent in VBScript? More specifically, I'm trying to check
if a file has closed before continuing - and I need this checking to
repeat itself in continuous loop.
Thanks! Tag: Run visio Macro from VBScript Tag: 187749
Writing to a file and then reading the file contents
How does one write to a file and then read the file contents with
out closing the file inbetween (if it is possible)? I'm tinkering
with the serial com port to see if the input buffer can be read
after writing to the output buffer. I can write bytes and such to
the comport by treating it like a file (substitute "COM1:" for
the "test.txt"), so the next question is can I get the contents
of the input buffer by reading the open file before closing it.
Can the below code be fixed such that it can read the contents of
the test.txt file after writing to it with out closing the file
first?
===================
Set fs=CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("test.txt",True)
a.write "this is a test"
Wscript.Sleep 1000
'get test.txt file contents here
'wscript.echo test.txt file contents here
a.Close() Tag: Run visio Macro from VBScript Tag: 187747
scripting IE to download ftp file
I have run into problem with batch file execution of FTP. Every now and then
the
ls something*.txt
gets hung. Consequently I wonder if I have better chance of IE as control
from vbscript
How do I find if a file of certain pattern exists from IE control? There
may be more than one that fit the pattern, or maybe nothing. If present, I
like to get the file name.
However, I don't have a clue in this, as I am not dealing with html but FTP
protocol from IE. I know how to make IE navigate to the desired directory
but I need help to list content of the desired ftp directory ain terms of
names, sizes, date time created if possible
Thank you very much for your time. Tag: Run visio Macro from VBScript Tag: 187742
Script to compair two files Help?
Hi
I am trying to write a Windows 2003 Server logon script to compair two files
("file1" and "file2"), if the files are different (say in size) then I need
to replace "file2" with "file1".
The algorithm is:
if file1 "is different" from file2 then
Overwrite file2 with file1 (a simple "copy file1 file2" will
suffice)
Is there a simple way to do it using a script (VBScript) so I can run it
when the user logs on?
My VBScript knowledge is NIL, I have no problems compiling a Visual Basic
program to perform the task, but would like to see how it can be done using
a script.
Any help would be appreaciated.
Regards
Gitendra Tag: Run visio Macro from VBScript Tag: 187740
Unloading and reloading Powerpoint Help
Wondering if VBS would unload and then launch a .ppt and start the show on a
remote computer? It's in the basement and viewed on remote tv's throughout
building.
MS Powerpoint 2003 w/(sp3) if it makes a difference.
Thanks
Nate Tag: Run visio Macro from VBScript Tag: 187730
Rename file extension
Hello all,
I need help to rename a file extension using the VBScript. I am
relatively new to this and have put this much together so far:
strComputer = "."
Set objWMIService = GetObject _
("winmgmts:" & "!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("Select * from Cim_Datafile where Name = " _
& "'D:\\test\\test.txt'")
For Each objFile in colFiles
errResult = objFile.Rename("D:\test\test." &
FormatdateTime(Now(),"ddhh")")
Wscript.Echo errResult
Next
I need the file extension to be in the format test.ddhh complete with
the two digit day and hour. Any help is appreciated. Thanks!
JV Tag: Run visio Macro from VBScript Tag: 187728
Need help with another commandline argument
I want to be able to close a running application like notepad.exe
using vbscript (the simplest way I've found so far) using the
test.bat batch file. The below test.vbs file is what I've come up
with so far for testing. Test.vbs gets the notepad.exe as an
argument, but i haven't found a way to get it to be successful in
the script to close a running notepad.exe. If I substitute
notepad.exe for the xxx down in the script, then the test.vbs
will close the running notepad.exe. Any suggestions on getting it
to work? Thanks!
========test.vbs=======
Set objArgs = WScript.Arguments
if objargs.count <> 1 then
wscript.echo "expected a command-line argument"
wscript.quit
end if
xxx = objArgs(0)
wscript.echo "xxx"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& "." & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & "'xxx'" )
For Each objProcess in colProcess
objProcess.Terminate()
next
wscript.quit
=======test.bat=========.
@echo off
test.vbs notepad.exe Tag: Run visio Macro from VBScript Tag: 187726
Frames and Window Resizing
I have an HTML page which has two frames on it - Header and Body are the
frame names.
Is it possible to resize the window containing the html frames when the ASP
page being displayed in the Body frame is loaded and reloaded?
I guess what I am asking is how do I reference to the window containing the
HTML page from one of the pages being displayed in one of the frames.
If this can be done, can anyone supply some code segments for me to achieve
this?
Paul Smith Tag: Run visio Macro from VBScript Tag: 187723
Incidental Factiod: pertaining to ConnectObject/GetRef in Class Code
A year ago, I posted a question/complaint about the apparent lack
of support for "ConnectObject" or "GetRef" in class code.
I had been attempting to instantiate a class from within an actX
object and then connect with events fired by that class (not the actX
object itself). This works well enough in "main line" vbs code, but
not (as best I can tell) in class code.
I recently tried to do the same thing, and failed again (groan!).
I even searched this ng, and found my previous disgruntled posting.
Then I remembered something, i.e., that you can refer to the current
instance of class code as "Me", within the class. It occurred to me
that "Me" might be equivalent (or even identical to) "GetRef". A
"GetRef" gives you an object whose default member calls the routine
which you specify. Likewise, if "Me" is a reference to the current
instance, then if one refers to "Me" in code, then one will also get
a call to the default member of "Me".
Cut to the chase. This did work the way I expected it would, and
I was then able to (in effect) do a "GetRef" in class code.
Here is an example (although referring to a proprietary actX (oSCO)
which is setting a "CBT Hook" to detect window openings). When it
detects a window opening, it will call me back with the information:
--- <snip> ---
' set an "ole callback" for the hookproc...
Set oSCO.SetCallBack = Me ' reference to the default member of THIS
instance
...
' this is "my hookproc" (called from real hookproc embedded in sco)...
Public Default Function myHookWndFunc(uMsg, wParam, lParam)
...
' and this is the "real" hookproc located in the actX (oSCO) object.
' it will intercept the hookproc calls and refer them back to script.
Public Function GenericHookProc(ByVal ncode As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Dim oCallBack As Object
Set oCallBack = m_oCallBack ' the ole callback
GenericHookProc = oCallBack(CVar(ncode), CVar(wParam), CVar(lParam))
End Function
--- </snip> ---
Note: there is no documentation about "Me", other than another
obscure ng posting by mikHar, way back in 2000. As an "undocumented-
and-unsupported" feature, one might justifiably be cautious about using
this, because in the past microsoft has abruptly "corrected" (i.e.,
removed) other undocumented-and-unsupported features. The "good news"
is that it will probably take an "act of congress" for microsoft to ever
do any further maintenance or support for vbs, so it is extremely
unlikely that "Me" will ever go away anytime in the foreseeable future.
cheers, jw Tag: Run visio Macro from VBScript Tag: 187721
DHTML question
I am wrting Access DAP. On the page I need to create a new record based on a
current rcord so I am developing copy operation. I have lots of HTML
controls on the page. When I click new, it should keep all the data in the
controls as it is except a few.
How can I achieve this using DHTML
thanks Tag: Run visio Macro from VBScript Tag: 187718
recursion to display records
I am learning how to get records from a database. I was able to accomplish
but I know there are 6 records and I only display 1. I know what to do but
do not know how in vbscript. i think the script needs a for loop to display
records until completed but was unable to get working.
----------------CODE BELOW--------------------
Const DB_CONNECT_STRING= "provider=SQLOLEDB.1;data
source=localhost;database=PSMT;uid=mydbUser;pwd=???????"
Set MyDB = CreateObject("ADODB.Connection")
MyDB.Open(DB_CONNECT_STRING)
SQLString = "select SystemName, Win32_ComputerSystem_TotalPhysicalMemory,
OSInstallDate, LAST_UPDATED from SystemInfo where
(Win32_ComputerSystem_TotalPhysicalMemory) < 120746688"
set MemQuery = MyDB.Execute(SQLString)
If Not MemQuery.EOF then
SystemName = MemQuery.Fields("SystemName")
PhysicalMem = MemQuery.Fields("Win32_ComputerSystem_TotalPhysicalMemory")
OSINstallDate = MemQuery.Fields("OSInstallDate")
LastUpdated = MemQuery.Fields("LAST_UPDATED")
WScript.Echo(SystemName & vbtab & PhysicalMem & vbtab & OSINstallDate &
vbtab & LastUpdated)
End if
MyDB.Close Tag: Run visio Macro from VBScript Tag: 187717
Setup.exe Silent intall w/.ISS not working
I am a novice in vbscript. Nonetheless I have an application on all
computers I need to be installed with a script on all computers. The
following works:
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run = "D:\TL06\setup.exe -s -f1D:\TL06\setupNEW.iss", 1 True
(-s is to silent install and the -f1 indicates the file location for
the response file needed in the silent install.)
The problem is the folder has a space, so with the change in folder
name the following does NOT work:
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run = "D:\TL 06\setup.exe -s -f1D:\TL 06\setupNEW.iss", 1 True
I tried adding extra quotes before and after but it does not work. I
tried declaring variables for the files but that does not work either.
I am missing something? or is it not possible to add arguments to a
file who's path has a space in it? The error that comes up is that The
system cannot find the specified file.
Please help anyone.
R D J Tag: Run visio Macro from VBScript Tag: 187715
Verify is a service can be stopped
I am trying to automatically start a service that is failing. Before I
can start the service, I need to verify that the service can be
stopped. I have the following code that tells me the state of all
services running that can be stopped. What I need to do is only check
if a particular service can be stopped, then if it can, kick off the
stop and restart of the service. I can stop and start, I just need to
fix the following code to check for a particular service.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set colServices = objWMIService.ExecQuery _
("Select * from Win32_Service Where AcceptStop = True")
For Each objService in colServices
Wscript.Echo objService.DisplayName
Next
Thanks Tag: Run visio Macro from VBScript Tag: 187714
XCOPY in VBscript
Anyone have an xcopy-like written in vbscript? Not a script that calls DOS
xcopy, but actually have a script that performs like xcopy? Thanks. Tag: Run visio Macro from VBScript Tag: 187712
SQL stored procedures: display both output and recordset
I'd like to retrieve both a recordset and the output parameter from a
SQL stored procedure. I can do one or the other but not both. The
stored procedure itself is a simple query with an input and output
parameter.
The parameters:
oCmd.Parameters.Append oCmd.CreateParameter("@ID", adVarChar,
adParamInput, 15 , "9123456")
oCmd.Parameters.Append oCmd.CreateParameter("@Return_Code", adVarChar,
adParamOutput, 50, "")
If I use:
oCmd.Execute
I can read the output parameter using:
wscript.echo oCmd.Parameters("@Return_Code").Value
or
wscript.echo oCmd.Parameters(1).Value
If I use:
set rs = oCmd.Execute
I can loop through the recordset and correctly display the data. I
can't display the output parameter.
I tried to use:
Set rs = rs.NextRecordset
wscript.echo oCmd.Parameters("@Return_Code").Value
wscript.echo oCmd.Parameters(1).Value
That doesn't work.
I then tried to close the recordset:
Set rs = rs.NextRecordset
rs.close
wscript.echo oCmd.Parameters("@Return_Code").Value
wscript.echo oCmd.Parameters(1).Value
To no avail.
I did set nocount in the stored procedure. I can get either the
output data or the recordset data so the stored procedure is returning
the data to my script.
At this point all I want to return is "Hello world" from the stored
procedure.
I'm new to the world of running stored procedures from vbscript,
though I have been running queries for a long time. Any ideas?
Swyck Tag: Run visio Macro from VBScript Tag: 187711
RePost: Problem handling Date Comparison in VBScript
I had posted the following earlier. However, the help I got did not resolve
the problem. I appreciate any advise/help to resolve the following. Thanks in
advance.
I have a html form with few fields. The fields are claim number, month, day
and year. Actually the month, day and year together
forms the claim date. There is also a variable named QuarterEndDate which
contains the quarter end date value which happens to be 12/31/05.
Now, before submitting the form, I need to do some validation check. The
first validation (which I cannot get it to work) is that
the claim date should be less than the Quarter End Date. The second
validation is that there has to be a claim number regardless
(which works by itself but does not when the first validation comes up).
I would like to know what is the problem with the first validation in the
code below?
Function frm_Details_OnSubmit
validation = TURE
Function frm_Details_OnSubmit
validation = TURE
If DateValue((frm_Details.ExpMonth_0.value) & "/" &
(frm_Details.ExpDay_0.value) &
"/" & (frm_Details.ExpYear_0.value)) > DateValue(QuarterEndDate) Then
Alert("You must enter claim date within the End Quarter Date")
document.frm_Details.ExpMonth_0.focus
frm_Details_OnSubmit =False
ElseIf (frm_Details.ClaimNo_0.value = "") Then
Alert("You must enter a value for Claim number.")
frm_Details.ClaimNo_0.focus
frm_Details_OnSubmit =False
Else
frm_Details_OnSubmit = True
End If
End Function Tag: Run visio Macro from VBScript Tag: 187710
ocx permission denied
I've updated an ocx (using VB6) that is currently being used in an asp
3.0 application. I created an internet package(using VB6) containing
the ocx and corresponding dll's. I then placed both the CAB and
support files on my webserver. I also registered the dll's on the web
server. I updated my asp script to reflect the new object's classid
and version#. When I call the asp page I receive an alert "permission
denied" when it calls the ocx. If anyone could provide some feedback
on how to overcome this issue I greatly appreciate it.
I also created a very simple ocx on my local machine complied and saved
to my system32 dir. I tried using it on my local machine in an asp
page; when it call the object's method on this com thru a
windowonload event I received a prompt "object doesn't support this
property or method"?
Thanks in advance! Tag: Run visio Macro from VBScript Tag: 187708
Determine if a script was run from an HTA
Is there a way to determine if an external vbscript was called from an
HTA? Tag: Run visio Macro from VBScript Tag: 187707
Input box
Hi all
I would like to create a service dependance with the command:
oShell.Run "sc config " & ServiceOVO & " depend= " & chr(34) &
ServiceApplicatif & chr(34), 1,True
My problem is that ServiceApplicatif is badly interpreted when it has
spaces in the name.
ServiceApplicatif is entered with the following line:
ServiceApplicatif = InputBox("Enter the name of service Applicatif
(Service name) " , "Service")
How can I make sure that spaces in the inputbox are converted as spaces
in the variable ?
or how can I modify the string to insert chr(32) ?
to have a correct service installation
Thanks and have a good day
Bruno Tag: Run visio Macro from VBScript Tag: 187704
List of the 20 most recent subfolders in a folder
Hi,
I'm looking for a script to read through the "subfolders" in a folder and
make a list of the 20 most recent folders.
Actually the "subfolders" are really zip files (pretending to be
subfolders).
TIA
Alex Tag: Run visio Macro from VBScript Tag: 187701
changing values in registry subkeys
Hi All
I'm looking to search through all subkeys of a specific registry key
for a given value.
The code below works fine for echoing out the names of the subkeys.....
----------------------------------------------------------------------------------------------------------------------
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set StdOut = WScript.StdOut
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet\Services"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each subkey In arrSubKeys
StdOut.WriteLine subkey
Next
----------------------------------------------------------------------------------------------------------------------
...... but how do I check each subkey for a specific value? Tag: Run visio Macro from VBScript Tag: 187697
Folder last accessed / modified
Hi Guys, doing a bit of network maintenance at the moment and I'd like to
archive some folders that havn't been accessed/modified since 2003.
I would like to generate a script to search a directory and output the names
of all the folders that have not been accessed since 2003 to a txt file.
The text document should also contain when the folders were last accessed.
The server uses NTFS. Tag: Run visio Macro from VBScript Tag: 187693
formatnumber
i try to add numbers from text type number data.
ABC = formatnumber("12") + formatnumber("50")
but the result is 1250, not 62
i change "+" to "*", then it can be multiplied.
how can i do additon?
Thanks a lot.
tony Tag: Run visio Macro from VBScript Tag: 187683
Select a Cell Range in Excel using numbers
Hi Every One,
I'm just trying to write a VBscript to edit an Excel file. Just want t
select a range of cells *using column and row numbers*. Here is m
sample code :
Dim objUser, strExcelPath, objExcel, objSheet, k, objGroup
strExcelPath = "C:\UserGroup.xls"
Dim objXL
Set objExcel = WScript.CreateObject("Excel.Application")
objExcel.Workbooks.Add
objExcel.ActiveWorkbook.Worksheets(2).Select
objExcel.ActiveWindow.SelectedSheets.Delete
objExcel.ActiveWorkbook.Worksheets(2).Select
objExcel.ActiveWindow.SelectedSheets.Delete
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
objSheet.Cells(1, 1).Value = "User Common Name"
objSheet.Cells(2, 1).Value = "sAMAccountName"
objSheet.Cells(3, 1).Value = "Display Name"
objSheet.Cells(4, 1).Value = "Distinguished Name"
objSheet.Cells(5, 1).Value = "Groups"
objExcel.ActiveWorkbook.SaveAs strExcelPath
objSheet.Range(cells(1,1),cells(2,3)).Select *<-- this doesn't work*
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
Set objUser = Nothing
Set objGroup = Nothing
Set objSheet = Nothing
Set objExcel = Nothing
Can anyone help me, pleaaaase
Cheers,
The K
-
The K
-----------------------------------------------------------------------
Posted via http://www.codecomments.co
----------------------------------------------------------------------- Tag: Run visio Macro from VBScript Tag: 187682
Importing Certificates into IE
Is there a way to import Certificates into Internet Explorer via VBScript? I
thought I found something on the internet that showed how to do this the
other night but now I can't seem to find it.
I would like to integrate this into my logon script.
Thanks
Talyn Tag: Run visio Macro from VBScript Tag: 187677
Object doesne't support this priority or metode Email 800a01B6
Can someone help me, I am new on this
Erik Gjertsen
' UserSpreadsheet .vbs
' Sample VBScript to create User accounts from a spreadsheet
' Author Guy Thomas http://computerperformance.co.uk/
' Version 4.6 - June 2005
' ------------------------------------------------------'
Option Explicit
Dim objRootLDAP, objContainer, objUser, objShell
Dim objExcel, objSpread, intRow
Dim strUser, strOU, strSheet
Dim strCN, strSam, strFirst, strLast, strPWD, strEmail
' -------------------------------------------------------------'
' Important change OU= and strSheet to reflect your domain
' -------------------------------------------------------------'
strOU = "OU=test ," ' Note the comma
strSheet = "D:\Scripts\NewUser44.xls"
' Bind to Active Directory, Users container.
Set objRootLDAP = GetObject("LDAP://rootDSE")
Set objContainer = GetObject("LDAP://" & strOU & _
objRootLDAP.Get("defaultNamingContext"))
' Open the Excel spreadsheet
Set objExcel = CreateObject("Excel.Application")
Set objSpread = objExcel.Workbooks.Open(strSheet)
intRow = 3 'Row 1 often contains headings
' Here is the 'DO...Loop' that cycles through the cells
' Note intRow, x must correspond to the column in strSheet
Do Until objExcel.Cells(intRow,1).Value = ""
strSam = Trim(objExcel.Cells(intRow, 1).Value)
strCN = Trim(objExcel.Cells(intRow, 2).Value)
strFirst = Trim(objExcel.Cells(intRow, 3).Value)
strLast = Trim(objExcel.Cells(intRow, 4).Value)
strPWD = Trim(objExcel.Cells(intRow, 5).Value)
strEmail = Trim(objExcel.Cells(intRow, 6).Value)
' Build the actual User from data in strSheet.
Set objUser = objContainer.Create("User", "cn=" & strCN)
objUser.sAMAccountName = strSam
objUser.givenName = strFirst
objUser.sn = strLast
objUser.Email = strEmail...............................Problem
objUser.SetInfo
' Separate section to enable account with its password
objUser.userAccountControl = 512
objUser.pwdLastSet = 0
objUser.SetPassword strPWD
objUser.SetInfo
intRow = intRow + 1
Loop
objExcel.Quit
WScript.Quit
' End of Sample UserSpreadsheet VBScript. Tag: Run visio Macro from VBScript Tag: 187675
Why does one logon script work and the other not work
I am trying to write a logon script for users logging into Windows 2003
terminal server. I need to determine what usergroups they belong to. I
downloaded two scripts and the first one only works for users in the
administrator group. The second script works for all users. I'm thinking it
is an Active Directory security setting. For my own education, how can I
make the first script work for all users.
Thanks for your help
' Only works for administrators
Set objADSysInfo = CreateObject("ADSystemInfo")
strUser = objADSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)
For Each strGroup in objUser.memberOf
Set objGroup = GetObject("LDAP://" & strGroup)
Wscript.Echo objGroup.CN
Next
' works for everybody
Set WshShell = WScript.CreateObject("WScript.Shell")
strDomain = WshShell.ExpandEnvironmentStrings("%USERDOMAIN%")
strUserName = WshShell.ExpandEnvironmentStrings("%USERNAME%")
Set objUser = GetObject("WinNT://"& strDomain &"/"& strUserName, user)
For Each objGroup In objUser.Groups
If strGroupList = "" Then
strGroupList = objGroup.Name
Else
strGroupList = strGroupList & ", " & objGroup.Name
End If
Next
WScript.Echo strGroupList Tag: Run visio Macro from VBScript Tag: 187672
Permission Denied and Path Not Found errors
I'm stuck in a loop with a remote script:
If I use the following line to connect to a remote system from a server, I
get a "Permission Denied" error:
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputers(y) & "\root\cimv2")
I can launch this script on one of my remote systems to connect to another
remote system (rather than launching it from the server), and the entire
script runs fine.
So, I use the "Locator" version, which connects successfully:
Set objSWbemLocator = CreateObject("WbemScripting.sWbemLocator")
Set objWMIService = objSWbemLocator.ConnectServer(strComputer, _
"\root\CIMV2", _
"strUser", _
"strPW", _
"MS_409", _
"NTLMDomain:" + strComputer)
However, when I use this "Locator" version, the following line in my script
fails with a "path not found" error:
Set objTargetFolder = objFSO.GetFolder("\\" & strComputer & _
"\c$\" & strTargetFolder)
I believe this is because "C$" is not accessible. Is there another way to
access the C drive remotely?
Thanks,
--
Bill Baker
PS: In case anyone notices, I had posted this question in the
scripting.remote area, but no one seems to be home there. Tag: Run visio Macro from VBScript Tag: 187668
Exchange 2003 scripts
Does anyone have good site with scripts for Exchange 2003. What I need is
the script that will let me select number of user accounts and tell me
number of emails in the each mailbox, may be the time email arrived to the
mailbox etc....
Thanks a lot. Tag: Run visio Macro from VBScript Tag: 187667
Hi,
How can I run a Macro in Visio 2003 from VBScrip, which opens a new instance
of Visio 2003. I am trying to run the Macro from VBScript.