Using Menus in WSH Scripting?
Hi,
I'm writing a small vb script that will allow certain users to interact with
a few elements of our AD. I've got the AD interaction working, however one
of the features I'd like if for people to be able to select some options
from a drop down menu. Is this possible? I've read certain articles that say
vbscript/wsh doesn't support drop menus, but these were a few years old. Is
it still true? If so, does anyone have any recommendations for a way around
it?
Cheers
Ben Tag: Printing word-doc to pdf-file Tag: 188959
Checking for folder existence using widlcards
In my office we have a system for allocating work that involves
creating a subfolder based on a reference number.
The reference number forms a unique part in the format T#nnnnn at the
start of the folder name, the rest of the folder name is freeformat
text with a description of the task (eg "T#12345 - Set up vbscript"). I
am trying to write a script that will check if a folder exists for a
given reference number, if it does it opens it up in explorer and if it
doesn't, it creates the folder and asks the user to input a description
which is then used in the folder name.
The only way I've been able to do it is to get a list of all the
subfolders and loop through each one checking the first 7 characters,
however this is taking quite a while as we have thousands of these
things.
I have split the folders into ranges of 1000 but it still takes too
long to find. What i'd really like to do is to only return folders with
a name of T#nnnn* when I do the getfolder. I can't seem to find any
other method on the filesystemobject that will do this. Wuld be very
grateful if someone could help me. Ta. Tag: Printing word-doc to pdf-file Tag: 188958
How to check word document?
Dear all.
I would like to create the vbscript which will try to open wor
document and give me the information if it is not possible, if the do
file is unreadable.
Somebode can help me?
Thank you in advance
Thoma
-
SMIEJ7
-----------------------------------------------------------------------
Posted via http://www.codecomments.co
----------------------------------------------------------------------- Tag: Printing word-doc to pdf-file Tag: 188957
retrieving share permissions in NT (Urgent)
hi all,
I need some help in writing a script which can retrieve share
permissions of a folder. This will run on NT machine so i cannot use
WMI service. AdsSecurity is not helpful in dealing with share
permissions.
Can anyone give some other idea of doing this.
Any Script on this can do more good to me Tag: Printing word-doc to pdf-file Tag: 188955
Local Account
I want to use a script to modify a local account on a computer.
Now, the local account is configed, but the property of the local account is
that "user can't modify the password" and "Password never expires is
disabled". Now I want the property of the local account is that "user can
modify the password " and "Password never expires is now enabled".
Hope some one would help me !
Thanks a lot ! Tag: Printing word-doc to pdf-file Tag: 188953
Syntax for SQL SELECT Statement with ReadOnly
Someone got into my student file and destroyed one of the feields in it.
I need to change the SELECT SQL statement but just cannot find the correct
syntax.
This is what I have now:
UnivSQL="SELECT * FROM UNVRSTY WHERE NAME = '" & PgName & "' and PASSWRD =
'" & PgPass & "', acReadOnly"
rsUnivs.Open UnivSQL, Cnnct, 3, 3
I was informed to use ReadOnly, but I cannot find where to insert the
property.
Thanks in Advance
Granny Tag: Printing word-doc to pdf-file Tag: 188941
Retrieving and Converting Octet String in VBS
Hi All,
How can one convert an Octet String attribute to decimal using VbScript?
The particular attribute I'm looking at is msExchSmtpRelayIPList - an
attribute of the SMTP virtual server object in Exchange.
I've gone through the ArrayConvert kba
(http://support.microsoft.com/?kbid=250344), have the Ads.dll from the kba
installed/registered, but had little success with this.
Perhaps there's another way or function someone's using to do this... ?
Thanks!
--
Bharat Suneja
MCSE, MCT
www.zenprise.com
blog: www.suneja.com/blog
----------------------------------------- Tag: Printing word-doc to pdf-file Tag: 188940
Word- boilerplate text merging?
I searched this group, but still can't find relevant answers.
Is there an easy way to build a Word document based on a template where
I can pick which boilerplate text or images to insert in the given
fields/spots? I found an add-in to Word from ActiveDocs that is very
nice but very pricey. It also seems to do more than I need. I thought
that maybe a VBA script could handle the steps. All I need is a
function that pops a dialog box where I can on the fly select the right
bits of text from a database or maybe txt files on the hard drive. Is
there an existing script that will do it, or alternatively a less
expensive program than ActiveDocs?
TIA Tag: Printing word-doc to pdf-file Tag: 188934
Search AD using a list of computer names and get OU location
I need to write a vbscript that will search AD using a list of computer
names and give me the OU location for each computer. I have been having
a hard time trying to figure this out. Someone please help. Thanks in
advance Tag: Printing word-doc to pdf-file Tag: 188927
Countdown Script!
I am looking for some help with a script to bascically count down time. After
about 27 hours I want the script to notify the user with a message to remind
them to log off. It will be a logon script which initiates every time a user
logs in. Can anyone help with this. I don't want to use wscript.sleep because
it is just to crude. Is vbs to weak? Tag: Printing word-doc to pdf-file Tag: 188921
reading file names, processing them, renaming them
Hi,
I am wondering if anybody can help me with vbscript code for the
following operations:
The script should read all the file names from a folder one by one
(lets say the folder name is c:\test).
For each file name read a process has to occur (I have the script for
the process I need).
After reading the file the file needs to be moved to an "OLD" folder
(c:\test\old).
Then move to the next file.... etc.
Thank you,
Carly Tag: Printing word-doc to pdf-file Tag: 188917
How to capture PRINT output in ADO?
I'm writing a VBScript to connect to a SQL-Server and execute queries that
contain PRINT statements. I cwant to capture that output... how can I do it?
TIA - e Tag: Printing word-doc to pdf-file Tag: 188915
Class or WSC?
I'm working primarily in vbscript with wsh.
I have wsf files that do various tasks for me. The wsf files use
fn/subs stored in separate .vbs files by using <script> in the wsf
file. The code is growing and I'm finding the need from my .vbs files
to call other fns/subs. Up to this point I've used a combination of
ExcecuteGlobal, wshell.run and wsf files to pass/return parameters and
call routines. I'm wondering now if I should put all my functions/sub
into a class or a wsc and just reference this one file in all my wsf
programs. The class/wsc would have some disparate functions, but it
seems to suit the purpose. Should I? Which one, class or wsc? Why?
Are there other options to solve my problems?
If you too have question about passing values I highly recommend
looking at Torgeir Bakken's post:
http://groups.google.com/group/microsoft.public.scripting.wsh/msg/9ebc58d1b5f5c51f
He mentions wsc, but not a simpler class. Why?
One of the drivers of my problems is my need to create a cental place
for storing constants. I reference many network paths and I want a
central place to be able to easily make changes. My initial solution
was a text file to hold the constants and a function that uses ado to
look up the values of named constants. But my architecture of calling
vbs files from wsf files didn't work well since now my vbs files needed
to call another vbs function that looked up the constants. You can't
call wsf files from wsf files.
I've looked at wsc and type libaries, but is this overkill for my need
to grab some constants?
Thanks in advance! Tag: Printing word-doc to pdf-file Tag: 188914
remove first horizontal tab on each line
Hi,
I am using VBScript RegEx on a file to filter it and I wondered if it
was possible to remove only the first horizontal tab on each line?
Aidy Tag: Printing word-doc to pdf-file Tag: 188906
Does WMI have to be installed on Remote Computer?
Hello. I'm new to WMI, learning as I go. I have a script which is
supposed to check disk space on a number of remote computers.
Sometimes I get an error number back, without a description:
-2147217405. After looking around here, it seems that that means
permission is denied, or it might mean that WMI is not installed on the
remote computer. I'm not sure which. Which brings up the question -
does WMI need to be installed on the remote computer in order for a
script which uses WMI to work? I would have thought it wouldn't since
the script is not being run from the remote computer. Does it?
Another question. If -2147217405 does mean that permission is denied,
I just want to be clear about what exactly that means. Sometimes that
error comes back, but I can log on to that computer and look at the
disk space through a remote desktop connection. So if permission is
denied, how can that be?
My script is below, just in case someone had questions about what I am
doing. And just on a side note, constructive criticism is very
welcome.
Thanks,
Jennifer
On Error Resume Next
Dim CN, RS
Const HARD_DISK = 3
Const CONVERSION_FACTOR = 1048576
Dim
objWMIService,colItems,diskid,freemegabytes,diskspace,totalspace,sInsQry
Dim sErrQry
Dim sErrMsg
Set CN = CreateObject("ADODB.Connection")
Set RS = CreateObject("ADODB.REcordset")
sCon = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security
Info=True;Initial Catalog=Server_Disk_Utilization;Data Source=XXXXX"
CN.ConnectionString = sCon
CN.CommandTimeout = 180
CN.Open
sQry = "Select ServerName from Servers"
RS.Open sQry, CN
RS.MoveFirst
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' Loop throug the list of servers. Server names are in the
''' Recordset called RS.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Do Until RS.EOF
StrComputer = RS("ServerName").Value
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' First try to ping the server. Server name is in strComputer.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Set objWMIService = GetObject("winmgmts:\\" & "." & "\root\cimv2")
Set colPings = objWMIService.ExecQuery _
("Select * From Win32_PingStatus where Address = '" &
StrComputer & "'")
For Each objStatus in colPings
If IsNull(objStatus.StatusCode) _
or objStatus.StatusCode <> 0 Then
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' If PING does not work, then log it to the errors table.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If Err.Number <> 0 Then
Call LogError ("DriveSpace.VBS", "Try Ping", strComputer, Err.Number,
Err.Source, Err.Description)
End If
Else
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' If PING does work, then try to create a connection with
''' WMI to the Server.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' If the connection does not work, log it to the errors table.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If Err.Number <> 0 Then
Call LogError ("DriveSpace.VBS", "Connect to Server", strComputer,
Err.Number, Err.Source, Err.Description)
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' If the connection does work, get a list of drives from
''' the server.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Set colItems = objWMIService.ExecQuery("Select * from
Win32_logicalDisk " & _
"where drivetype = " & HARD_DISK & "")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' If getting the list of drives fails, log it to the errors table.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If Err.Number <> 0 Then
Call LogError ("DriveSpace.VBS", "Get Drive Letter", strComputer,
Err.Number, Err.Source, Err.Description)
End If
For Each objItem In colItems
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' If getting the list of drives works, then get the drive space
''' for each drive. Write the drive space to the Server_DiskUsage
''' table.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
diskid = objitem.deviceid
freemegabytes = objitem.freespace / conversion_factor
diskspace = round(freemegabytes,0)
totalspace = round(objitem.size/ conversion_factor)
sInsQry = "Insert Into Server_DiskUsage (" & _
" CollectedDateTime, " & _
" ServerName, " & _
" DriveLetter, " & _
" Capacity, " & _
" Used) " & _
"Values ('" & _
Now & "','" & strComputer & "','" & _
diskID & "'," & TotalSpace & "," &
TotalSpace - FreeMegabytes & ")"
CN.Execute sInsQry
If Err.Number <> 0 Then
Call LogError ("DriveSpace.VBS", "Insert Into Server_DiskUsage",
strComputer, Err.Number, Err.Source, Err.Description & " " & DiskID &
" " & Now )
End If
DiskID = ""
TotalSpace = 0
FreeMegaBytes = 0
Next
End If
Next
Set objWMIService = Nothing
Set colItems = Nothing
RS.MoveNext
Loop
Sub LogError (ScriptName, Location, Server, N, S, Desc)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' LogError Subroutine - logs the errors to the Server_ErrorLog
table.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim sCon, CN
sCon = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist
Security Info=True;Initial Catalog=Server_Disk_Utilization;Data
Source=XXXXX"
Set CN = CreateObject("ADODB.Connection")
cN.ConnectionString = sCon
cN.CommandTimeout = 180
CN.Open
If Err.Number = -2147217405 Then
sErrMsg = "Permission Denied"
Else
sErrMsg = Desc
End If
sErrQry = "Insert Into Server_ErrorLog (" & _
" ErrDateTime, " & _
" Script_Name, " & _
" Script_Location, " & _
" ServerName, " & _
" ErrNumber, " & _
" ErrSource, " & _
" ErrDescription) " & _
" Values ('" & _
Now & "','" & ScriptName & "','" & Location & "','" &
Server& "','" & N & "','" & _
S & "','" & sErrMsg & "')"
CN.Execute sErrQry
Err.Clear
CN.Close
Set CN = Nothing
End Sub Tag: Printing word-doc to pdf-file Tag: 188904
VBScript - ASP Access to SQL SERVER change
I have an ASP page that was done in VBScript
It is setup to read an Access database and I need to change it to read
a Sql 2005 Database.
The code that is used to open the Access Database:
Set adoConnection = server.CreateObject("ADODB.Connection")
Set adoRecordset = server.CreateObject("ADODB.Recordset")
adoConnection.Provider = "Microsoft.Jet.OLEDB.4.0"
Dim strLocation, iLength
strLocation = Request.ServerVariables("PATH_TRANSLATED")
iLength = Len(strLocation)
iLength = iLength - 11
strLocation = Left(strLocation, iLength)
strLocation = strLocation & "../Database.mdb"
adoConnection.Open ("Data Source=" & strLocation)
adoRecordset.ActiveConnection = AdoConnection
In my VB 6.0 app I use the following to open the SQL Database"
Set DataBaseTS_1 = New ADODB.Connection
DataBaseTS_1.ConnectionString ="Provider=MSDASQL.1;Persist Security
Info=False;Extended
Properties=Description=Large Pump Data Source;DRIVER=SQL
Server;SERVER=LPDATASYSTEM\PL3LP;APP=Microsoft Data Access
Components;WSID=LPDATASYSTEM;DATABASE=LargePump;Trusted_Connection=Yes;Initi
al Catalog=LargePump"
DataBaseTS_1.Open
How can I get the VBScript to open the SQL Database?
Thanks,
Bob Hiller
Lifts for the Disabled LLC Tag: Printing word-doc to pdf-file Tag: 188901
write results to virtual text file
I often use the following to output vbscript results to a temporary text
file so I can cut and paste text from it. Is there a way to make this a
"virtual" text file that never gets written to disk? Perhaps something
similar to ASP's Response.ContentType = "text".
Set Shell = CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
InfoFile = FSO.GetTempName
Path = Shell.Environment("Process")("Temp")
FSO.CreateTextFile(Path & "\" & InfoFile, True).WriteLine Details
CreateObject("Shell.Application").NameSpace(Path).ParseName(InfoFile).Invoke
Verb
WScript.Sleep 1000: FSO.DeleteFile Path, True
Set Shell = Nothing
Set FSO = Nothing
thanks
LJB Tag: Printing word-doc to pdf-file Tag: 188900
Error 800A0046 while running a vbs script on a remote computer
Hey there,
I am trying to make a script that could read an eventlog from a remote
comptuer. I found some code on MS website :
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile " _
& "Where LogFileName='System'")
For Each objLogFile in colLogFiles
Wscript.Echo objLogFile.NumberOfRecords
Next
When using "." for strComputer, everything works fine. If I put a remote
computer, the 800A0046 error appears (Access Denied 'GetObject'). I also
tried the permission "{impersonationLevel=impersonate, (Security)}" with no
success.
Any clues?
Thanks!
Mario Lavigne Tag: Printing word-doc to pdf-file Tag: 188899
Changing Exchange Folder pemission
All,
I want to add several users to an Exchange PF some as Owners others as
Publisher. Can this be done via script and is there a good sample you can
share?
Thanks,
Rafael Tag: Printing word-doc to pdf-file Tag: 188898
Copy "Services" file script ??
I need to copy the Services file in \Windows\System32\drivers\etc in all PC
in the domain.The prolem is that regular users dont have permissions to copy
the file.
I tried the Computer Startup Script in GPO but no success.
How can I copy this file through a script ??
Thanks Tag: Printing word-doc to pdf-file Tag: 188896
Permission Denied on CreateObject
Hi there,
the simple line of code that follows works fine on every
machine that I have tried it on except Windows 2003 Server. I get an error:
Permission Denied: CreateObject.
Set WordApp = CreateObject("Word.Application")
Is it the creation of the COM server, or the CreateObject script call that
is being blocked? What do I need to do to resolve it? Tag: Printing word-doc to pdf-file Tag: 188895
Re: How to make a dynamic file name?
I have not WMI installed for testing .. try :
Set objNetwork = CreateObject("Wscript.Network")
sComputerName = objNetwork.ComputerName
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextfile("c:\" & sComputerName & ".txt", True)
'sComputer = "." ' use . for local computer
'Msgbox sComputer
'''''MyFile.Write InstalledApplications(sComputer)
MyFile.Write InstalledApplications(sComputerName)
MyFile.Close
Function InstalledApplications(node)
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
Set oRegistry = _
GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& node & "/root/default:StdRegProv")
sBaseKey = _
"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
iRC = oRegistry.EnumKey(HKLM, sBaseKey, arSubKeys)
For Each sKey In arSubKeys
iRC = oRegistry.GetStringValue( _
HKLM, sBaseKey & sKey, "DisplayName", sValue)
If iRC <> 0 Then
oRegistry.GetStringValue _
HKLM, sBaseKey & sKey, "QuietDisplayName", sValue
End If
If sValue <> "" Then
InstalledApplications = _
InstalledApplications & sValue & vbCrLf
End If
Next
End Function
--
Fosco Tag: Printing word-doc to pdf-file Tag: 188886
Question regarding shelling out of an HTA to invoke an EXE
I have written an HTA program to facilitate the addition and deletion of DNS
host records using Microsoft DNS. The hypertext make the program user
friendly but the really work is being performed by the imbedded VBScript
code and the DNSCMD.EXE program. Currently, the VBScript sets up some
oshell.run statements involving the DNDCMD.EXE and the program works fairly
well.
My question is this.....
Is there another commands other than oshell.run or oshell.exec to invoke a
command line (non-GUI) program and pipe the output of the program directly
back into the HTA?
Here's what I want and don't want......
I don't want to have to deal with piping output to temp or permanent files.
I want the DNSCMD program to run completely in the background.
I want the output of the DNSCMD program to be it's directly accessible to me
from memory, not in a file that I would have to read.
Any suggestions would be greatly appreciated. Tag: Printing word-doc to pdf-file Tag: 188882
error when exporting crystal report to pdf using asp
I receive this error when trying to export a crystal report to a pdf
via an asp page...can anyone help? This worked perfectly on Windows
2000 but we have moved it to a Windows 2003 machine and it doesn't
work...
Microsoft VBScript runtime error '800a01fb'
An exception occurred: 'session(...).Export'
Any ideas?
Thanks!
Amanda Tag: Printing word-doc to pdf-file Tag: 188881
IE7. Any word about the affect on vbs.
A recent blurb in pcMag says that IE7 is much more secure than
IE6 ever was, and the major means by which the "improvements"
were achieved was by stifling scripting and actX objects.
Further, it went on to say the IE7 would most likely "break"
(does that mean render inoperable?) a vast number of websites,
and "break" an even vaster number of intRA-net web applications
(leading one to presume that intRA-net apps make a greater use
of scripting than the public websites).
The conclusion was that microsoft was frantically distributing
IE7 betas (or release candidates?) so that their customers could
reprogram their websites and their internal net-based apps to
conform with the requirements of IE7.
It is understandable that microsoft would want to stifle scripting,
those evil and malicious scripters have been giving everybody agita.
However, the customary advice given here to anybody who wishes to
have a scripting GUI is to script yourself up a suitable dialog
using the automation interface to IE6.
So finally, here's the question. Are all those scripts (or hta's)
going to be "broken" by IE7 also???
cheers, jw Tag: Printing word-doc to pdf-file Tag: 188871
posting here with attachments (follow-up)
A couple of weeks ago, there were some postings here related to
what was allowed in this ng as far as the size of attachments.
I don't know the definitive answer, but I recently tried to post
a message with TWO 40kb attachments, and that was rejected by
the server (grumble).
Then I removed one of the attachments and that one was posted
successfully.
So a somewhat vague answer would be that (at least) up to a 40kb
of attachments is acceptable, but 80kb is not.
hope this helps, jw Tag: Printing word-doc to pdf-file Tag: 188869
resolve OU current user
Hi,
Can anyone, please, help me with some code. I'm looking for a VB script to
resolve the OU of the current user. This way I want to create the LDAP path
of the current logged in user automatically. Anyone some ideas?
Best regards,
Jerry Tag: Printing word-doc to pdf-file Tag: 188862
Error running scripts against W2K3 boxes.
In the script below and all other scripts I have that I run against Win2k3
boxes I get an error. The error is:
Line: 33
Char: 1
Error: Permission denied:'GetObject'
Code: 800A0046
What am I doing wrong.
'--------------------------------------------------------------------
' This script looks for a CSV file in the same directory as this script to.
' pull server names from.
'--------------------------------------------------------------------
Dim fsoIn, fsoOut
Dim inFile, outFile
Dim arrComputerNames
Dim objUser
Dim strComputer
Dim ErrorOccurred
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Const inFilename = "servers.csv"
Const outFilename = "STARTTelnet.log"
'On Error Resume Next
ErrorOccurred = False
' Open the input file and skip the header line
Set fsoIn = CreateObject("scripting.filesystemobject")
Set inFile = fsoIn.OpenTextFile(inFilename, ForReading, True)
inFile.Skipline
While Not inFile.AtEndOfStream
arrComputerNames = Split(inFile.Readline, vbTab, -1, 1)
' arrComputerNames(0) contains the computer name
strComputer = arrComputerNames(0)
'--------------------------------------------------------------------
'This section sets up the information.
'--------------------------------------------------------------------
'THIS IS LINE 32 the one below is the one I'm havin' trouble with!!!
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\sp1\sp1.exe" , "\\" & strComputer & _
"\c$\SP1\sp1.exe", OverwriteExisting
'Next
Wend
Wscript.Echo "Done" Tag: Printing word-doc to pdf-file Tag: 188861
script for sharedtemplates location
I need to move the location of the sharedtemplates to another server and need
a script to automate the change for users. I know how to change the location
in office and the registry, however, with over 400 workstations spread over 5
locations, a manual process just doesn't seem efficient. Help...Please. :-) Tag: Printing word-doc to pdf-file Tag: 188859
Exporting datagrid contents to Excel using ASP.NET
Hello,
I am attempting to export the contents of a datagrid on my webform (using
Excel automation) through ASP.NET.
I have added the Excel object library to my VS ASP.NET project but I am lost
on how to export my datagrid contents to Excel?
I am sure it can be done but having difficulties figuring out the code.
Any help would be greatly appreciated.
Thanks,
Mike Tag: Printing word-doc to pdf-file Tag: 188858
redirecting stdout??
hi all, I need to redirect stdout to a file within a VBS script I need to
do this because I'm forced to use this SQL-DMO method:
http://msdn2.microsoft.com/de-de/library/ms141159(SQL.90).aspx
...which does not allow capturing of its stdout, since the one I need:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q279514
is broken (and has been since 2003). a response would be great!
- erick <e@arix.com>
p.s. in Ksh this would be so easy... I don't remember the syntax exactly but
it would be something like: exec > /tmp/myfile Tag: Printing word-doc to pdf-file Tag: 188855
Servers Status Monitor
Hi all.
I have writern a script which shows the online status of the all
servers which i have configured in the database, which includes Disk
space, Services status, Anvivirus stastus (Macfee), Processor usage.
Like how it synchronises with the server and show the status.
Please contact me on srikanth.vemu@gmail.com, whoever wants the script.
Regards,
Srikanth.V
Senior Systems Administrator,
HSBC. Tag: Printing word-doc to pdf-file Tag: 188854
Advice on working script
Hi,
I would welcome any comments on this script - it works and does what I
want it to, but I'm interested if any of the syntax is dodgy.
The script it intended to copy a file over from a location to another
location, and if the file already exists, check if the user wants to
overwrite.
Many thanks in advance
Script
-----
' Script to copy over the email signature
'get current user, put it in a string
Dim strUsername
Dim strBoo
Dim intResult
Const OverwriteExisting = TRUE
set strBoo = createobject("WSCRIPT.Network")
strUsername=strBoo.Username ' gets currently logged in username
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Check for files and prompt user to overwrite if it exists
If objFSO.FileExists("C:\Documents and
Settings\"&strUsername&"\Application Data\Microsoft\Signatures\sig.txt")
Then
intResult = MsgBox("You already have the signature files. Do you wish
to overwrite?",4,"email signature")
if intResult = vbNo then
WScript.Quit
else
MsgBox ("End of script")
objFSO.CopyFile "J:\sig.txt", "C:\Documents and
Settings\"&strUsername&"\Application Data\Microsoft\Signatures\",
OverwriteExisting
End If
else objFSO.CopyFile "J:\sig.txt", "C:\Documents and
Settings\"&strUsername&"\Application Data\Microsoft\Signatures\",
OverwriteExisting
end if Tag: Printing word-doc to pdf-file Tag: 188853
Script for adding/removing local user accounts on servers
Hello,
I have a need to maintain exact copies of local user accounts between
two Win2k3 member servers. I cannot use AD; the accounts must be
local.
I'm looking for a script that will create/delete user accounts on both
servers. In addition, when a PW needs to be updated it will change it
on both servers.
I'm vbScript "savvy" so I'm looking for a good headstart if someone
else is doing something like this already.
Thanks!
Troy Tag: Printing word-doc to pdf-file Tag: 188849
hot to round time to next day, next week or next month?
Hi Guys:
I have a scheduled task, should be run at every day, or every
first day of next week, or every first day of next month (from now).
I'm wondering if it's possible that:
Given today = March 13, 2006
Then URoundWeek(today) == March 20, 2006
URoundMonth(today) == April 1, 2006
Thanks in advance. Tag: Printing word-doc to pdf-file Tag: 188845
Folder/Sub-folder contents to a DB
Hello all, just wondering if I can can get some help here.
My company just purchased an EMR (Electronic Medical Records) system and we
need to perform a mass scanning offsite. The vendor is asking us to scan
patient files this way. The top folder is the patient account number the sub
folders contains the tabs where we want the files to be stored on the EMR
database and then inside of these sub-folders we will be scanning all the
files. What I need to do is to create a script that can monitor a Hard Drive
for all top folders (Account #'s) and all sub-folders and files and store the
folder names and file names into a databse for each top folder (account #).
Each database entry will need to have the account#, Tabname, filename. Once
Everything is scanned and the databse knows the location of all the files we
will then give an .csv file to the vendor with all the databse entries plus
the hard drive for a complete import to their system. I've looked everywhere
to see how can I accomplish this. So basically I will be creating folders
manually on the Hard Drive conataining the patients account#, the sub-folders
containing the tab names and then inside of the sub folders that's where the
scanned files will be. As for my database for the mass scanning it will be
an Access or SQL db containing only a table with pt_account,pt_tab,pt_image.
Any help would be greatly appreciated.
Thanks, Tag: Printing word-doc to pdf-file Tag: 188840
how to resolve Microsoft VBScript runtime error '800a0006'
Hi all,
I'm using the following bit of code to try to convert some date fields
to the epoch equivelant, but getting the error:
Microsoft VBScript runtime error '800a0006'
Overflow: '[number: 1142289086]'
/test.asp, line 25
After it hits a certain value. Here's the asp I'm using:
<html>
<head>
<title>Result of Database Query</title>
</head>
<body>
<h1>Result of Database Query - ASP/VBScript</h1>
<%
set myconn = server.createobject("adodb.connection")
connection = "helpdesk"
myconn.open (connection)
set result = server.createobject("adodb.recordset")
result.PageSize = 50
sql = "SELECT id,create_date,lastupdate FROM ooz_tickets"
set result = myconn.execute(sql)
if not result.EOF then
response.write("<p>Data:")
response.write("<table
border=2><tr><th>ID<th>create_date<th>lastupdate<th>newcd<th>newlu")
while not result.EOF
response.write("<tr><td>" & result("id"))
response.write("<td>" & result("create_date"))
response.write("<td>" & result("lastupdate"))
oldid = result("id")
newcd = DateDiff("s", "01/01/1970 00:00:00", result("create_date"))
newlu = DateDiff("s", "01/01/1970 00:00:00", result("lastupdate"))
response.write("<td>" & newcd)
response.write("<td>" & newlu)
result.movenext()
wend
response.write("</table>")
else
response.write("<p>No Entry for " & request("place"))
end if
%>
</p>
</body>
</html>
Line 25 is: newcd = DateDiff("s", "01/01/1970 00:00:00",
result("create_date"))
I'm assuming DateDiff() can't handle numbers greater than some specific
value. How can I get around this, or is there a different way to
convert the date values to epoch?
TIA Tag: Printing word-doc to pdf-file Tag: 188837
VBScript grammar for Yacc?
Hello,
I am looking for a up-to-date VBScript grammar for Lex/Yacc, Flex/Bison or
any other free lexer/parser.
Any idea where I could find one please?
Thank you in advance. Tag: Printing word-doc to pdf-file Tag: 188836
PopUp from LocalSystem
Hi,
I have a scheduled task which has to run as LocalSystem. Basically the
program allows me to specify "another program" to be ran before the
actual program begins (not confusing if you think about it). If the
called program's return code is an error, the scheduled task won't
start.
The idea is to have a message box displayed to the user, and if the
user chooses to cancel the operation or if it "times out", then the
task won't start.
I already did the trivial message box vbscript, which works fine if ran
from the same account of course: displays message box, in case times
out, and returns 0 or 1..
My "little" problem (and I come here after having searched almost
everywhere) is that the message box is not displayed at the user (as
the program runs from LocalSystem and not as the user) and therefore it
always returns the timeout.
Do you have any indication on how to solve this, or even a direction in
which to point me?
Looking forward to hearing from you soon,
Marco Tag: Printing word-doc to pdf-file Tag: 188835
Making Startup Script Visible
I have created a VBScript that runs interactively/visible as a Windows
startup script via Domain Group Policies. My script calls
CreateObject("InternetExplorer.Application") to display a form and
everything works correctly, but Windows is waiting for the script to
finish before displaying the login window. I can run another script and
quit the first script to get around this, but anything started by the
following means is not interactive/visible, even if it is forced to be
visible by all means that I have tried. I can keep the first instance
of Internet Explorer open, but is there any way to connect to that
instance of Internet Explorer from the second script, or is there
another way to start the second script similar to CreateObject?
These do not work:
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "WSCRIPT.EXE """ & WScript.ScriptFullName & """" & "
/Start"
'Set objStartup = objWMIService.Get("Win32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_
objConfig.ShowWindow = 5
objConfig.PriorityClass = NORMAL
Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process")
ScriptPath = Left(WScript.ScriptFullName, InStr(WScript.ScriptFullName,
WScript.ScriptName) -1)
errReturn = objProcess.Create("CSCRIPT.EXE """ & WScript.ScriptFullName
& """" & " /Start", null, objConfig, intProcessID)
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("WSCRIPT.EXE """ & WScript.ScriptFullName &
"""" & " /Start")
--
a178235
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------ Tag: Printing word-doc to pdf-file Tag: 188832
adding user to AD
Hello !
I have a small but very anoyning problem.
The helpdesk I work for is makeing a mess in the add when creating users.
There is allways a problem when there is some new user added to the domian.
Sometime there is userhomeshare is wrong, wrong wrights on homeshare server,
homeshare on wrong server, wrong loginscript and so on.......
I am looking for a good, smart way to let the helpdesk create users.
I thought of a script that could make such thing. But I do not know where to
start.
Do I really need to envent the wheel agin ? Perhaps I am not alone in this
world and someone els has made such a script before me.
I thought of a script that add a input.
The input should be
1 First name
2 Last name
3 networkloginid
Then the script would no everything els.
Everthing the same.
Like what server the user has as homeshare folder.
Login script should all be the same.
Password set to "password4me" as default to all users created by the script.
The user account enabled.
Well, do You see my point and do You understand what I am trying to
accomplish.
Any advice and direction to the correct soloution would make me happy. Tag: Printing word-doc to pdf-file Tag: 188829
Printer Usage
I have a Print Server having more than 400 defined LPR print queues. I
know there are many that are no longer needed. I would like to find
out when was the printer object last used. For example if a particular
queue has not been used for more than an year, I can remove it from my
server.
Any help would be appreciated. Tag: Printing word-doc to pdf-file Tag: 188825
How to make a dynamic file name?
I have a simple script that does what I want except that it saves the file
as a predetermined static name each time it's run.
I need to change it so it gets the computer name, adds it to the output and
also saves the file as the "computername."txt so each time it runs on a
different machine it would be easy to identify which machine it came from
without having to manually rename the file.
Here is the code:
Const OpenAsASCII = 0 ' Opens the file as ASCII (TristateFalse)
Const OverwriteIfExist = -1
' file where result is to be saved
sFile = "c:\apps.txt"
sComputer = "." ' use . for local computer
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set fFile = oFSO.CreateTextFile(sFile, _
OverwriteIfExist, OpenAsASCII)
fFile.Write InstalledApplications(sComputer)
fFile.Close
Function InstalledApplications(node)
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
Set oRegistry = _
GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& node & "/root/default:StdRegProv")
sBaseKey = _
"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
iRC = oRegistry.EnumKey(HKLM, sBaseKey, arSubKeys)
For Each sKey In arSubKeys
iRC = oRegistry.GetStringValue( _
HKLM, sBaseKey & sKey, "DisplayName", sValue)
If iRC <> 0 Then
oRegistry.GetStringValue _
HKLM, sBaseKey & sKey, "QuietDisplayName", sValue
End If
If sValue <> "" Then
InstalledApplications = _
InstalledApplications & sValue & vbCrLf
End If
Next
End Function
What would need to change so the results are saved as the name of the
computer it ran on instead of apps.txt or any other static name?I searched
around the Microsoft scripting site and could not find an understandable
answer. I found another script there that did a similar software inventory,
except it had even worse output. It outputted to pop-up dialog boxes
instead a written file. Tag: Printing word-doc to pdf-file Tag: 188823
Connect to db via VBScript?
Is it possible to connect to a MS Access (Mdb) database file from a html
page and write some records in the html file using Document.Write(myRec)
etc. The db file will be located in the same folder as the html file. Lets
say the database is a Telephonelist and I want to be able to read it from a
html page located in a shared folder. I suppose you would use ADO and SQL?
A very short example would be very much appriciated. Thank you so much in
advance.
Sincerely
Jan
PS. I know a little ASP but that is not an option here. Security is not
important in this case. Tag: Printing word-doc to pdf-file Tag: 188816
Enumerate ODBC Data Sources on all computers and write to file
I am not a programmer, but in preparation for a SQLnet rollout, we need
to poll the computers on our network to determine what ODBC definitions
they have.
To get ODBC connections, I believe we'd need a means of enumerating the
values of these two registry keys:
HKEY_LOCAL_MACHINE/SOFTWARE/ODBC/ODBC.INI/ODBC Data Sources
HKEY_CURRENT_USER/SOFTWARE/ODBC/ODBC.INI/ODBC Data Sources
Is there any way, perhaps with VBScript, to gather this type of
information and write it to a file?
If you're aware of any code that has been written to accomplish
something like this, I'd certainly be most appreciative! Tag: Printing word-doc to pdf-file Tag: 188814
Disable local account
I created a local user, that I addd to the local admin group. So outside of
the local admin account, I've also got another account in the local admin
group. Lets call it localA.
My question is once the pc is added to the domain, and a person logs in with
a domain account, I want to be able to remove the account called localA.
How do I script that out? I was thinking of putting a script in the default
users startup, that will look for my FQDM and if it detects it, then it will
remove the localA account, and delete itself.
I just need to know how I can delete that localA account.... the rest I
think I can handle
Thanks Tag: Printing word-doc to pdf-file Tag: 188808
Can not find the files
Hi Alll
I got a very strange problem today. I have couple user they saved pst file
on the file server. Because outlook2000 can't open pst file over 2GB. So I
decide to monitor those pst file on the server.
I am using this vbscript to find out the pst file on the server, during the
test, I just need the script can report where is the pst file.
**********************************************************
strComputer = "."
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery("Select * from CIM_DataFile where
extension = 'pst'")
For Each objFile in colFiles
Wscript.Echo objFile.Name
Next
**********************************************************
It runs and can't find any pst file. I change pst to mdb or xls, it got a
lot result. I rename one of the file to test.abc, and try to search by
extension='abc', still nothing.
any idea?
Thanks
Fire Tag: Printing word-doc to pdf-file Tag: 188807
ADO and NDS
I am using the following script to perform and LDAP query using ADO.
The LDAP server is Novell Netware 6 with eDirectory 8.6.2. The query
runs below returns all the attrubutes and their values when I use
LDP.EXE.
The query in the VBScript below finds the object and enters the While
loop, but I receive a Type Mismatch error when I try to retrieve the
Value property.
TypeName tells me the Value property is a Variant() type.
VarType tells me the Value property is 8204, which is an array of
Varriant
Ubound(objUser.Value) tells me there are 0 items in the array Value
objUser.Name returns "sn", which is correct.
Set cnnLDAP = CreateObject("ADODB.Connection")
Set rstLDAP = CreateObject("ADODB.RecordSet")
cnnLDAP.Provider = "ADSDSOObject"
cnnLDAP.Open
Query = _
"<LDAP://192.168.10.11/o=org>;(mail=bburns@ix.netcom.com);sn;subtree"
rstLDAP.Open Query, cnnLDAP
While Not rstLDAP.EOF
set objUser = rstLDAP.Fields.Item(0)
wscript.echo TypeName(objUser.Value)
wscript.echo Ubound(objUser.Value)
wscript.echo VarType(objUser.Value)
wscript.echo objUser.Name
rstLDAP.MoveNext
Wend
rstLDAP.Close
cnnLDAP.Close
Does anyone know why I am getting these results? Could this be an
issue with Novell's LDAP server? I have the Novell LDAP service
running in Compatibility mode. Do I need a specific option set to
retrieve the attributes?
Thanks for any help.
Brian Burns Tag: Printing word-doc to pdf-file Tag: 188806
Hi,
I dynamically created a word-document. How do I save it as a pdf-file?
Word and a pdf-printer are installed on the server!