? Find last instance of substring in a string
Hi,
I have a string that contains the full path to a file (eg: "C:\Program
Files\folder\directory\app.exe". What I need is a way of removing the
"\app.exe" so that I can have just the path.
I checked around but none of the solutions worked when I put the code in
a VBS file. How can I do that with a .VBS file?
thanks
--
Alec
asoroudi@synetech.cjb.net Tag: LoggedOn Tag: 148733
NewBie needs help mapping drives
i have a script that works if I double click on it when its on the
desktop but nothing happens when user logs on. Not sure if I am
placing the script in the right folder and or setting up the user
login profile right. I know how to use .bat logon scripts but would
like to start using the vbs scripts. So could I please get some help.
How the user should be setup and where script should be placed on the
server.
using nt4.0 server and Xp, ME or 98 workstations
thanks Tag: LoggedOn Tag: 148728
Retrive User SID via VBScript
I have been trying to create a script to do something very tricky which is
delete local user profiles from a workstation using a variable for the
profile name in question. Obviously the correct way from the console is to
go to the System Properties-User Profiles tab because doing it from the Docs
& Settings directory still leaves Reg entries.
So, I can do it manually and know the registry locations to delete the data
however it's done by the SID of the user account. My problem is how to get
the user SID for the account. In the 2k Reskit I have the GETSID command
available however it gives way too much data and calling it from a script
only runs the command but doesn't give me the output back into my script.
Does anyone have a method to get the user SID via VBScripting?
Thanks
Richard Tag: LoggedOn Tag: 148719
wscript.shell Popup not working?
The following line doesn't dismiss my Popup after one second when called
from my html. It does work however when run on the desktop in VBScript. What
I was looking for was just a brief message indicating a program was started
and running. Instead I get a Popup I must dismiss manually. What gives?
CreateObject("WScript.Shell").Popup "Running: MyProg", 1, "title", 64
Parameter "64" gives me button OK and the information icon. Is there a way
to call a Popup without any button?
thanks
LJB Tag: LoggedOn Tag: 148717
Retrieving Network Card Configuration
This is the script I am using to retrieve network card configuration
from a remote Windows 2000 computer. It is striaght from the
Microsoft Portable Script Center. The script works and retrieves the
information but it retrieves the information as if there were two
network cards in the PC. I have run this on multiple PC's with only
one network card and each time it retrieves information twice for the
same adapter. Is there something wrong with the "For Each objAdapter
in colAdapters" statement that it is seeing two network adapters?:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\"& strComputer &
"\root\cimv2")
Set colAdapters = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled
= True")
n = 1
WScript.Echo
For Each objAdapter in colAdapters
WScript.Echo "Network Adapter " & n
WScript.Echo "================="
WScript.Echo " Description: " & objAdapter.Description
WScript.Echo " Physical (MAC) address: " & objAdapter.MACAddress
WScript.Echo " Host name: " & objAdapter.DNSHostName
If Not IsNull(objAdapter.IPAddress) Then
For i = 0 To UBound(objAdapter.IPAddress)
WScript.Echo " IP address: " &
objAdapter.IPAddress(i)
Next
End If
If Not IsNull(objAdapter.IPSubnet) Then
For i = 0 To UBound(objAdapter.IPSubnet)
WScript.Echo " Subnet: " &
objAdapter.IPSubnet(i)
Next
End If
If Not IsNull(objAdapter.DefaultIPGateway) Then
For i = 0 To UBound(objAdapter.DefaultIPGateway)
WScript.Echo " Default gateway: " & _
objAdapter.DefaultIPGateway(i)
Next
End If
WScript.Echo
WScript.Echo " DNS"
WScript.Echo " ---"
WScript.Echo " DNS servers in search order:"
If Not IsNull(objAdapter.DNSServerSearchOrder) Then
For i = 0 To UBound(objAdapter.DNSServerSearchOrder)
WScript.Echo " " & objAdapter.DNSServerSearchOrder(i)
Next
End If
WScript.Echo " DNS domain: " & objAdapter.DNSDomain
If Not IsNull(objAdapter.DNSDomainSuffixSearchOrder) Then
For i = 0 To UBound(objAdapter.DNSDomainSuffixSearchOrder)
WScript.Echo " DNS suffix search list: " & _
objAdapter.DNSDomainSuffixSearchOrder(i)
Next
End If
WScript.Echo
WScript.Echo " DHCP"
WScript.Echo " ----"
WScript.Echo " DHCP enabled: " & objAdapter.DHCPEnabled
WScript.Echo " DHCP server: " & objAdapter.DHCPServer
If Not IsNull(objAdapter.DHCPLeaseObtained) Then
utcLeaseObtained = objAdapter.DHCPLeaseObtained
strLeaseObtained = WMIDateStringToDate(utcLeaseObtained)
Else
strLeaseObtained = ""
End If
WScript.Echo " DHCP lease obtained: " & strLeaseObtained
If Not IsNull(objAdapter.DHCPLeaseExpires) Then
utcLeaseExpires = objAdapter.DHCPLeaseExpires
strLeaseExpires = WMIDateStringToDate(utcLeaseExpires)
Else
strLeaseExpires = ""
End If
WScript.Echo " DHCP lease expires: " & strLeaseExpires
WScript.Echo
WScript.Echo " WINS"
WScript.Echo " ----"
WScript.Echo " Primary WINS server: " &
objAdapter.WINSPrimaryServer
WScript.Echo " Secondary WINS server: " &
objAdapter.WINSSecondaryServer
WScript.Echo
n = n + 1
Next
Function WMIDateStringToDate(utcDate)
WMIDateStringToDate = CDate(Mid(utcDate, 5, 2) & "/" & _
Mid(utcDate, 7, 2) & "/" & _
Left(utcDate, 4) & " " & _
Mid (utcDate, 9, 2) & ":" & _
Mid(utcDate, 11, 2) & ":" & _
Mid(utcDate, 13, 2))
End Function Tag: LoggedOn Tag: 148712
VBScript will not install Security Patches Silently.
Need Help!!!
I am trying to install 7 patches for Office 2000 silently. I want
users to have no interaction these are installing. Below is the
following code.
'On error Resume next
Set Wshshell = WScript.CreateObject("WScript.Shell")
WshShell.Run "U:\AppLauncher\OfficeSP3\O2kSp3.exe /q /R:N", 1, True
WshShell.Run "U:\AppLauncher\OfficeSP3\olk0901.exe /q /R:N", 1, True
WshShell.Run "U:\AppLauncher\OfficeSP3\office2000-KB822035-client-enu.exe
/q /R:N", 1, True
WshShell.Run "U:\AppLauncher\OfficeSP3\office2000-KB830347-client-enu.exe
/q /R:N", 1, True
WshShell.Run "U:\AppLauncher\OfficeSP3\office2000-KB830349-client-enu.exe
/q /R:N", 1, True
WshShell.Run "U:\AppLauncher\OfficeSP3\office2000-KB824993-client-enu.exe
/q /R:N", 1, True
WshShell.Run "U:\AppLauncher\OfficeSP3\office2000-KB826292-client-enu.exe
/q /R:AS", 1, True
Even through I have used /q switch, the windows install displays and
also the pop up message that the patch has installed? Is there anyway
to keep this message pop ups hidden? Thanks for help!!!! Tag: LoggedOn Tag: 148709
Managing Office Objects
Can anybody please point me to a good starting point to understand the
Office object model, the best way to use it and, if possible, some VBscript
samples to manage Excel, Word and Outlook?
Marius Tag: LoggedOn Tag: 148703
how to hide VBScript: in a MSGBox ?
Hello,
Does it possible to hide the message VBScript: in the title of a message box
?
Thanks. Tag: LoggedOn Tag: 148697
MS Image Resizer
I would like to implement a VBScript to use the Image
Resizer from the XP Powertoys. Does anyone know if this
is possible and if so what object I need to link to? Tag: LoggedOn Tag: 148696
Get the default user name of pc using a text file contain a hostname list
Here is my dilemma...
I have a text file with all the pc's i need to get the
default username using the registry.
The key is HKLM\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Winlogon
and the reg value to read is DefaultUserName.
I need to output the results in a file like:
hostname,username
The hostname would be gathered from the text file, so I
dont need to query for it.
Any ideas how? Tag: LoggedOn Tag: 148695
Windows Environment Variable
Hi! I've worked with VBA for a while now, but am brand new to VBScript.
How do I use windows environment variables in VBScript? In VBA/VB, you have
the "Environ()" function, which I guess is not in VBScript. (I have one
called "ddssrvr", which returns the name of a server)
What I'd like to to do is change the HREF attribute of the <BASE> tag when
the window loads - evaluating the value of "ddssrvr" and using it to create
the <base> href URL. The .htm document I want to use this is will be part
of an compiled HTML help file - I don't know if this would cause additional
problems.
Thanks for any help with this! --- Francis Parsons Tag: LoggedOn Tag: 148692
WMI Broken?
I have a VBS script that runs on all of our XP
workstations except for one.
When ever the following line is executed.
Set oReg=GetObject("winmgmts:\root\default:StdRegProv")
I get this error.
"The specified module could not be found."
I tried re-applying Service Pack 1 for XP but I still have
the asme problem.
Is WMI busted on this PC?
Does anyone know of a fix?
Thanks
Mike Tag: LoggedOn Tag: 148687
popup not working
The following line doesn't dismiss my Popup after one second when called
from my html. It does work however when run on the desktop in VBScript. What
I was looking for was just a brief message indicating a program was started
and running. Instead I get a Popup I must dismiss manually. What gives?
CreateObject("WScript.Shell").Popup "Running: " & MyProg , 1, "Publish
KCenter", 64
Parameter "64" gives me button OK and the information icon. Is there a way
to call a Popup without any button?
thanks
LJB Tag: LoggedOn Tag: 148683
Problems with date(), datevalue(), formatdatetime() in VBScript 5.6
Hi,
I wrote a few scripts some time ago and now I just wanted to make them better.
While I've been testing the scripts, something weired was going on since the
scripts didn't work as expected anymore. Now I found out, that it is my machine
that is stupid (the scripts are working on every other machine!!!).
This little script workes on every machine I tested.
today = Date()
datum = datevalue(today)
wscript.echo "Die Variable 'datum' ist vom Typ: " & vartype(datum)
wscript.echo "Die Variable 'today' ist vom Typ: " & vartype(today)
Both variables are of Type "7" (Date) but on my machine I get an runtime error
in Line 2 "Type mismatch" (datevalue) Code: 800A000D
Can anybody help?? I just reinstalled Windows Script 5.6 and this behaviour
still occures only on my machine. Tag: LoggedOn Tag: 148675
Object browser and registry
Where can I locate documentation about Object Browser and the way to use it?
I used Object Browser inside Word to look at objects.
I addes the Scripting library to the list of available lists.
I noticed that I can look at several classes.
However, class FileSystemObject have a corresponding entry in the registry
under HKEY_CLASSES_ROOT, (Scripting.FileSystemObject) while I don't see an
entry in the registry for the Files class: is it registyered with a
different name? How can I locate the entry in the Registry associated with
a specific class?
Second question: looking in the Registry I don't see anything in the
Scripting.FileSystemObject and in the Scripting.FileSystemObject .CLSID
keys: is it correct?
Regards
Mario Tag: LoggedOn Tag: 148670
VBS / WSHost FTP Help ..
Hello there ..
I'm using the following the VBS script to retrieve a file from a
remote website. Everything works fine - almost. The problem is that
the file naming convention of the file I'm retrieving is date stamped
with the date and time the file was created. Here's the naming
convention for files in the outgoing account:
CompanyName_MMDDYY_hhmmss.txt (ie
CompanyName_MonthDayYear_HourMinuteSecond.txt)
Example: FordMotor_102403_150100.txt
Since I retrieve files on a daily basis I obviously know the first
half of the file name, but since I don't know exactly when the file is
created I don't know the 2nd half.
I've tried this without success:
RemoteFile = "SomeCompany_" + mm + dd + yy + "_" + ****** + ".txt"
Here's the full script below:
*************************************************
Option Explicit : Dim LocalDir, FTPaddr, UserName, Password, BaseDir
Dim args, fso, ws, InFile, ftp, OutFile, f, TextFile, ofile, oName
FTPaddr = "ftp.SomeCompany.com"
LocalDir = "D:\Inetpub\CompanyName\Import\"
UserName = "XXXXXXXXX"
Password = "XXXXXXXXX"
Set args = WScript.Arguments
Set fso = CreateObject("Scripting.FileSystemObject")
Set ws = CreateObject("WScript.Shell")
InFile = fso.GetSpecialFolder(2) & "\" & fso.GetTempName
Set ftp = fso.OpenTextFile(InFile, 2, True)
OutFile = fso.GetSpecialFolder(2) & "\" & fso.GetTempName
'--Create the target remote file to look for
Dim mm,dd,yy, RemoteFile
mm = Month(now)
dd = Day(now)
yy = Right(Year(now),2)
if mm < 10 then
mm = "0" & mm
end if
if dd < 10 then
dd = "0" & dd
end if
RemoteFile = "SomeCompany_" + mm + dd + yy + "_" + ****** + ".txt"
LocalDir = LocalDir & RemoteFile
' File nameing convention: SomeCompany_MMDDYY_HRMMSC.txt
Download()
ws.Run "%comspec% /c ftp -i -s:" & InFile & " >" & OutFile, 0, True
Cleanup() 'Release objects and exit
'---------Subs----------------------------------------------------
Sub Download()
With ftp
.WriteLine "open " & FTPaddr
.WriteLine UserName
.WriteLine Password
.WriteLine "binary"
.WriteLine "get "
.WriteLine RemoteFile
.WriteLine chr(34) & LocalDir & chr(34)
.WriteLine "close"
.WriteLine "bye"
.Close
End With
End Sub
Sub Cleanup()
On Error Resume Next
fso.DeleteFile InFile, True
fso.DeleteFile OutFile, True
fso.DeleteFile BaseDir, true
Set args = Nothing
Set fso = Nothing
Set ws = ""
Set ftp = ""
WScript.Quit
End Sub
********************************************
Thanks you kind people !!!!!!!!!!!!!!!!!!
Bill Tag: LoggedOn Tag: 148668
VBscript versions
I am confused about VBscript versions.
As I understand, installing a standard ("vanilla") Windows 2000 or XP I
install WSH 2.0, is it correct?
Should I install VBscript 5.6? Does it mean I install WSH 5.6?
What is the advantage?
Why do version numbers skip from 2.0 to 5.6? Is there anything else between
2.0 and 5.6?
Regards
Marius Tag: LoggedOn Tag: 148666
Retrieving the computer name
Hi guys,
I would like to retrieve the computer name on a whole lot of pcs. The
problem is I cannot use a networking object to retrieve it because some of
the pcs have their network card disabled. I work in retail as a pos support
guy, and we get info from the stores pcs through dialup.
Is there any way to get the host name or computer name of these machines
without doing a query to a network adapter?
Any help greatly appreciated.
I have tried the following:
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled =
True")
For Each objAdapter in colAdapters
Wscript.Echo "Host name: " & objAdapter.DNSHostName
Next
This works for a pc which has their network adapter card enabled, but even
if I change it to FALSE, for disabled card, it does not return it.
Simon
--
---------------------------------------------------------------------
"Are you still wasting your time with spam?...
There is a solution!"
Protected by GIANT Company's Spam Inspector
The most powerful anti-spam software available.
http://mail.spaminspector.com Tag: LoggedOn Tag: 148665
More help! Please.....
Ideally guys, I would like to input the information into the one file, but
all on the same line, with a comma in between each entry.
I would like to do this because I have over 150 systems, and I would like to
get all this information into a spreadsheet.
inventory.bat
cscript //NoLogo .\os.vbs >> .\inventory.txt
cscript //NoLogo .\ip.vbs >> .\inventory.txt
Output of inventory.txt
Microsoft Windows XP Home Edition 5.1.2600
144.136.24.160
What I would like to do is have this:
<computername1>,,,,,,,, Microsoft Windows XP Home Edition 5.1.2600,
144.136.24.160, etc
<computername1>,,,,,,,, Microsoft Windows XP Home Edition 5.1.2600,
144.136.24.160, etc
<computername1>,,,,,,,, Microsoft Windows XP Home Edition 5.1.2600,
144.136.24.160, etc
<computername1>,,,,,,,, Microsoft Windows XP Home Edition 5.1.2600,
144.136.24.160, etc
Add a comma automatically at the end of each script that has run, and also
have the entries automatically inserted on the SAME LINE at the end of the
previously run script..
Why? - to import it into a spreadsheet.
Is there any way to do this guys?
Any help greatly appreciated.
Simon
--
---------------------------------------------------------------------
"Are you still wasting your time with spam?...
There is a solution!"
Protected by GIANT Company's Spam Inspector
The most powerful anti-spam software available.
http://mail.spaminspector.com Tag: LoggedOn Tag: 148662
Adding a delimiter at the end of lines automatically
Hi gurus, Im new to vbscript and would love your help.
I want to build up a text file with different inventory specs.
I run a batch file which runs 2 (so far) vbscripts - very simple stuff (as
follows).
inventory.bat
cscript //NoLogo .\os.vbs >> .\inventory.txt
cscript //NoLogo .\ip.vbs >> .\inventory.txt
Output of inventory.txt
Microsoft Windows XP Home Edition 5.1.2600
144.136.24.160
What I would like to do is have this:
Microsoft Windows XP Home Edition 5.1.2600,
144.136.24.160,
Add a comma automatically at the end of each line.
Why? - to import it into a spreadsheet.
Is there any way to do this guys?
Any help greatly appreciated.
Simon
--
---------------------------------------------------------------------
"Are you still wasting your time with spam?...
There is a solution!"
Protected by GIANT Company's Spam Inspector
The most powerful anti-spam software available.
http://mail.spaminspector.com Tag: LoggedOn Tag: 148661
scrollIntoView not bringing object to top of screen
The script below does what I'm looking for. It finds the first instance of
the current date on the active page, scrolls it into view, and selects it.
However, I'm trying to get the date to be scrolled to the top of the page.
From what I read on MSDN about scrollIntoView, this is supposed to be the
default behavior of the command. However, it only seems to work if the date
is found above what is currently showing on the screen. If the date is
found below whats currently on the screen then the scrollIntoView seems to
default to scrollIntoView(false) with no way to change it (meaning the
object being scrolled to is always at the bottom of the screen). Is there a
workaround that can force it to the top?
By the way, I'm using this to quickly scroll to new posts in a forum I
frequent.
Thanks!
-Jeremy
---------------------------------------------------------------------------
<script language="vbscript">
Dim sDate, oRange
sDate = Right("0" & Day(Date),2) & "-" & Right("0" & Month(Date),2) _
& "-" & Year(Date)
Set oRange = document.body.createTextRange
With oRange
.findText(sDate)
.scrollIntoView(true)
.select
End With
</script>
--------------------------------------------------------------------------- Tag: LoggedOn Tag: 148655
How would you parse the nubers out of this text?
I need to parse out the first number to the immediate left of the
first letter in each of the words. For example, the output would be
2,3,3,3,3
2GreysIceStorm 1093Pnj'sPromenade 31.053Pnj'sPromenade
3Pnj'sPromenade 3Pnj'sPromenade
In this line of text:
4Bob'sHammer 1008Leta'sCharlotte 31.166MaryvilleShep
5Keyless 2GreysIceStorm
The output would be 4,8,6,5,2
Is this possible with vbscript. Is there a way to make a script look
for the first number to the immediate left of any letter? Tag: LoggedOn Tag: 148639
VBScript.Encode Trouble
When using screnc.exe to encode ASP files, the resulting encoded ASP file
produces the following error:
Microsoft VBScript compilation error '800a03ea'
Syntax error
?, line 0
The ASP page is being served on the same server it was encoded on:
Window 2000 Server SP4
VBScript 5.6.8515
Any ideas? Thanks.
-joshua Tag: LoggedOn Tag: 148629
WScript.Shell works as .vbs file, doesn't work as .htm file
When I double-click on the following file saved
as "c:\test.vbs" it works:
Dim wsh
Set wsh = WScript.CreateObject("WScript.Shell")
Wsh.Run("C:\testfile.exe")
When I double-click on the following file saved
as "c:\test.htm", I get RunTime Error "Line 4 Error:
Object required: 'WScript'". Except for the HTML and
SCRIPT lines, the files are identical (I copied and
pasted the code from one to the other).
<HTML>
<SCRIPT LANGUAGE="vbscript" defer>
Dim wsh
Set wsh = WScript.CreateObject("WScript.Shell")
Wsh.Run("C:\testfile.exe")
</SCRIPT>
</HTML>
Why does it work as a .vbs file and not a .htm file?
Thanks in advance. Tag: LoggedOn Tag: 148628
Hex to String???
I've been browsing and I can't seem to find a good way in
vbs to convert a hex to a string. I see a hex() function
that takes a string but I don't see a toString() that
takes a hex vaule.
Can anybody point me to a usefull resource? I'd be more
than happy to work with a conversion table...
thanks, and you guys are great!
-Jess Tag: LoggedOn Tag: 148612
? VBS File Browse Dialog
Hi,
I need a way of browsing for a file (eg: Common Dialog) in a VBS file.
How can I do it?
Thanks a lot.
--
Alec
asoroudi@synetech.cjb.net
Ò Tag: LoggedOn Tag: 148608
CDONTS not sending from invalid email address
Will CDONTS not send emails from an invalid email address? For instance, I
have this code:
?------------------------------------
Set objCDONTS = Server.CreateObject("CDONTS.NewMail")
objCDONTS.From = "blahblahblah@invalidEmailAddress.com"
objCDONTS.To = "myEmailAddress@myDomain.com"
objCDONTS.Subject = "My Subject"
objCDONTS.Body = "Test"
objCDONTS.Send
?------------------------------------
If I know that the 'from address' is not valid, the email will not send.
The routine will complete without a problem, but I will never receive an
email. Why is that? How does CDONTS know if the email address is valid or
not?
The reason I ask is that I get the 'from email address' from a web form, and
the users sometimes (accidentally) give an invalid email address. I still
want the email to send, however. I would like to send it from this persons'
email address (as they entered it).
Can anyone lend a hand? Tag: LoggedOn Tag: 148606
Scroll to specified text in current web page (Client-side)
I'm trying to create a vbscript that will find the current date on the
active web page in IE and then scroll to that location in the page.
All I have so far is the date in the format I'm looking for.
------------------------------------------------------------------
<script language="vbscript">
Dim sDate
sDate = Year(Now) & "-" & Right("0" & Month(Now),2) & "-" & Right("0" &
Day(Now),2)
msgbox sDate
</script>
------------------------------------------------------------------
I was looking into the FindText method on MSDN http://tinyurl.com/x8sn, but
as I'm a rookie in regards to VBScript. I don't even know if I'm barking up
the right tree.
Any help would be great. Thanks!
-Jeremy Tag: LoggedOn Tag: 148605
Change BIOS passwords with VBscript
Hi,
I need a script through which i can change the bios passwords for
all/any of the machines in a network/domain.
Thanks for any kind of help.
Gaurav Tag: LoggedOn Tag: 148598
wscript vs cscript problems
When I run a script I developed with cscript.ext it runs fine, when I run it
with wscript.exe I get the error:
Script: c:\myscript.vbs
Line:124
Char: 2
Error:The hande is invalid
Code: 80070006
Source: (null)
Here is the portion of code that is relavent: What's the difference between
wscript and cscript?
'User Information
Dim strCompName
Dim strUserName
Dim strDomainName
'Main-----------------------
GetUserInfo
'---------------------------
Sub GetUserInfo
Dim ws
Set ws = WScript.CreateObject("WScript.Network")
strCompName = ws.ComputerName <---error here with wscript.exe
strUserName = ws.UserName
strDomainName = ws.UserDomain
End Sub Tag: LoggedOn Tag: 148597
Add a label to Computer Properties General tab?
How can I add a label to the Computer Properties General tab?
(right click on "My Computer" and click "Properties.")
I want to put some information on there about the enterprise build of the PC
configuration.
Currently I am able to only change the Description field on the Computer
Name tab using the following snippet:
Set wscr=CreateObject("WScript.Shell")
Read the registry Value
sReg =
wscr.RegRead("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\lanmanser
ver\parameters\srvcomment")
msgbox sReg,,"Computer Description Information"
Thanks in advance!
David Johnson Tag: LoggedOn Tag: 148595
Problem with sending command to a service
Hi!
I have a problem with sending commands to my service - it simply doesn't
answer...
I used similar code in VB.NET and it responded so service is OK
As well the way of finding service is also right because when I used
StartService method it was started...
I use UserCustomCommand method but instead of 0 (everything is right) it
returns 21(Status Invalid Parameter) and simply I have no idea why...
Please help...
That's the code:
Option Explicit
Dim objWMIService
Dim objSerwisList
Dim objItem
Dim objItema
Dim strserwis
Dim iCommand
Dim return
iCommand = 200
strService = "test"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" + "." + "\root\cimv2")
Set objSerwisList = objWMIService.ExecQuery("Select * from
Win32_Service where Name = '" + strService + "'")
For Each objItem In objSerwisList
return = objItem.UserControlService(iCommand)
MsgBox(return) 'shows "21"
Next Tag: LoggedOn Tag: 148579
string formatting fixed digits
Hello,
I am trying to define or format a variable to a 3 digit
nummeric value. The wanted result sould be like: strNumer
+ 1 = 001, strNumer + 32 = 033 etc. I have tried the
FormatNumer function but this doesn't give the wanted
outcome. Can anybody help me with this?
Thank you for your help... Tag: LoggedOn Tag: 148572
Recurse all files and subfolders of a root folder? Not just the top level
Is it possible to find out the number of files and folders a supplied
folder has?
You know like when go into the properties of a folder it says the
size, number of files and folders in the entire folder (not just the
first level)
As far as I can tell there is not way to get the properties "contains
X files, X folders" Tag: LoggedOn Tag: 148563
How to sink events with the Scripting Control
If I add an object to the MS Scripting Control using the AddObject method
how can I let the script sink events raised by this object?
/J Tag: LoggedOn Tag: 148560
Zipping a text file
I need to compress a text file, dump of database data as SQL statement, for
backup purposes. I know that Windows XP has a built in ZIP application, can
i use this application to zip these dump files, or will i need to use
another application.
Your help is appreciated.
Regards
--
Justin Fowler
Programmer
MizziSoft P/L
Ph: +61 3 9645 7111
Fax: +61 3 9645 7533
http://www.mizzisoft.com
_________________________________________________
This email is subject to professional privilege. If you have received
it in error, any disclosure, copying or use of the contents of this
email is prohibited. If you have received this email in error please
reply to the sender or telephone the sender on +61 3 9645 7111 or fax on
+61 3 9645 7533. Tag: LoggedOn Tag: 148557
Get workgroup/domain name from 32 bit Windows
Hi there,
I need to be able to get the workgroup or domain name
(depending on config of machine) of all our machines
running 32 bit versions of Windows... I know how to get
this info with Win9x up to ME but have had no luck
finding this info in the registry of 32 bit versions.
Anyone got any suggestions? This will need to cover NT4
up to XP....
Any help appreciated...
Cheers Tag: LoggedOn Tag: 148553
Find the Favorites foler size of each user. Number of files and subfolders.
Hi
I've created a script but now I am stuck. Note: I realize that I
have to clean up the code into functions and such. I just want to get
things working first before I clean it up.
The problem I am trying to get an answer to the following:
How do I get all of the number of files and folders of the Favorites
folder.
I'll be moving this from the local PC and getting it to work on a
folder of a server later.
My current code....
'================================================================================================
'|Description:
'|
'| Returns the Profile folders sizes and Favorites folder sizes to a
file - C:\Profile Sizes.txt
'================================================================================================
' Create the File System Object
Set FileSys = CreateObject("Scripting.FileSystemObject")
' Create the text file - Profile Sizes.txt
Set TextFile = FileSys.CreateTextFile("C:\Profile Sizes.txt")
WScript.Sleep(1000)
'Set the folder to get subfolders from...
Set Folder = FileSys.GetFolder("C:\Documents and Settings")
'Get the Subfolder Collection
Set SubFolders = Folder.SubFolders
' Write the Info to a file
TextFile.Write "Folder Size Report " & Now & vbCrLf
TextFile.Write "========================================" & vbCrLf &
vbCrLf
For Each Folder1 in SubFolders
strLine = Folder1.Name & ", Profile=" &
FormatNumber((Folder1.Size/1048576),2) & " MB, "
' Write the Folder Name to a file
TextFile.Write StrLine
'==================================================
' Find out the size of the user's favorites folder in KB
Set UserSubFolders = FileSys.GetFolder(Folder1)
'Get the Subfolder Collection
Set UserFolder = UserSubFolders.SubFolders
' Inside Loop
For Each UserSub in UserFolder
If UserSub.Name = "Favorites" Then
strLine = UserSub.Name & "=" &
FormatNumber((UserSub.Size/1024),2) & " KB"
' Write the Folder Name to a file
TextFile.Write StrLine & vbCrLf
End If
Next
'=================================================
Next
' Close the Text File
TextFile.close
WScript.Echo ("The C:\Folder Sizes.txt Report is Complete!")
OUTPUT
=======
Folder Size Report 11/30/2003 2:12:07 PM
========================================
All Users, Profile=187.48 MB, Favorites=0.00 KB
Default User, Profile=0.34 MB, Favorites=0.00 KB
Jim, Profile=888.97 MB, Favorites=78.83 KB
Joy, Profile=312.24 MB, Favorites=9.41 KB
LocalService, Profile=1.87 MB, Favorites=0.12 KB
NetworkService, Profile=0.48 MB, Tag: LoggedOn Tag: 148548
Read News from an NNTP Server
Hi !
Is possibile via VBscript access an NNTP server to read news whitout install
dedicated components ??
Tanks in advance Tag: LoggedOn Tag: 148546
CopyHere VBScript method working on Windows 2000, but not on XP...
Hello,
I am trying to copy the contents of one folder to another using the
following VBScript code:
set SA = CreateObject("Shell.Application")
set FolderObj = SA.NameSpace("C:\temp")
FolderObj.CopyHere "C:\HLCache\*.*" , 16+512
The thing is, in Windows 2000, this code works fine, the progress dialog
appears and copies the files in the right place. I am running WSH 5.6 on
that system. But in Windows XP, I receive this error message:
C:\DOCUME~1\Robert\LOCALS~1\Temp\~shlcpy.vbs(3, 1) Microsoft VBScript
runtime er
ror: Object required: 'FolderObj'
I am also running WSH 5.6 on Windows XP. The same message appears for other
Windows XP machines I have too. I need to use the CopyHere method as this is
the only way I can have a progress indicator. But why would it work on
Windows 2000 and not in XP?
Please can someone help me!
Robert Tag: LoggedOn Tag: 148545
Format string as hyperlink
The following outputs from an access database. Its simply a string
representing a hyperlink. When it is displayed I want it to display as a
hyperlink and open in a new window:
<td><%=(rsLinks.Fields.Item("url").Value%></td>
what is the correct format for doing this?
John Kostenbader Tag: LoggedOn Tag: 148537
Changing IE-settings
Hi,
is it possible to change the security options of Internet Explorer by a
VBScript?
I usually run the IE with security level set to high in the Internet Zone
but some sites require medium level. My preferred solution would be to make
the change via a button within the IE itself.
Any ideas?
Ingo Tag: LoggedOn Tag: 148536
Script date
Hi all,
I tried an example script vbs that it changes the short date to extended
date, example 30/11/2003 to Sun 23 November 2003.
Thanks Tag: LoggedOn Tag: 148527
Convert numerics into date & time
These are coming from a w2k box, how do I conver to a valid date.
InstallDate: 20020911065353.000000+600
LastBootUpTime: 20031130004708.000000+660
LocalDateTime: 20031130185325.627000+660
Don Tag: LoggedOn Tag: 148524
The subject parameter has a Time Out. What is the
scipting to control the Time Out Parameter?