output results to .txt or .xls file
hey all,
i have finally gotten together a script that will list all users in an
OU. well, the next thing i want to accomplish is writing the results
to a file. well, once again i have been humbled by the complex beast
that is scripting and i reach to my only life support (you fine folks
here) for assitance. here is a copy of the script. it will echo each
name but i want the end result to be a txt file or spreadsheet that
has the list of all of my users. please help...
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("C:\Documents and Settings
\&username&\desktop\list_users.txt")
objConnction.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT Name FROM 'LDAP://ou=company ou,ou=company
ou,dc=domain,dc=local' WHERE objectCategory='user'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo objRecordSet.Fields("Name").Value
objRecordSet.MoveNext
Loop Tag: New China Sex Hotline! Tag: 207210
Excel conditional formatting - how to make exceptions?
Hello all.
I've got a VBScript that creates an XLS file. In it I want to
implement conditional formatting; where if a cell value in Column C is
greater than 50000, then that cell font will be changed to bold and
red.
Recording a macro gave me this:
Sub Bold_Red()
Columns("C:C").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue,
Operator:=xlGreater, _
Formula1:="50000"
With Selection.FormatConditions(1).Font
.Bold = True
.ColorIndex = 3
.Italic = False
End With
End Sub
Then, after adding these Constants:
Const xlCellValue = 1
Const xlGreater = 5
I transposed the above macro into the following code:
'~~ Insert Bold and Red Font for any value
'~~ greater than 50000 in Column C
objExcel.Range("C:C").Select
objExcel.Selection.FormatConditions.Delete
objExcel.Selection.FormatConditions.Add xlCellValue, xlGreater,
"50000"
With objExcel.Selection.FormatConditions(1).Font
.Bold = True
.ColorIndex = 3 'Red
.Italic = False
End With
The code works fine except for one problem. Some of the cells in
Column C contain text, not a number, and the text is getting changed
to the Bold and Red font. I want the font to change only for cells
that contain a number, not text. How do I exclude the text cells from
the conditional formatting?
Any suggestions would be greatly appreciated. Thanks!
- Dave Tag: New China Sex Hotline! Tag: 207207
Event Problems
This is a test script that I am trying to get to work before I
incorporate it into the real thing. I am trying to get the
__InstanceModificationEvent to cooperate. Creation & Deletion events
work great. I can't figure out what triggers the Modification event.
I just want it to tell me if a file has been modified. By that I mean
if there is a file in the C:\X directory and a newer version of the
file is copied on top of the existing one, I would think that the
Modification Event would be triggered. Am I wrong. Someone please
help.
NoSeconds = "2"
MonitoredFolder = "C:\X"
CorrectMonitoredFolder = Replace( MonitoredFolder, "\", "\\\\" )
strComputer = "."
Set objFSO = CreateObject( "Scripting.FileSystemObject" )
Set objWMIService = GetObject( "winmgmts:" &_
"{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\cimv2" )
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceOperationEvent WITHIN " & NoSeconds & "
WHERE " _
& "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
& "TargetInstance.GroupComponent= " _
& "'Win32_Directory.Name=""" & CorrectMonitoredFolder & """'" )
Do While True
Set objEventObject = colMonitoredEvents.NextEvent()
Select Case objEventObject.Path_.Class
Case "__InstanceCreationEvent"
WScript.Echo "Created"
Case "__InstanceModificationEvent"
WScript.Echo "Modified"
Case "__InstanceDeletionEvent"
WScript.Echo "Deleted"
End Select
Loop Tag: New China Sex Hotline! Tag: 207204
How do I check for group membership?
I can ping a server to check its alive. I can add the proper group. What I
can't do is check to see if the group is already there!
I have looked at Hilltop Lab but can't seem to figure it out :(
'Define Variables
Dim objFSO
Dim objFile
Dim strLine
Dim arrFields
Dim strName
Dim Mydomain
Dim GlobalGroup
Dim oDomainGroup
Dim oLocalAdmGroup
Dim oNet
Dim sComputer
'CONSTANTS DECLARATION
Const LOGFILE = "C:\Documents and Settings\xxx\My
Documents\yyy\zzz\Logs\Results.Log"
Const ForReading = 1 'Open a file for reading only. You can't write to this
file.
Const ForWriting = 2 'Open a file for writing.
Const ForAppending = 8 'Open a file and write to the end of the file.
Set ofso = CreateObject("Scripting.FileSystemObject")
' initialisation of log file
InitLogFile()
' Open csv file for reading
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Documents and Settings\xxx\My
Documents\yyy\zzz\Logs\Test.csv", 1)
' Read the file one line at the time and loop through it
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
If strLine <> "" Then
arrFields = Split(strLine, ",")
For i=0 To UBound (arrFields)
strName = arrFields(i)
'Pinger serveren først, hvis den ikke er i live, skrives en log besked
If Ping(strName) = True Then
' Add the <servername>_local_admin group to the locale Administrators group
Mydomain = "xxx"
GlobalGroup = strName & "_local_admin"
Set oNet = WScript.CreateObject("WScript.Network")
Set oDomainGroup = GetObject("WinNT://" & MyDomain & "/" & GlobalGroup &
",group")
Set oLocalAdmGroup = GetObject("WinNT://" & strName &
"/Administrators,group")
oLocalAdmGroup.Add(oDomainGroup.AdsPath)
On Error Resume Next
If Err.Number = 0 Then
WriteLogFile 0, GlobalGroup & " has been added to the Administrators
group on "
Else
WriteLogFile 1, "Got Error " & Err.Number & " - " & Err.Description &
_
". When trying to add group " & oDomainGroup & " to " & oLocalAdmGroup
End If
On Error Goto 0
Else
WriteLogFile 0, "The server is unreachable: "
End If
Next
End If
Loop
' The functions for logging
Function InitLogFile()
oFso.CreateTextFile LOGFILE,True
End Function
Function WriteLogFile(iResult, sLogInfo)
Dim sLog,fFile
If iResult = 0 Then
sLog = Date & " - " & Time & " - " & sLogInfo & strName
Elseif iResult = 1 Then
sLog = Date & " - " & Time & " - ERROR - " & sLogInfo & strName
End If
Set fFile = oFso.OpenTextFile(LOGFILE,ForAppending,True)
fFile.WriteLine sLog
fFile.Close
End Function
Function WriteEventLog(iResult, sLogInfo)
Dim oshell, Retval, sLog
Set oShell = createobject("wscript.shell")
sLog = "*** " & ucase(wscript.ScriptName) & " ***" & vbcrlf &_
VbCrLf &_
Chr(9) & "RESULT : " & sLogInfo & vbcrlf &_
VbCrLf &_
Chr(9) & "SCRIPTLOCATION : " & wscript.ScriptFullName & VbCrLf
Retval = oShell.LogEvent(iResult, sLog)
End Function
' Funktionen der pinger serverne
Function Ping(strName)
Dim objPing
Dim objRetStatus
set objPing =
GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
("select * from Win32_PingStatus where address = '" & strName & "'")
For each objRetStatus in objPing
if IsNull(objRetStatus.StatusCode) or objRetStatus.StatusCode<>0
then
Ping = False
Else
Ping = True
End If
Next
End Function
' Confirms the script has completed and opens the file
Set objShell = CreateObject("WScript.Shell")
objShell.run ("Explorer" & " " & LogFile)
WScript.Quit Tag: New China Sex Hotline! Tag: 207201
Script to find a string in a text file on a remote computer
Could anybody help with me a script that is able to open a text file
on a remote computer, search it for a specified string, and then
return to me that string AND the line below it (or the next 30
characters).
I'm hoping to query a number of machine's drwtsn32.log files to find
similer errors.
The string I want to search for is "App: C:\Program Files\Internet
Explorer\iexplore.exe." and the line below it would be something like
"When: 10/05/2006 @ 11:01:24.511."
So basically I'm trying to find out when these errors are occurring. Tag: New China Sex Hotline! Tag: 207200
Certificate Services
Hello,
I need to connect to certificate services, read all certificates and their
properties like user, deadline etc. Does anyone know how to do that?
We have CA outside of AD. What do I have to do is to read certificate
properties, then connect to AD to find user specific info and do a task based
on conditions. I already have an application in .NET framework 2.0 to
communicate with AD, but how to communicate with Certification
Authority(service). The script/application schould be running on CA.
Thank you for help Tag: New China Sex Hotline! Tag: 207199
Detecting domain/user/computer through VPN tunnel/connection
Hi
The logon script we use at work works great when users are at the
office. But when at home and connected to our network through a VPN
tunnel (Netscreen Remote tunnel), the script is unable to detect the
domain name, the current user and the current computer. Currently we
detect those using the following VBScript code (cleaned up to save
space):
--------------------------------------
Dim strDomain
Dim objADSystemInfo: Set objADSystemInfo =
CreateObject("ADSystemInfo")
' AD info
strDomain = objADSystemInfo.DomainDNSName
' User account
Set objUser = GetObject("LDAP://" & strDomain & "/" &
objADSystemInfo.UserName)
' Computer account
Set objComputer = GetObject("LDAP://" & strDomain & "/" &
objADSystemInfo.ComputerName)
--------------------------------------
Is there another way to detect these things?
Best regards,
Egil. Tag: New China Sex Hotline! Tag: 207198
Count down timer
How do i create a msgbox popup in the middle of my screen that displays an
active count down
for example "this pc will shutdown in 10 9 8 7 etc"
I have figured out the shutdown portion of this script, just can seem to
figure out the timer.
Thanks Tag: New China Sex Hotline! Tag: 207179
string functions KILLING me, help! :o)
have the following:
strPath = "\\server\folder\folder"
strPath = Mid(strPath, 3)
strPath = Mid(strPath, 1, InStr(strPath, "\") - 1)
Wscript.Echo strPath
obviously what im doing is plucking out only the server name from the unc
path.
is there no way i could do this with one statement instead of 2? Tag: New China Sex Hotline! Tag: 207168
New to scripting, need a lil help
Im an intern at a software company, and I think I'm way over my head.
I need a script that can read and parse a text file (easy part, that I
know)
but I need my script to extract text between two delimiters that i can
specify.
is it possible to do this with regular expressions?
thanks in advance Tag: New China Sex Hotline! Tag: 207167
New to Scripting - Certificate revocation
Hello everyone, I have been thrown into VBScripting, of which I have no
experience.
I need to come up with a script that will revoke a certificate.
Specifically I need to revoke certificates from my CA that belong to certain
servers.
I am pretty sure I can figure out how to write a script that will call the
CertUtil utility and revoke the cert by serial number (based on the
following).
To revoke the certificate by serial number
Syntax
certutil-revoke [-gmt] [-seconds] [-v] [-config CAMachineName\CAName]
SerialNumber [Reason]
What I am stuck on is how to either scan through my CA and obtain the serial
numbers in question, or query the servers directly for the SN of their Cert.
Then use that list of serial numbers to revoke each. The good news is that
all of the servers I will have to do this for have a common naming
convention. Let's just say for example they all begin with AServer. .
Aserver1, AServer2, etc.
Here is some more information specific to what I am trying to accomplish:
I can easily do it through the GUI, but not sure how to script it.
We have member servers in a Windows 2003 domain with Microsoft Certificate
Authorities, Root, Intermediate, Issuing all set up with Group Policy set up
to manage. We are going through and changing the names of certain servers.
Then we are running an executable that forces the renamed client machine to
request a new certificate. That leaves the old certificate sitting on the CA
with the old machine name. I need to be able to script out finding that cert
on the CA under "Issued Certificates" and revoke it. It is easy enough if
you are in the GUI, just look and find the old server name and look at the
issued date and right click and revoke.
So I need a way to either go through all certs on the CA and parse for the
old hostname and retrieve the SN so it can be revoked. Or maybe there is a
way to query the member server for the previous cert. I have looked at the
Certutil switches and cannot find a way to pull the serial numbers at all,
much less pull a specific one based on member server name.
I shouldn't be a complete novice for long, as I am sitting at my desk going
through my courseware for both 2433A and 2439A. I have a deadline on the
above however and would really appreciate any help at all.
Thank you very much
--
Brad Tag: New China Sex Hotline! Tag: 207164
Creating Page Borders in Word
Hi all! I an new to this group but not to vbscript. However, I can't
seem to find out how to create Page Borders in a Word Document???
Thanks for any help,
Joe Tag: New China Sex Hotline! Tag: 207163
Scripting Help!! Please!!!
Hi I have created this script to remove a home directory from searching the AD
Const ForReading = 1
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1
strUser = InputBox("Enter User Name")
strDomain = "Globalinfra"
Set objTrans = CreateObject("NameTranslate")
objTrans.Init ADS_NAME_INITTYPE_GC, ""
objTrans.Set ADS_NAME_TYPE_NT4, strDomain & "\" & strUser
strUserDN = objTrans.Get(ADS_NAME_TYPE_1779)
Set objUser = GetObject("LDAP://" & strUserDN)
HomeShare = objUser.homeDirectory
DeleteFolder HomeShare
But for some reason I cannot get this to work. I have Admin rights to all
file servers. Any help appreciated
Cheers
G Tag: New China Sex Hotline! Tag: 207160
Cancel Button Problems
This is my script. While running, a window is opened, and refreshed
every so many seconds. Works great, but I want a button that I can
use to cancel the script and close the window. I know I can use these
two commands
objExplorer.Quit 'close window
Wscript.Quit 'quit proccess
but I can't get a html button to call them. Can someone please help
me and show me how, or give me a better way of doing what I want.
Thanks
On Error Resume Next
LocalDirectory = "C:\X"
RemoteDirectory = "D:\X\"
Seconds = 5
Minutes = ( Seconds / 60 )
strComputer = "."
Set objExplorer = CreateObject ( "InternetExplorer.Application" )
objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width = 550
objExplorer.Height = 200
objExplorer.Visible = 1
objExplorer.Document.Title = "Script in progress"
Do
LastRanTime = Now
If Seconds > 59 Then
objExplorer.Document.Body.InnerHTML = "This script will run every "
& Minutes & " minutes. <BR> " &_
"Your script is now being processed and may take several minutes to
complete. <BR>" &_
"This script last ran at " & LastRanTime
Else
objExplorer.Document.Body.InnerHTML = "This script will run every "
& Seconds & " seconds. <BR> " &_
"Your script is now being processed and may take several minutes to
complete. <BR>" &_
"This script last ran at " & LastRanTime
End If
objExplorer.Reload( True )
Set objFSO = CreateObject( "Scripting.FileSystemObject" )
Set objWMIService = GetObject( "winmgmts:\\" & strComputer & "\root
\cimv2" )
Set colFileList = objWMIService.ExecQuery _
( "ASSOCIATORS OF {Win32_Directory.Name='" & LocalDirectory & "'}
Where " & "ResultClass = CIM_DataFile" )
For Each objFile In colFileList
If ucase( objFile.Extension ) = "DXF" Then
RemoteFile = RemoteDirectory & objFile.FileName & "." &
objFile.Extension
If objFSO.FileExists( RemoteFile ) Then
Set objLocalFile = objFSO.GetFile( objFile.Name )
LocalDate = objLocalFile.DateLastModified
Set objRemoteFile = objFSO.GetFile( RemoteFile )
RemoteDate = objRemoteFile.DateLastModified
If LocalDate > RemoteDate Then
objFSO.CopyFile objLocalFile.Path, objRemoteFile.Path, True
End If
Else
objFSO.CopyFile objFile.Name, RemoteDirectory, True
End If
End If
Next
Wscript.Sleep( Seconds * 1000 )
Loop Tag: New China Sex Hotline! Tag: 207159
KIX Scripts & installing hotfix's
Greetings one and all,
You might be able to help me out of a real jam.
Our network here needs hotfix kb935843 (to fix a SQL reporting
services problem)
There are 2 versions of this hotfix, one for XP and one for 2000.
I need to roll this out as a logon script as there are over 1000 PC's
needing this update.
Now my query is this.
How, using KIX script, do i roll out the right update to the right
version of the OS, but only run it once.
Something like.
IF already installed then exit
Else IF OS = XP then run XP install
Else IF OS = 2000 then run 2000 install.
Help.
I'm new to using KIX, I seem to remember it is possible but exactly
how to do it i'm not sure.
Any help would be welcome.
Peter Phillips
Network Analyst
Redcats UK PLC Tag: New China Sex Hotline! Tag: 207155
mspview
Hello,
i need to convert several hundres .tif images to OCR. what i am looking for
is an automated process that will convert every single file in a specific
directory without any user input.
any help and or suggestions are greatly appreciated.
thanks
Surge Tag: New China Sex Hotline! Tag: 207154
need a tiny backup monitor script i can execute with task scheduler?
i would think this is like...the wheel. but i can't find anything, and i'm
not a coder.
i just need a tiny script i can run with task scheduler that will check to
make sure that:
1. a file was written in the last 24 hours
2. it's not locked for writing
3. it's larger than zero
email to a specified address if any of the above fail with the message
'Backup service is hung, and the bloody bugger won't email of it's own
volition when it does that.' Or something of that ilk anyway.
:P
can anyone point me in the right direction, or help a girl out?
Thanks!
peace,
pen
---
Life is short.
Break the rules.
Run towards your fears.
Forgive quickly.
Love truly.
Laugh uncontrollably.
Kiss slowly.
Above all, never regret anything that made you smile. Tag: New China Sex Hotline! Tag: 207152
send binary to IP printer
i have these printers that have formatter boxes attached. to
reconfigure these formatter boxes, i send a binary file to the device
by ...
1 create a print queue to the ip address
2 share that print queue
3 redirect LPT2 to that print queue
4 copy /b <format_file> LPT2
i would like to automate this function and am considering using
MSWinSck.ocx (stream to TCP 9100) but, can it handle ~1MB stream? Does
anyone have another idea how to do this efficiently and reliably? Tag: New China Sex Hotline! Tag: 207151
list printer address details of printers in AD
I need to be able to obtain a list of the printer name, host server, IP
address and MAC Address of all the Canon printers in an AD domain.
I can find the printer name and servername via dsquery as per below but then
some how I need to obtain the IP address and MAC address.
Any ideas?
dsquery * domainroot -filter "(&(objectClass=PrintQueue))" -attr printername
drivername servername -limit 10000 |find "Canon" Tag: New China Sex Hotline! Tag: 207146
labelling a mapped network drive
hi
how can i change label of a mapped network drive by commands (for example in
a batch file or logon script) Tag: New China Sex Hotline! Tag: 207134
WMI Query Question
OK.. Take this simple WMI query statement:
Set objBIOS = objWMIService.ExecQuery("SELECT * From Win32_Bios",,48)
Can anyone give me a good reference to what the "48" argument represents?
Better still, could anyone give me a good reference to an advanced scripting
textbook or online resource?
Many Thanks! Tag: New China Sex Hotline! Tag: 207132
Time after Time
Hi,
I have found lots of interesting stuff about time here, but one thing
is eluding me.
I need to be able to find the elapsed time between when a call was
taken and the time that the case was resolved.
Easy enough you say and it is.
Then I need to compare the elapsed time with a constant value, ie. 2
Hours, 4 hours, 48 hours and 120 hours.
I have tried doing this in an excel spreadsheet but no luck.
so here it is in psudo code;
WorkTime = Start Time - Finish Time
If Worktime > 2 and SLA = 1 then
objworksheet.value = "Over Sla"
End if
And so on and so on.
OldDog Tag: New China Sex Hotline! Tag: 207131
Yet More Time
Hi,
I have found lots of interesting stuff about time here, but one thing
is eluding me.
I need to be able to find the elapsed time between when a call was
taken and the time that the case was resolved.
Easy enough you say and it is.
Then I need to compare the elapsed time with a constant value, ie. 2
Hours, 4 hours, 48 hours and 120 hours.
I have tried doing this in an excel spreadsheet but no luck.
so here it is in psudo code;
WorkTime = Start Time - Finish Time
If Worktime > 2 then Tag: New China Sex Hotline! Tag: 207130
printer driver
hi
am trying to delete a printer driver from windows 2003 server and saying it
cannot do it because it is in use
Any ideas on h ow to delete it?
Have tried stopping and starting spooler but does not work, also tried
prndrvr.vbs and still says it is in use
is there a way i can export all queues and import them back, i just need to
remove a printer driver without having to recreate 600 quueues
help
don Tag: New China Sex Hotline! Tag: 207127
Adding TCP/IP Printer Ports and Drivers using a login script
I've written a script to automatically add tcp/ip printer ports and drivers
based on the user's subnet. The script works fine as administrator or power
user however it will NOT work properly if the user has standard user rights.
I need some assistance working around this. I realize that I could use WMI
to do impersonation and add these ports and drivers. However, due to the
large size of the script and the fact that changing methodologies to WMI
would add probably 20+ lines of code per printer per function, there are 100+
functions with anywhere from 2-15 printers per branch function, I can't
realistically change. I'm using the prnport.vbs and rundll32 printui.dll
methodoligies to accomplish what I need. I've tried to build runas into the
script even passing credentials automatically and it still doesn't work
right. My inclination is that the rundll32 must run under an explorer
session that has admin or power user rights otherwise it fails with not
enough rights. Below is a sample of the code. Any help you can provide
would be great!
Dim oIP, r
On Error Resume Next
oIP = DefaultGateway
Select Case oIP
Case "10.207.127.1"
Set oShell = WScript.CreateObject("WScript.Shell")
r = oShell.RegRead("HKLM\SOFTWARE\Printers\judesk\Installed")
If r <> 1 Then
AddPrintersjudesk
End If
End Select
Function DefaultGateway()
Dim oDG, oDGs, WMI
Set WMI = GetObject("winmgmts:\\.\root\cimv2")
Set oDGs = WMI.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each oDG in oDGs
If Not IsNull(oDG.DefaultIPGateway) Then
If Not oDG.DefaultIPGateway(0) = "0.0.0.0" Then
DefaultGateway = oDG.DefaultIPGateway(0)
Exit For
End If
End If
Next
End Function
Function AddPrintersJUDesk()
'prndriver1 = """QMS ColorScript Laser 1000"""
'prndriver2 = """Kyocera Mita FS-3700"""
prndriver3 = """IBM InfoPrint 20"""
'prndriver4 = """HP LaserJet 4"""
'prndriver5 = """SHARP AR-M277 PCL5e"""
prndriver6 = """Kyocera FS-5900C (KPDL-2)"""
'prndriver7 = """HP LaserJet 5Si"""
'prndriver8 = """HP LaserJet 4100 PCL 5e"""
oShell.Run "cmd /c cscript c:\windows\system32\prnport.vbs -a -r
IP_172.18.102.10 -h 172.18.102.10 -o raw -n 9100"
oShell.Run "cmd /c rundll32 printui.dll,PrintUIEntry /if /b P6154001 /f
%windir%\inf\ntprint.inf /r IP_172.18.102.10 /m " & prndriver1
oShell.Run "cmd /c cscript c:\windows\system32\prnport.vbs -a -r
IP_172.18.102.11 -h 172.18.102.11 -o raw -n 9100"
oShell.Run "cmd /c rundll32 printui.dll,PrintUIEntry /if /b P6154002 /f
%windir%\inf\ntprint.inf /r IP_172.18.102.11 /m " & prndriver1
oShell.Run "cmd /c cscript c:\windows\system32\prnport.vbs -a -r
IP_172.18.102.14 -h 172.18.102.14 -o raw -n 9100"
oShell.Run "cmd /c rundll32 printui.dll,PrintUIEntry /if /b P6154003 /f
%windir%\inf\ntprint.inf /r IP_172.18.102.14 /m " & prndriver1
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set StdOut = WScript.StdOut
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Printers"
strKeyPath2 = "SOFTWARE\Printers\judesk"
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath2
strValueName = "Installed"
dwValue = 1
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeypath2,strValueName,dwValue
End Function Tag: New China Sex Hotline! Tag: 207121
enumerate install windows components
Hey all, I am trying to enumerate the components that you add/remove
via the "Add/Remove Windows Components" option in add/remove prorgams.
Just to be clear, I need to list 'windows components' and not simply
installed software...for instance I need a script to determine if IIS
is installed on a machine, or 'fax services' and I am not looking for
whether or not general apps are installed (stuff like Adobe, Office,
etc...).
Please help! Tag: New China Sex Hotline! Tag: 207120
printer driver and prndrvr.vbs
hi
am trying to delete a printer driver from windows 2003 server and saying it
cannot do it because it is in use
Any ideas on h ow to delete it?
Have tried stopping and starting spooler but does not work, also tried
prndrvr.vbs and still says it is in use
help
don Tag: New China Sex Hotline! Tag: 207105
Full name of remote logged on user
I have this that gives me the domain\username of the remote logged on
user:
strComputer = InputBox("Enter the PC-name you want to know who's
logged on at", "Who is logged on?")
if strComputer = "" then
WScript.Echo "Don't you want to know?"
end if
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root
\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From
Win32_ComputerSystem")
For Each objItem in colItems
Name = objItem.UserName
wscript.echo name
Next
But i want to output the fullname of the user. I have tried everything
i can think of but only get my own fullname.
I have this that gives me the fullname of the localy logged on user,
but can not get it to work with the other script.
Set WshNetwork = WScript.CreateObject("WScript.Network")
objUserName = WshNetwork.UserName
Set objUser = GetObject("WinNT://" & Name)
wscript.echo objUser.FullName
Any help to get me in the right direction would be much appreciated. Tag: New China Sex Hotline! Tag: 207104
Assigning variable output of %comspec%
Hello,
Is there a way to allow a variable to hold the output of the comspec
statement (the statement running commands on command prompt)?
The command I am running produces result of only a single word on
screen, so can I:
VAR = objShell.run 'The comspec statement
Is this possible? I get an error when I do this but I really want the
variable to hold the value, is there any other way? Tag: New China Sex Hotline! Tag: 207100
write to eventlog or filesystem on remote machine in system context
hi,
i have a rather complex problem. we have to run a script that updates
a software via Microsoft SMS and I want to log the success/failure of
the script on a remote machine. i tried to write it into the remot
machines event log as well as filesystem but the main problem is:
everything that SMS executes on the client runs in system context.
even when i give permissions for "Everyone" on the remote machine that
is ment to collect the logs, the system on the client is not allowed
to connect to the share on the remote machine.
logfile = "c:\scripts\log\bla.log"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile (logfile, ForAppending, True)
Sub WriteTime
objTextFile.WriteLine("[" & Day(Now) & "." & Month(Now) & "." &
Year(Now) & " " & Hour(Now) & ":" & Minute(Now) & ":" & Second(Now) &
"]")
End Sub
using a UNC name as logfile works well, if the script runs with a real
user. can i tell vbs to establish the connection with a specific
useraccount? this way i could create a stripped down user on the
remote machine which the vbs on the client then uses to connect to the
share with a real username. Tag: New China Sex Hotline! Tag: 207098
How to find a DFS root in a domain
Hi all,
Does any one know how to find the DFS root in a Domain using VBscript.
Please let me know
Thanks in advance... Tag: New China Sex Hotline! Tag: 207097
Using VBScript to refresh group policy, restart, and log in.
I am writing a script that needs to apply the domain's group policy,
restart, and automatically log the administrator back in without
needing any user interaction. The problem is that I cannot get rid of
the legal message. This is the popup that appears after you press CTL-
ALT-DEL on a Win2k or WinXP machine which has a message set in the
group policy. In my case, the message is set in a domain GPO.
My first solution was to delete the legalnoticetext and
legalnoticecaption registry values in HKLM. This is a very common
example on the internet. However, (like many of these examples) this
doesn't work because the group policy will just be applied again when
the computer is restarting.
My second solution was to make use of the NoMachinePolicy DWORD value
located in:
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\GPExtensions
\{827D319E-6EAC-11D2-A4EA-00C04F79F83A}
When NoMachinePolicy is set to 1, it prevents the security policy from
being applied. I had the script set the value to 1 just before
rebooting, and then change the value back after logging in. This
solution also has problems, and I can't use it. In Windows XP, it
appears to reverse the changes made by the gpupdate /force command. I
am executing gpupdate /force, setting the auto logon registry entries,
setting NoMachinePolicy to 1, clearing the legal message text and
caption, and then restarting. But here's the problem: when the group
policy is applied, the administrator account is renamed to something
else. However, after I restart the account's name goes back to
administrator. My auto login fails because I have the wrong account
name for DefaultUserName. And I have verified that after the gpupdate
command is run, the account name does change just before the gpupdate
finishes. I have no idea why this is happening.
The second reason I don't like using this is because I cannot leave
NoMachinePolicy set to 1 the whole time the script is working. The
script installs several packages after restarting which need to be
able to apply group policy. And if I do not have it set the whole
time, the computer will not be able to automatically boot up and login
if one of the package installations forces a restart.
So I'm looking for a working solution that will let me bypass the
legal message for an automated logon. This is the only problem
stopping me from being able to use this script, and I would really
appreciate some help here. Tag: New China Sex Hotline! Tag: 207096
Shutdown computer using VBScript
Hi. I am trying to shutdown a group of computers that are on the
domain using a VBScript. When the user launches the VBScript it will
ask for the time in seconds before the computer shutdowns. It is being
done based on the way the command prompt does i.e. shutdown -m \
\computerName -s -t 00. I know the script will work if I make the
computer shutdown ignoring the user input but need to know how to do
it so the user can select how long it will be before it shutdown.
Thanks very much for anyone who can help me in this matter. Tag: New China Sex Hotline! Tag: 207084
registry keys to treeview control
Hi,
I have been struggling with the following
I am using vbscript in an application that will display registry keys
(and their values) as part of a treeview control.
I know the 'parent key', under which there can be a varying number of
subkeys, and their subkeys, and so on.
I know how to enumerate subkeys under a single key, using WMI and
EnumKey
What I am srtuggling with is, that I need some mechanism to process
each of the found subkeys to find about their subkeys, and so on. Some
kind of recursive algorhythm. I have seen and tried examples of
recursive algorhythms, for instance for files and folders. But
somehow, I cannot get my brain to figure out how to translate those to
my needs.
I was hoping someone could help me out, either with some sample code
or a website perhaps? I have so far searched pscode.com and some
others, but havent quite found what I am looking for.
kind regards,
arno Tag: New China Sex Hotline! Tag: 207083
Read from one Text file and Write to another.
I have to make an edit to a file and what I was planning to do is open
the file to read, then compare each line read to see if it equals my
search value, which is a substring of what is probably there. If it
does not, simply write it to another file. If it does = my search,
simply replace the value with my edit and write to the other file. I
would do this until the original file is at end. I would then like to
move my new file over the original, which should now include my edit.
Or
Open File for Read
Open Other File for Right
'read through first file
While file not at end
If line contains my search substring
replace line to include new substring
write it to other file
else
write line to other file
End if
End While
Close new file
Close original file
Move new file to original
Done!
Any guidance from a vbscript wiz would be greatly appreciated!
Thanks!!! Tag: New China Sex Hotline! Tag: 207075
How to insert the Thousands Separator (comma) in Excel?
Hello all.
I've got a VBScript that takes a CSV file, makes some formatting
changes, and saves it to an XLS file. What I'd like to add to this
script is the command to insert the Thousands Separator in column B
for the entire column. Column B contains numbers in every cell except
for the top cell which has a word.
In searching I did find the Constant "Const xlThousandsSeparator = 4"
but I can't quite figure out how to write the line to implement it.
Any suggestions would be greatly appreciated. Thanks!
My script:
Const xlDescending = 2
Const xlNormal = 1
Const xlCenter = -4108
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim CurDir
CurDir = objFSO.GetFolder(".").Path
Set Folder = objFSO.GetFolder(CurDir)
Set Folder = nothing
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Open(CurDir & "\Results.csv")
Set objWorksheet = objWorkbook.Worksheets(1)
'~~ Sort by Column B, Descending
Set objRange = objWorksheet.UsedRange
Set objRange2 = objExcel.Range("B1")
objRange.Sort objRange2,2
'~~ Insert blank row at Row 1
sRow = "1"
objExcel.Worksheets(1).Rows(sRow).Insert xlDown
'~~ Insert Header text
objExcel.Worksheets(1).Cells(1,1).Value = "Server"
objExcel.Worksheets(1).Cells(1,2).Value = "Error Amount"
'~~ Bold the Header row
Set objRange3 = objExcel.Range("A1:B1")
objRange3.Font.Bold = True
'~~ Auto Fit and Center both Columns
objExcel.Cells.EntireColumn.AutoFit
objExcel.Cells.EntireColumn.HorizontalAlignment = xlCenter
'~~ Insert blank row at Row 2
sRow = "2"
objExcel.Worksheets(1).Rows(sRow).Insert xlDown
objWorkbook.SaveAs CurDir & "\Results.xls",1
objWorkbook.Close
objExcel.Quit
Set objFSO = nothing
Set objExcel = nothing
Set objWorkbook = nothing
Set objWorksheet = nothing
Set objRange = nothing
Set objRange2 = nothing
Set objRange3 = nothing Tag: New China Sex Hotline! Tag: 207066
Problems with Connection Strings
Hello Everyone,
I am a newbie to web development. I am using FrontPage 2002/SP3 on XP and
IIS 6.0 on Win2K3 server. My Dev website is stored locally and I am
publishing to the IIS server.
I am attempting to connect to and query an Access database stored both
locally and on the IIS server. This is the code (and connection string that
I am using, (which I believe should be using the Microsoft Jet driver, pardon
if I am not 100% correct in this statement.)...
<%
dim oConn
dim strConn
dim strSQL
dim rs
Set oConn = CreateObject("ADODB.Connection")
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and
Settings\rks.RPS.002\My Documents\My
Webs\richweb\GSDtest\OtherFiles\jettest.mdb
oConn.open strConn
%>
On my local XP box, the first time I hit the hyperlink to call this page
(jet.asp), IIS shows me all the code on the page. If I refresh the page, it
renders and displays correctly, except the query that I run does not appear
to execute, or at the very least, the results of the query are not
returned/displayed.
When I run this page on the IIS server, I get the following error message:
Microsoft VBScript compilation error '800a0401'
Expected end of statement
/GSDtest/Jet.asp, line 8
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and
Settings\rks.RPS.002\My Documents\My
Webs\richweb\GSDtest\OtherFiles\jettest.mdb
----------------------------^
The ^ character is pointing to the "." (period) after OLEDB and before the
number 4. Can anyone tell me why I am having this problem and how to resolve
it?
TIA,
Rich Tag: New China Sex Hotline! Tag: 207065
Login script for printing preferences
I need to over-ride Printing Preferences at the point of login to change a
default label size on a Zebra TLP-2844 Thermal Printer.
Is this information stored in the registry and is it possible to do this
please?
Thank you, Mark Tag: New China Sex Hotline! Tag: 207064
Check if AD attribute exists
Hi, is there a way to check if an attribute of a user object in Active
Directory is "Not Set", i.e. currently has no values set?
Checking for Null or an empty string doesn't seem to be possible, but I
don't really want to rely on checking for an error.
many thanks,
Craig Tag: New China Sex Hotline! Tag: 207061
Assign serial Number to Thumb Drive (USB)
Is there a way to process a VB Script to put a serial number in for a USB
Thumb Drive?
Thanks in advance. Tag: New China Sex Hotline! Tag: 207059
Install MSI
Hi!
I have the following code to install an app:
Set objInstaller = CreateObject("WindowsInstaller.Installer")
objInstaller.UILevel = 3 + 32
objInstaller.InstallProduct "app.msi"
In some machines the user do not have install privileges.
Is there any form to install the app in these machines?
Thanks. Tag: New China Sex Hotline! Tag: 207056
Urgent!!! VB Developers for UAE
VAM SYSTEMS is a Business Consulting, IT Technology Solutions and
Services company with operations in UAE, Qatar, USA, Singapore,
Australia and India.
We are currently looking for a team (4 to 8 developers) VB Developers
for our UAE operations with the following Skill Set and Terms &
Conditions
Skill Set required:
Skills:
1. Strong Development experience VB, VB Scripting, SQL and Delphi.
2. Experience on banking will be an added advantage.
Domain: Banking.
Experience Required: 3-5yrs
Terms and conditions:
Joining time frame : 2 weeks (Maximum 4 weeks)
The selected candidates shall join VAMSYSTEMS-UAE and deputed to one
of the leading banks in UAE.
Should you be interested in this opportunity, please send your latest
resume in MS Word format at the earliest at
nishanthini.suda@vamsystems.com or If there is any queries you can
chat me on nishanthini_28@hotmail.com,
nishanthini_81@yahoo.co.in,vinirma@gmail.com, Skype ID is nishanthini2
or call us +91 471-3015245 or 2311320. Tag: New China Sex Hotline! Tag: 207053
Urgent!!! VB Developers for UAE
VAM SYSTEMS is a Business Consulting, IT Technology Solutions and
Services company with operations in UAE, Qatar, USA, Singapore,
Australia and India.
We are currently looking for a team (4 to 8 developers) VB Developers
for our UAE operations with the following Skill Set and Terms &
Conditions
Skill Set required:
Skills:
1. Strong Development experience VB, VB Scripting, SQL and Delphi.
2. Experience on banking will be an added advantage.
Domain: Banking.
Experience Required: 3-5yrs
Terms and conditions:
Joining time frame : 2 weeks (Maximum 4 weeks)
The selected candidates shall join VAMSYSTEMS-UAE and deputed to one
of the leading banks in UAE.
Should you be interested in this opportunity, please send your latest
resume in MS Word format at the earliest at
nishanthini.suda@vamsystems.com or If there is any queries you can
chat me on nishanthini_28@hotmail.com,
nishanthini_81@yahoo.co.in,vinirma@gmail.com, Skype ID is nishanthini2
or call us +91 471-3015245 or 2311320. Tag: New China Sex Hotline! Tag: 207052
IsDate()
I am working with an HTA, having the user enter a numeric value for the
MONTH / DAY / YEAR. I then concatenate them into the format shown and then
do an IsDate(). If the user enters something like 14 / 2 / 2007, IsDate
returns True; it is reading the date as DAY / MONTH / YEAR.
Any idea how I can get around this without using DropDowns?
Thanks.
Bart Tag: New China Sex Hotline! Tag: 207051
Bug in Win32_LogonSession?
Hello everyebody,
It seems that Win32_LogonSession class has an undocumented bug or
feature related to the RunAs service.
Here is a simple script:
*******************************************************************************************
Set objWmiSvc = GetObject("winmgmts://")
Set colUsers = objWmiSvc.execQuery("Select * from
Win32_LoggedOnUser")
For Each objUser In colUsers
set objUser = objWmiSvc.Get(objUser.antecedent)
set objSess = objWmiSvc.Get(objUser.dependent)
WScript.Echo objUser.name & " - " & objSess.logontype
Next
*******************************************************************************************
I run it under a regular user account and it displays:
MyUser - 2
where
MyUser - the user currently logged on
2 - means that is an interactive session.
Then, from the same session spawn a command prompt windows using Run
As with another username and rerun the script from the initial user
context (not the new run as window).
Now it displays:
MyUser - 0
where
MyUser - the user currently logged on
0 - means this is SYSTEM session !!!
Is this a bug in WMI?
Has anyone seen this before? Tag: New China Sex Hotline! Tag: 207050
Using the DiskQuota object returns many names unresolved in Windows 2000 - any way to get all?
I am attempting to gather the disk quota information on a number of
volumes on a Windows 2000 server. I am using the script from TechNet
at http://www.microsoft.com/technet/scriptcenter/scripts/storage/quotas/default.mspx?mfr=true.
The entries are returned but many of them return a blank LogonName and
an AccountStatus value of 5 (Account information is unresolved). I
note that if I display the quota entries from the volume properties
many of the entries display [Retrieving Name] for some period of time.
I am guessing that the use of the shell object from the script does
not get refreshed. Is there any way to get the information refreshed
in Windows 2000?
Thanks! Tag: New China Sex Hotline! Tag: 207048
Locale and CDate issue
When I am using setlocale to a western locale like en-gb or en-us, the
CDate function is sensitive to the field sequence defined in the
locale. So if I CDate a string like 25/12/2007 using en-gb the date is
Christmas, if I do the same in a en-us locale, 12/25/2007 is
Christmas.
If I setlocale to ar-sa (Arabia Saudi Arabia) and use the
formatdattime function, I get the Gregorian date converted to a Hijri
date automatically.
However, if I use CDate while in the ar-sa locale setting, the
datevalue that is created seems like the middle ages (1428/12/16). How
can I get a correct datetime value from a Hijri date using the locale
features in vbscript?
tia Tag: New China Sex Hotline! Tag: 207045