using vbscript with a dictionary object
I have an asp application that uses vbscript. There is a dictionary object
that is included in this application.
I want to be able to see all the members that are part of a dictionary
object. Thus I have the following questions:
1. What do I need to do to be able to see the count of the number of
members included in the dictionary object?
2. What can I do to see what is included in each member of the dictionary
object? In other words, I would like to all the data contained in each
occurence of the dictionary object. Tag: filepost.asp Tag: 171694
VBScript and "positional arguments" in VBA object methods
Hello!
I have a problem with the VBScript syntax. I found this
here in this group:
"---VBA supports named argument syntax (e.g., ArgName:="argvalue") in
method calls. In WSH hosted VBScript, you have to code all arguments
as positional arguments since named argument syntax is not supported."
It describes exactly my problem. But what is the syntax of those
"positional arguments" in VBScript / WSH ?
The following code from Excel VBA is:
Sheets("Tabelle2").Select
Sheets("Tabelle2").Move After:=Sheets(3)
There are three sheets in an Excel workbook with the names
"Tabelle1", "Tabelle2" and "Tabelle3".
The code above just moves the second sheet from the second
position to the last, in VBA.
But what code do I have to write in VBScript ?
What is the syntax in VBScript when the method of the
Excel.Application object awaits an named argument named "After" ?
Thanks for any help!
Best Regards,
Gernot Mulisch Tag: filepost.asp Tag: 171691
Return Serial Number of connected USB printer
Any ideas on the possibility of retunring an attached printers serial
number? All printers in the case would be HP, connected via USB Tag: filepost.asp Tag: 171690
find and replace horizontal tab
hi,
i'm trying to write a replace statement and I'm having a problem.
the string is
"canon\tpowershot a290\t...."
i want to replace every \t with a horizontal tab.
i have it as
str = replace(string, "\t", chr(11))
this doesn't seem to work since I don't think i have the write ascii code
for a horizontal tab.
please advise.
rafael Tag: filepost.asp Tag: 171686
First Time with VBScript
I'm trying to start a session in Access2003 using VBScript. I have no
knowledge of VBScript at all. To make it short I trying to use VBScript to
set the security level to low to stop an blocking unsafe procedures error
message. I have found the following code at a web sight
Set o = CreateObject("Access.Application")
o.AutomationSecurity = 1 ' set macro security LOW.
o.OpenCurrentDatabase "full path to your database"
o.UserControl = True
Set o = Nothing
I've been told if I create a file with this in it and use that file as a
short to start Access it will work. Well, the basic question is how do I
create the file? Do I need certain software to create a VBScript file? Can
I do it in Access or maybe Visual Basic? I have both.
Thanks for the help Tag: filepost.asp Tag: 171685
Windows domain login scripts
Hello all,
As a new to this group, I would like to know any sources for login
scripts to be used in AD. Need to implement some in an test enviroment...
Thanks in advance,
Taavi Sepp Tag: filepost.asp Tag: 171678
Syntax to run multiple commands in a single shell
I have a vbs file that usese a wscript shell to modify registry keys on a
remote machine. It works fine if I have the shell only change one key, but
as soon as I try to change multiple keys in the same shell it simply doesn't
work.
Here's what works:
regforce = "reg add ""\\" & strIP & "\HKLM\SOFTWARE\Microsoft\Windows NT\" &
_
"CurrentVersion\Winlogon"" /v ForceAutoLogon /t REG_SZ /d 1 /f"
objShell.Run regforce,0
Here's what doesn't work:
regboth = "reg add ""\\" & strIP & "\HKLM\SOFTWARE\Microsoft\Windows NT\" &
_
"CurrentVersion\Winlogon"" /v ForceAutoLogon /t REG_SZ /d 1 /f" & _
"reg add ""\\" & strIP & "\HKLM\SOFTWARE\Microsoft\Windows NT\" & _
"CurrentVersion\Winlogon"" /v AutoAdminLogon /t REG_SZ /d 1 /f"
objShell.Run regboth,0
When I try running regboth, neither key gets modified. But if I run either
'reg add' statement by itself it works fine, so the problem seems to be in
the way I'm combining the two statements. I know the '&' character is
supposed to allow multiple commands to be run from a single shell, but it
just isn't working. Anyone know what I'm doing wrong?
Thanks in advance for any help with this... Tag: filepost.asp Tag: 171675
Sending Post form using ITC
Hi all
Having a very FRUSTRATING time trying to pass an html form through the
Internet Transfer Control.
Can someone tell me what I'm doing wrong.
HTML = "<FORM> method=GET name=form1" '
HTML = HTML & "<INPUT type=hidden value=116717 name=instId>"
HTML = HTML & "<INPUT type=hidden value='" & mvarCartID & "'
name=cartId>"
HTML = HTML & "<INPUT type=hidden value='" & mvarTestMode & "'
name=testMode>"
HTML = HTML & "<INPUT type=hidden value=USD name=currency>"
HTML = HTML & "<INPUT type=hidden value='" & mvarDesc & "' name=desc>"
HTML = HTML & "<INPUT type=hidden value='" & mvarCost & "' name=cost>"
HTML = HTML & "<INPUT type=hidden value='" & mvarAuthPW & "'
name=authPW>"
HTML = HTML & "<INPUT type=hidden value='" & mvarBuyerAddress & "'
name=address>"
HTML = HTML & "<INPUT type=hidden value='" & mvarBuyerPostal & "'
name=postcode>"
HTML = HTML & "<INPUT type=hidden value='" & mvarBuyerCountryCode & "'
name=country>"
HTML = HTML & "<INPUT type=hidden value='" & mvarBuyerPhone & "'
name=tel>"
HTML = HTML & "<INPUT type=hidden value='" & mvarBuyerEmail & "'
name=email>"
HTML = HTML & "<INPUT type=hidden value='" & mvarCCCardNo & "'
name=cardNo>"
HTML = HTML & "<INPUT type=hidden value='" & mvarExpMonth & "'
name=cardExpMonth>"
HTML = HTML & "<INPUT type=hidden value='" & mvarExpYear & "'
name=cardExpYear>"
HTML = HTML & "<INPUT type=hidden value='" & mvarCardIssueNo & "'
name=cardIssueNo>"
HTML = HTML & "<INPUT type=hidden value='" & mvarBuyerName & "'
name=cardName>"
HTML = HTML & "</FORM>"
Form1.Inet1.Execute URL, HTML
I've also tried to use the "POST", and other combinations.
The message I get back from the site is the same as if I omit the HTML
variable from the Execute.
Thanks
Richard
--
JRWakefield Tag: filepost.asp Tag: 171670
YYYYMMDD
How can I validate a numeric data from database against this format
YYYYMMDD?
I have this data in database 19990120 and I'd like to make sure that the
four digit represents the year and the preceding 2 digits represents the
month and .....
Thanks Tag: filepost.asp Tag: 171660
Script for Q311218
I am curious if it is possible to script the modifications referenced in
Q311218. This is not a simple export/import of a registry key, but rather a
modification to a key on each computer due to GUID references.
Thanks,
Bob Tag: filepost.asp Tag: 171657
Height of window
I am using T Lavedas' WSH Scripts for msgbox function. I want to dymanically
set the height of the "mgsbox" based upon the contents.
Can anyone tell me how?
Thanks,
dra Tag: filepost.asp Tag: 171656
simple text encrypt / decrypt
Hello all. Anyone have a simple VBScript that will take input and
encrypt it and/or decrypt it? Tag: filepost.asp Tag: 171653
Remote logoff - is it possible?
Is it possible to do remote logoffs on winxp clients without using wmi?
The reason I don't want to use wmi is that wmi fails if the wbem\repository
directory becomes corrupt, which it does from time to time. Tag: filepost.asp Tag: 171649
Connect to DB
Hi
Does anybody know how I can connect to a database from a script without
having to configure ODBC or install any software?
I plan to run the script on Windows 2000 Pro and Win XP machines.
Regards
Wayne Tag: filepost.asp Tag: 171642
printer changes
All,
I am looking for a simple script to remap domain printers. i need to
determine what printers from server ABC are installed and replace them with
identical printers from server XYZ. Can this be done easily? and can
anybody point me in the right direction?
many thanks. Tag: filepost.asp Tag: 171639
Start and manipulate a web page via vbscript remotely
Hello group, the following requirement to programatically control
device/s via VBScript may interest many experiencing similar
issues....
Background:
Cable modem - connected to ISP. Router - connected between Cable Modem
& LAN.
Problem:
ISP continually has network issues and requires End-User to restart
Cable modem and then the Router. Although inconvenient, this is OK if
End User is on site at the time.
Question for Group;
Taking into account the above information, can I perform the following
programatically with VBScript:
1. Connect to the cable modem's web page and select the "Reboot"
button from a LAN W2K3 PC/server?
2. Connect to the Router's web page, supply credentials and select the
"Restart" button from a LAN W2K3 PC/server?
Note: I have a scheduled job executing a VBScript that monitors the
Cable connection to the ISP. When this script detects that the
connection is down, I want the proposed "Restart" Script to run. This
script must be able to be run without having an End User log on to run
the script.
This may be asking too much, any Ideas greatly appreciated......
Cheers Tag: filepost.asp Tag: 171628
Call a batch file from a vbs script
I am new to vbs and need some help. Can anyone give me a sample of how
you can call a batch file from within a .vbs script? This is going to
be used in a workgroup enviroment.
Thanks for you help and time
Jason Tag: filepost.asp Tag: 171625
Can you use a vbs script in a non domain environment?
I have about 300 laptops that do not belong to a domain. I would like
to find a way of running a vbs login sript to call a batch file. All
of the vbs scripts that I can find are for domains. We would like to
be able to leave the batch file empty most of the time, but have the
option of pushing configurations thru the batch file by adding to the
batch file. I realize that if we were on a domain this could be all
done thru group policy, but we are not. I also realize that I could
add a shortcut to the startup folder that would point to the batch
file, but then it could be removed very easily.
Any help would be greatly appreciated.
Jason Tag: filepost.asp Tag: 171624
order array..... and sorry
Excuse me for my last post, in spanish language. Is a mistake. Sorry.
You know if an array can order its elements?
Thanks! Tag: filepost.asp Tag: 171614
¿Ordenar un array?
Hola,
conoceis algún método en VBS para ordenar un array?.....o si no es un
array..... algún método de ordenación sea lo que sea? ;) Gracias Tag: filepost.asp Tag: 171613
Add to Public Folder Favorites?
I am new to trying to script with Outlook, but what I am doing is
trying to add a specific folder to the Public Folders FAVORITES. Below
is my code. When I run it, Outlook locks up...I close Outlook and I
get the error "Remote Procedure Call Failed". Any ideas?
AddToFavorites
Sub AddToFavorites()
'Adds a Public Folder to the list of favorites
Dim olapp
Dim objFolder, newfolder
set olapp = CreateObject("Outlook.Application")
set objFolder = olapp.GetNameSpace("MAPI")
Set objFolder1 = objFolder.Folders("Public Folders").Folders("All
Public Folders").Folders("Office Locations")
Set newfolder = objFolder1.AddToPFFavorites
End Sub Tag: filepost.asp Tag: 171611
VBS to list groups/users and authorities on a shared folder
Hi,
Trying to comply with some SOX stuff.
I need to come up with a list of shared folders, users or groups, and rights.
I can get the list of shared objects using objWMIService.ExecQuery("Select *
from win32_Share"). This generates a list of shared objects on our 2000 or
above computers. It's a start.
Is there anything generic to both NT and 2000+ ?
Also how would I take the "objShare's" in the query and get the list of
users and rights?
Thanks for any help.
Vance Tag: filepost.asp Tag: 171610
How determine if a process + window name is up & running
This is a multi-part message in MIME format.
------=_NextPart_000_00EA_01C52897.FE5D3060
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi everyone,
How can I determine if a process + window name is up & running, like =
"Winzip - SomeExcelFile.xls"?
Using WMI (Win32_Process) I can find out if Winzip is running but what I =
want to do is to have my script wait until a specific instance of Winzip =
(compressing TO a specific file) is still processing or not.
Can it be done at all?
Thanks in advance.
Joseph
philippeoget at hotmail dot com
http://www.geocities.com/philippeoget/a2z/
------=_NextPart_000_00EA_01C52897.FE5D3060
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2523" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi everyone,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>How can I <FONT size=3D2>determine if a =
process +=20
window name is up & running, like "Winzip -=20
SomeExcelFile.xls"?</FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Using WMI (Win32_Process) I can find =
out if Winzip=20
is running but what I want to do is to have my script wait until a =
specific=20
instance of Winzip (compressing TO a specific file) is still processing =
or=20
not.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Can it be done at all?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks in advance.</FONT></DIV><FONT =
face=3DArial=20
size=3D2>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Joseph</DIV>
<DIV> </DIV>
<DIV>philippeoget at hotmail dot com<BR><A=20
href=3D"http://www.geocities.com/philippeoget/a2z/">http://www.geocities.=
com/philippeoget/a2z/</A></FONT></DIV></BODY></HTML>
------=_NextPart_000_00EA_01C52897.FE5D3060-- Tag: filepost.asp Tag: 171604
ActiveScriptEventConsumer/WMI Permanent Event Subscription
I am trying to get a vbScript to fire off when a particular registry entry
changes using the ActiveScriptEventConsumer.
I have created the instances of __EventFilter, __EventConsumer and
__FilterToConsumerBinding and can see them using CIM studio but nothing
appears to happen when the entry changes.
The event query works as a tempoary subscription, but I need to get it
working as a permanent subscription.
Here's the code I used for creating the classes
Set objSWbemServices = GetObject("winmgmts:root\cimv2")
Set objEventFilterClass = objSWbemServices.Get("__EventFilter")
Set objEventFilter = objEventFilterClass.SpawnInstance_()
objEventFilter.Name = "MonitorVPNStatus"
objEventFilter.QueryLanguage = "WQL"
objEventFilter.Query = _
"SELECT * FROM RegistryValueChangeEvent WITHIN 5 " _
& "WHERE Hive='HKEY_LOCAL_MACHINE' AND " _
& "KeyPath='SOFTWARE\\CheckPoint\\SecuRemote\\Status' " _
& "AND ValueName='ClientConnected'"
objEventFilter.Put_()
Set objConsumerClass = objSWbemServices.Get("ActiveScriptEventConsumer")
Set objConsumer = objConsumerClass.SpawnInstance_()
objConsumer.Name = "VPNScript"
objConsumer.ScriptFileName = "C:\Windows\VPNScript.vbs"
objConsumer.ScriptingEngine = "VBScript"
objConsumer.Put_()
Set objBindingClass = objSWbemServices.Get("__FilterToConsumerBinding")
Set objBindingInstance = objBindingClass.SpawnInstance_()
objBindingInstance.Filter = "MonitorVPNStatus"
objBindingInstance.Consumer = "VPNScript"
objBindingInstance.Put_()
Any help would be most greatly appreciated Tag: filepost.asp Tag: 171601
monitor file deletion
is there a script that can tell me whenever a file/folder is deleted or moved
from a network shared drive.
the script should give the following details
name of file/folder removed or moved
when it was deleted
who deleted (ie windows username of user who deleted the file)
from which PC (PC name) the file was deleted
the PCs are in a domain Tag: filepost.asp Tag: 171597
assign array to a variable
This is a multi-part message in MIME format.
------=_NextPart_000_000A_01C52883.E800CAC0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi,
The following code query the IP address of enabled NIC cards, how do I =
assign the IPConfig.IPAddress(i) to another variable and Echo the output =
later on(not within FOR... EACH... NEXT)?=20
The IPConfig.IPAddress(i) seems like an array, you help is greatly =
appriciated.
Thanks
Frank
strComputer =3D "."
Set objWMIService =3D GetObject("winmgmts:" _
& "{impersonationLevel=3Dimpersonate}!\\" & strComputer & =
"\root\cimv2")
Set IPConfigSet =3D objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where =
IPEnabled=3DTRUE")
=20
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then=20
For i=3DLBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
WScript.Echo IPConfig.IPAddress(i)
Next
End If
Next
------=_NextPart_000_000A_01C52883.E800CAC0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1491" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>The following code query the IP address =
of enabled=20
NIC cards, how do I assign the IPConfig.IPAddress(i) to another variable =
and=20
Echo the output later on(not within FOR... EACH... NEXT)? </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>The IPConfig.IPAddress(i) seems like an =
array, you=20
help is greatly appriciated.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Frank</DIV>
<DIV><BR></DIV></FONT>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>strComputer =3D "."<BR>Set =
objWMIService =3D=20
GetObject("winmgmts:" _<BR> &=20
"{impersonationLevel=3Dimpersonate}!\\" & strComputer &=20
"\root\cimv2")<BR><BR>Set IPConfigSet =3D objWMIService.ExecQuery=20
_<BR> ("Select * from =
Win32_NetworkAdapterConfiguration Where=20
IPEnabled=3DTRUE")<BR> <BR>For Each IPConfig in =
IPConfigSet<BR> =20
If Not IsNull(IPConfig.IPAddress) Then=20
<BR> For =
i=3DLBound(IPConfig.IPAddress)=20
to UBound(IPConfig.IPAddress)</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbs=
p; =20
WScript.Echo =
IPConfig.IPAddress(i)<BR> =20
Next<BR> End If<BR>Next<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> </DIV></FONT></BODY></HTML>
------=_NextPart_000_000A_01C52883.E800CAC0-- Tag: filepost.asp Tag: 171594
Changing security settings on registry keys and folder with script?
X-posted to:
microsoft.public.scripting.wsh;
microsoft.public.scripting.vbscript
Hi everyone!
System is Windows XP Pro pcs on a Server 2003 Domain. I need to give normal
users (either groups "everyone" or "users") write access to certain registry
keys (and sub keys) and folders (and subfolders). Basically, critical apps need
admin rights by default, which we are not going to give. :-)
I have to do this on many pcs, so think a script would be easiest. I have
downloaded the TechNet Script Center package, but haven't found a template
suitable for either application.
Could someone please advise on what commands I need, or privide some template
examples. If so, I'd really appreciate it. Any help or tips appreciated too. :-)
Many thanks in advance.
grol Tag: filepost.asp Tag: 171587
When is 'IsBrowseable' True?
I was checking out various folderitem properties:
http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference/=
objects/folderitem/folderitem.asp
and found that the following code in a .vbs file:
'-----------------------------------------
Set oAppShell =3D CreateObject("Shell.Application")
set oFolder =3D oAppShell.BrowseForFolder(0, "Choose a Folder", 0)
msgbox "IsBrowsable =3D " & oFolder.Self.IsBrowsable,,oFolder.Self.Name
'For each oItem in oFolder.Items
' With oItem
' If .IsFolder then msgbox "IsBrowsable =3D " & .IsBrowsable,,.Name
' end with
'Next
'-----------------------------------------
will always show "False"???
Can anyone explain this to me?
Thank you,=20
Keith Tag: filepost.asp Tag: 171582
Start windows program from a script
Please can some one point me in the right direction.
I want to start notepad to show a txt file, from within a vbscript.
thanks in advance
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! Tag: filepost.asp Tag: 171576
URL re-writing in classic ASP
I want to automagically rewrite a url like:
www.blah.com/index.asp?client=123
to
www.blah.com/jonnyD
What's the best approach to this using classic ASP?
Do I need a 3rd party component or can this be done using IIS?
(don't mind paying for something if it works better)
Thanks,
Peter
--
"I hear ma train a comin'
... hear freedom comin" Tag: filepost.asp Tag: 171572
TradeDoubler
this might be a wild shot, but has anyone here had experience of
implementing TradeDoubler code on their site?
The tech support staff are unhelpful at best
--
"I hear ma train a comin'
... hear freedom comin" Tag: filepost.asp Tag: 171571
unable to access
hello i have the same code in VBscript end in Javascript. in VBScript
everithing is ok but in javascript i can't access to the server. any
suggest?
VBScript
......
Set Locator = CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer( server,
"root\SMS\site_XXX","DOMAIN\administrator","password")
Set Users = Service.ExecQuery("Select * From SMS_R_User WHERE Name LIKE ""%"
+ username + "%""")
.......
JavaScript
.................
var Locator = new ActiveXObject("WbemScripting.SWbemLocator");
var Service =
Locator.ConnectServer("server","root\SMS\site_XXX","DOMAIN\administrator","p
assword");
var Users = Service.ExecQuery("Select * From SMS_R_User WHERE Name LIKE ""%"
+ username + "%""");
-->
.................. Tag: filepost.asp Tag: 171570
problem running a dos cmd from a VBS file
I have a problem trying to run a DOS cmd and redirect the output to a text
file.
The code below only works as far as the Messages Boxes display the correct
information, ie. the paths are correct,
but not test.txt file is being created!
The purpose is to catch the output from a reverse DNS Lookup tool
"zwhois.exe.
Eventually, I want to run this code from either a VBS file or a web page,
and display the result on screen, rather than having to run the cmd from a
DOS prompt
The DOS exe file can be downloaded from here:
http://www.zoneedit.com/doc/code/zwhois.exe
' whois.vbs which resides in the same folder as the exe file
Dim objWHShell
Dim scriptPath
Dim exeFile
Dim txtFile
Dim Cmd
' scriptPath is returned with a "\" appended at the end
scriptPath = Left(WScript.ScriptFullName,Len(Wscript.ScriptFullName) -
Len(Wscript.ScriptName))
exeFile = scriptPath & "zwhois.exe -v 217.233.242.39 >> " ' -v = verbose
followed by the IP to query
txtFile =scriptPath & "test.txt"
Cmd = exeFile & txtFile
' MsgBox exeFile
' MsgBox txtFile
' MsgBox Cmd
RunFile Cmd
Sub RunFile(CmdToRun)
On Error Resume Next
Set objWHShell = CreateObject("Wscript.Shell")
objWHShell.Run Chr(34) & CmdToRun & Chr(34)
Set objWHShell = Nothing
End Sub
--
Many Thanks in advance guys
Joseph
philippeoget at hotmail dot com
http://www.geocities.com/philippeoget/a2z/ Tag: filepost.asp Tag: 171563
Can WINNT:// or Winnmgnts: read accounts from a domian controller?
I use Torgeir Bakken's script ( modified) to query only local administrator
on servers
(NT/win2k/win2k3). However, when a remote server is a domain controller,
I get the information of the domain enterprise administor account, instead
of the local administrator. I think I should not get anything on a remote DC
since SAM is looked out on a DC.
Why?
Also I try to use example 2 to query all local user accounts. Again, when a
remote server is a domain controller, I get all domain user accounts out.
Why?
**********Example 1 Begin **********
On Error Resume Next
strComputer = Wscript.Arguments(0)
strComputerNo = Wscript.Arguments(1)
Set objWMIService = GetObject("winmgmts:{impersonationlevel=impersonate}!\\"
& strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_UserAccount")
If Err <> 0 Then
Wscript.Echo strComputerNo & "," & strComputer & "," & Err.number & "," &
Err.Description
Wscript.Quit
End If
For Each objItem in colItems
' determine local administrator name by its SID
'If Left(objItem.SID, 9) = "S-1-5-21-" AND Right(objItem.SID, 4) =
"-500" Then
Wscript.Echo strComputerNo & "," & strComputer & "," & _
"Local administrator name:" & objItem.Name & "," & _
"Account Type: " & objItem.AccountType & "," & _
"Caption: " & objItem.Caption & "," & _
"Description: " & objItem.Description & "," & _
"Disabled: " & objItem.Disabled & "," & _
"Domain: " & objItem.Domain & "," & _
"Full Name: " & objItem.FullName & "," & _
"Lockout: " & objItem.Lockout & "," & _
"Password Changeable: " & objItem.PasswordChangeable & "," & _
"Password Expires: " & objItem.PasswordExpires & "," & _
"Password Required: " & objItem.PasswordRequired & "," & _
"SID Type: " & objItem.SIDType & "," & _
"Status: " & objItem.Status
'Exit For
'End If
Next
**********Example 1 End **********
**********Example 2 Begin **********
Set objNetwork = CreateObject("Wscript.Network")
strComputer = Wscript.Arguments(0)
'strComputer = objNetwork.ComputerName
Set colAccounts = GetObject("WinNT://" & strComputer & "")
colAccounts.Filter = Array("user")
For Each objItem In colAccounts
Wscript.Echo strComputer & "," & _
objItem.Name & "," & _
objItem.Description
Next
**********Example 2 End **********
"Torgeir Bakken (MVP)" <Torgeir.Bakken-spam@hydro.com> wrote in message
news:OT8lFxoIFHA.2356@TK2MSFTNGP12.phx.gbl...
> Wensi Peng wrote:
>
> > Is it possible to change the password of the local administrator
> > with GPO too?
> Hi
>
> You could do it in a computer startup script (with a GPO) that runs
> as part of the boot up process (before the user logs in).
>
> More here:
>
http://groups.google.co.uk/groups?selm=ewm7dAwCFHA.3740%40TK2MSFTNGP09.phx.gbl
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx Tag: filepost.asp Tag: 171560
IE Trusted Sites
Not sure if wirting a script for this purpose is the easiest way to go...
But it's always fun to do so, especially, when you get it going :- )
Anyway, basically, we have a vbs script that inputs a list of trusted sites
both for Internet, Local Intranet, and Trusted Sites (all under the Security
Tab).
It works very well as far as its purpose...
However, the annoying part though is that, after applying these parameters,
whenever an access goes through any of the sites on the list and then
redirects to another domain name, say, *.yahoo.com, it always ask if I wuld
like to allow access to the redirected site.
What I would like to accomplish is to get rid of this message and just let
me through the redirected page.
A script to do this?Or maybe just a quick registry change on the local system?
I'll take any approach (he-he-he).
Thank you so much :- )
Newbie
ar11z4404@hotmail.com Tag: filepost.asp Tag: 171558
Pulling the first record
I trying to use it to perform a task. Here is an example
Got this from Script-O-Matic. My question involves only pulling certain
records from colItems, I am looking to pull the first record of the query.
****
This is the part that displays the results. For example, this will display
5 records. I only want the first one
For Each objItem In colItems
WScript.Echo "GroupComponent: " & objItem.GroupComponent
WScript.Echo "PartComponent: " & objItem.PartComponent
WScript.Echo
Next
****
Any assistance that you can provide is much appreciated.
Here is the entire code
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
arrComputers = Array("FAMILY")
For Each strComputer In arrComputers
WScript.Echo
WScript.Echo "=========================================="
WScript.Echo "Computer: " & strComputer
WScript.Echo "=========================================="
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM
Win32_GroupInDomain", "WQL", _
wbemFlagReturnImmediately +
wbemFlagForwardOnly)
For Each objItem In colItems
WScript.Echo "GroupComponent: " & objItem.GroupComponent
WScript.Echo "PartComponent: " & objItem.PartComponent
WScript.Echo
Next
Next Tag: filepost.asp Tag: 171557
Script to control/allow access to the Internet but allow Intranet
Would anyone have a ready script or any info on writing a vbscript that will
set a given system's (XP or 2000) Internet Explorer browser to work this way:
Specific username (i.e. JDOE - may have admin rights or not on the local
system)
- Allow ONLY access to the Intranet (but not Internet access)
- Completely no access to the Internet Explorer application at all
Adminstrator(not the group)
- Allow full access/use of the application for Internet and Intranet use.
Thanks in advanced for any info you can provide.
Newbie
ar11z4404@hotmail.com Tag: filepost.asp Tag: 171556
can't get nbtstat to work using shell script in WINXP
I found a script on this site to get the users MAC address using
nbtstat. Here's the script:
Function GetMACAddress(ByVal strIP) As String
Dim net = CreateObject("wscript.network")
Dim sh = Server.CreateObject("wscript.shell")
sh.run("%comspec% /c nbtstat -A " & strIP & " >
c:\inetpub\wwwroot\test\mac\" & strIP & ".txt", 0, True)
sh = Nothing
Dim fso = CreateObject("scripting.filesystemobject")
Dim ts = fso.opentextfile("c:\inetpub\wwwroot\test\mac\" &
strIP & ".txt")
Dim MacAddress As String
Dim Data As String
Do While Not ts.AtEndOfStream
Data = UCase(Trim(ts.readline))
If InStr(Data, "MAC ADDRESS") Then
MacAddress = Trim(Split(Data, "=")(1))
Exit Do
End If
Loop
ts.close()
ts = Nothing
fso.deletefile("c:\inetpub\wwwroot\test\mac\" & strIP &
".txt")
fso = Nothing
GetMACAddress = MacAddress
End Function
My problem is that the file created is 0kb. I can't figure out why
the script doesn't run properly. I tried replacing the nbtstat
command with a dir command, and that works fine. Any ideas?It only
happens in WINXP.The script works in win2000.Is there any permission
issue?
Thanks! Tag: filepost.asp Tag: 171555
sql
is this a right place to ask question about interfacing vbscript and
ms-sqlserver scheduled jobs?
i'd like to use external vbscript task to check [running] status of
scheduled jobs on
sql database, to see is particular job running, and may it be forced to
start or stop.
do i need some special component or is all allready bilt in into sql server?
thanks for comments. Tag: filepost.asp Tag: 171547
Script for Folder View Customization - Beta
This is a multi-part message in MIME format.
------=_NextPart_000_01A3_01C526AA.CB4F12E0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi all,
I've written this script to allow users to customize a view for a =
folder and then apply to all the subfolders. I thought I'd post it here =
first for comments and suggestions. It's not very robust with error =
handling :). It will hang if it runs into a folder with access denied. =
Can the gurus here take a look and help me tweak it before posting to =
the customize and music folk? I'm especially wondering about how to =
handle the timing in the OpenAndCloseSubfolders function. The loop I =
have now seems to be faster than using a sleep statement. I've left in =
a msgbox reporting execution time for the function which I plan to take =
out before the big rollout :)
Thanks to all ,
Keith
P.S. I know some people hate it, but I'm attaching the file as text as =
well because of line-wrapping concerns.
##########################################################
Const conBagMRUPath =3D =
"HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\BagMRU"
Const conBagsPath =3D =
"HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags"
Const conFolderStreams =3D =
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Streams\Defaults=
\{F3364BA0-65B9-11CE-A9BA-00AA0=AD04AE837}"
Const ForReading =3D 1
dim oAppShell, oScriptShell, oFso, oFolder
dim VPathCollection ()
dim sIntroMsg, sScriptTitle, sIntro2, sSetView
'Instructions & Warnings
InitMsgStrs
If (msgbox(sIntroMsg, vbYesNo, sScriptTitle) <> vbYes) Then
WScript.Quit
End If
If (msgbox(sIntro2, vbYesNo + vbCritical, sScriptTitle) <> vbYes) Then
WScript.Quit
End If
'Assign objects
Set oAppShell =3D CreateObject("Shell.Application")
Set oScriptShell =3D CreateObject("WScript.Shell")=20
Set oFSO =3D CreateObject("Scripting.FileSystemObject")
'Verify other windows are closed
Do While oAppShell.windows.count <> 0
If (msgbox(oAppShell.windows.count & " Explorer/I.E. windows are =
still open!", _
vbRetryCancel + vbCritical, sScriptTitle) <> vbReTry) Then
WScript.Quit
End If
Loop
'Back up the Registry Keys
Call RegExport(conBagMRUPath, "BagMRU Backup.reg")
Call RegExport(conBagsPath, "Bags Backup.reg")
DeleteBagsAndIncreaseLimit
'If conFolderStreams exists,it screws up the
' default columns for detail view of special folders. So...
On Error Resume Next
oScriptShell.RegDelete conFolderStreams
Err.Clear
On Error Goto 0
iNewBagCount =3D 0
bContinue =3D True
iLoopCount =3D 0
Do While bContinue '*** The Fun Starts Here ***
iLoopCount =3D iLoopCount + 1
set oFolder =3D oAppShell.BrowseForFolder(0, "Choose a Folder", 0)
oAppShell.Open oFolder
WScript.Sleep 1000
msgbox sSetView,,oFolder.title & " - Script Paused..."
oAppShell.windows.item.quit
iNewBagCount =3D iNewBagCount + 1
ReDim Preserve VPathCollection(iLoopCount - 1)
VPathCollection(iLoopCount - 1) =3D VPath(oFolder)
sFolderTemplateFile =3D MakeFolderTemplate(iNewBagCount)
RegImport sFolderTemplateFile
sStart =3D Now
iNewBagCount =3D iNewBagCount + OpenAndCloseSubfolders(oFolder)
MsgBox "Finished in " & DateDiff("s", sStart, Now) & " seconds", _=20
vbSystemModal, "OpenAndCloseSubfolders"
oFso.GetFile(sFolderTemplateFile).Delete
oScriptShell.RegDelete(conBagsPath & "\AllFolders\Shell\")
oScriptShell.RegDelete(conBagsPath & "\AllFolders\")
msg =3D "You have saved views for the following folder(s):" & vbCrLf
For each sPath in VPathCollection
msg =3D msg & vbTab & sPath & vbCrLf
Next
msg =3D msg & "You have saved views for " & iNewBagCount & " folders =
(8000 max)" & vbCrLf
msg =3D msg & vbCrLf & "Would you like to do another folder?"
bcontinue =3D msgbox (msg, vbYesNo) =3D vbYes
Loop
Set oAppShell =3D Nothing
Set oScriptShell =3D Nothing
Set oFSO =3D Nothing
'---------------------------------------End------------------------------=
-----
Function MakeFolderTemplate (iBagNum)
Dim sTemplateRegPath, sTemplateFileName, sFolderTemplate, ts
sTemplateRegPath =3D conBagsPath & "\" & iBagNum
sTemplateFileName =3D "Folder Template" & iBagNum & ".reg"
sFolderTemplate =3D RegExport (sTemplateRegPath, sTemplateFileName)
'msgbox sFolderTemplate
Set ts =3D oFso.OpenTextFile(sFolderTemplate, ForReading)
sTemplateInfo =3D ts.ReadAll
ts.close
sSearch =3D "Bags\" & iNewBagCount
sReplace =3D "Bags\AllFolders"
sTemplateInfo =3D Replace (sTemplateInfo, sSearch, sReplace, 1, 2)
sTemplateInfo =3D Replace (sTemplateInfo, "My", "")
Set ts =3D oFso.CreateTextFile (sFolderTemplate, true)
ts.Write sTemplateInfo
ts.Close
Set ts =3D Nothing
MakeFolderTemplate =3D sFolderTemplate =20
End Function
'----------------------------------------
Function OpenAndCloseSubfolders (oFolder)
Dim iCount
iCount=3D0
For Each oItem in oFolder.Items
If oItem.IsFolder Then
If NotZipped(oItem) and NotAlreadySaved(oItem) Then
'Do Until oAppshell.windows.count =3D 0
' WScript.Sleep 100
'Loop
oAppshell.open oItem.GetFolder
'WScript.Sleep 1000
On Error Resume Next
Do
Err.Clear
oAppshell.windows.item.quit
Loop Until Err.Number =3D 0
iCount =3D iCount + 1
iCount =3D iCount + =
OpenAndCloseSubfolders(oItem.GetFolder)
End If
End If
Next
OpenAndCloseSubfolders =3D iCount
End Function
'-----------------------------------------
Sub DeleteBagsAndIncreaseLimit ()
Dim tFolder, tName, tFile, tString
Const TemporaryFolder =3D 2
Set tFolder =3D oFso.GetSpecialFolder(TemporaryFolder)
tName =3D oFso.GetTempName =20
Set tFile =3D tFolder.CreateTextFile(tName)
tString =3D _
"REGEDIT4" & vbCrLf & vbCrLf & _
"[-HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\BagMRU]" =
& vbCrLf & _
"[-HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags]" & =
vbCrLf & vbCrLf & _
"[HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell]" & vbCrLf & _
"""BagMRU Size""=3Ddword:00001f40" & vbCrLf & vbCrLf & _
"[HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam]" & =
vbCrLf & _
"""BagMRU Size""=3Ddword:00001f40" & vbCrLf & vbCrLf & _
=
"[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Ex=
plorer]" & vbCrLf & _
"""NoSaveSettings""=3Ddword:00000000" & vbCrLf & vbCrLf
tFile.write (tString)
tFile.close
RegImport (tFolder.Path & "\" & tName)
oFso.GetFile(tFolder.Path & "\" & tName).Delete
End Sub =20
'-----------------------------------------
Sub RegImport (sFileName)
Dim sCmd
sCmd =3D "regedit.exe /s """ & sFileName & """"
oScriptShell.Run sCmd, 0, True
End Sub
'-----------------------------------------
Function RegExport (sRegPath, sFileName)
Dim sCmd, sTemp
sTemp =3D oScriptShell.SpecialFolders("Desktop") & "\" & sFileName
sCmd =3D "regedit.exe /A """ & sTemp & """ " & """" & sRegPath & =
""""
oScriptShell.Run sCmd, 0, True
RegExport =3D sTemp
End Function
'-----------------------------------------
Function NotZipped (oFolder)
NotZipped =3D Not (CBool (InStr (oFolder.type, "zipped")))
End Function
'-----------------------------------------
Function VPath (oFolder)
on error resume next
sTemp =3D oFolder.ParentFolder.title
If Err.Number =3D 0 then=20
VPath =3D VPath (oFolder.ParentFolder) & "\" & oFolder.title
Else
VPath =3D oFolder.title
Err.Clear
End If
End Function
'-----------------------------------------
Function NotAlreadySaved (oFolder)
Dim sVPath
NotAlreadySaved =3D True
sVPath =3D VPath (oFolder.GetFolder)
For Each s in VPathCollection
If s =3D sVPath Then
NotAlreadySaved =3D False
Exit For
End If
Next
End Function
'-----------------------------------------
Sub InitMsgStrs ()
sIntroMsg =3D "This script will allow you to customize the view for =
a folder and " & _
"then have that view applied to all of the folder's subfolders. =
" & _
"All previously saved views will be lost. Your old settings " & =
_
"will be saved in two .reg files placed on the desktop that can =
be " & _
"merged to restore your old settings." & vbCrLf & vbCrLf & _
"Work your way up from lower-level folders to higher-level " & _
"folders -- i.e. do My Music and My Pictures before doing My =
Documents. " & _
"If a sub-folder has already had a view saved, It will not be =
affected by " & _
"applying a different view to its parent folder." & vbCrLf & =
vbCrLf & _
"Also, different views are saved for 'My Documents' and its " & =
_
"subfolders, depending on how they are accessed:" & vbCrLf & =
vbCrLf & _
vbTab & "'Desktop\My Documents'" & vbCrLf & vbTab & "'My =
Computer\My Documents'" & _
vbCrLf & vbTab & "'C:\Docs and Settings\<username>\My =
Documents'" & vbCrLf & _
vbCrLf & "are seperate and unique as far as views are concerned. =
You may want " & _
"to take a minute to verify which way you access these folders =
by opening one " & _
"and viewing the folder pane to determine the path." & vbCrLf & =
vbCrLf & _
"Do you wish to continue?"
sScriptTitle =3D "Customize Folder Views"
sIntro2 =3D "This script will be opening and closing explorer =
windows in order to " & _
"apply the views. It is recommended you close other =
applications to run " & _
"this Script. To function properly, It is IMPERATIVE that you =
not have " & _
"any Explorer or I.E. windows open. If you have any open, =
please close " & _
"them before clicking 'OK'" & vbCrLf & vbCrLf & "Do you wish to =
continue?"
sSetView =3D "Alt+Tab to the Folder window now open and set all view =
options to your " & _
"liking. DO NOT CLOSE THE FOLDER YOURSELF! When you are done, =
Alt+Tab back to this window & click 'OK'."=20
End Sub
------=_NextPart_000_01A3_01C526AA.CB4F12E0
Content-Type: text/plain;
name="FolderViewSave.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="FolderViewSave.txt"
Const conBagMRUPath =3D =
"HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\BagMRU"
Const conBagsPath =3D =
"HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags"
Const conFolderStreams =3D =
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Streams\Defaults=
\{F3364BA0-65B9-11CE-A9BA-00AA0=AD04AE837}"
Const ForReading =3D 1
dim oAppShell, oScriptShell, oFso, oFolder
dim VPathCollection ()
dim sIntroMsg, sScriptTitle, sIntro2, sSetView
'Instructions & Warnings
InitMsgStrs
If (msgbox(sIntroMsg, vbYesNo, sScriptTitle) <> vbYes) Then
WScript.Quit
End If
If (msgbox(sIntro2, vbYesNo + vbCritical, sScriptTitle) <> vbYes) Then
WScript.Quit
End If
'Assign objects
Set oAppShell =3D CreateObject("Shell.Application")
Set oScriptShell =3D CreateObject("WScript.Shell")=20
Set oFSO =3D CreateObject("Scripting.FileSystemObject")
'Verify other windows are closed
Do While oAppShell.windows.count <> 0
If (msgbox(oAppShell.windows.count & " Explorer/I.E. windows are =
still open!", _
vbRetryCancel + vbCritical, sScriptTitle) <> vbReTry) Then
WScript.Quit
End If
Loop
=20
'Back up the Registry Keys
Call RegExport(conBagMRUPath, "BagMRU Backup.reg")
Call RegExport(conBagsPath, "Bags Backup.reg")
DeleteBagsAndIncreaseLimit
'If conFolderStreams exists,it screws up the
' default columns for detail view of special folders. So...
On Error Resume Next
oScriptShell.RegDelete conFolderStreams
Err.Clear
On Error Goto 0
iNewBagCount =3D 0
bContinue =3D True
iLoopCount =3D 0
Do While bContinue '*** The Fun Starts Here ***
iLoopCount =3D iLoopCount + 1
set oFolder =3D oAppShell.BrowseForFolder(0, "Choose a Folder", 0)
oAppShell.Open oFolder
WScript.Sleep 1000
msgbox sSetView,,oFolder.title & " - Script Paused..."
oAppShell.windows.item.quit
iNewBagCount =3D iNewBagCount + 1
ReDim Preserve VPathCollection(iLoopCount - 1)
VPathCollection(iLoopCount - 1) =3D VPath(oFolder)
sFolderTemplateFile =3D MakeFolderTemplate(iNewBagCount)
RegImport sFolderTemplateFile
sStart =3D Now
iNewBagCount =3D iNewBagCount + OpenAndCloseSubfolders(oFolder)
MsgBox "Finished in " & DateDiff("s", sStart, Now) & " seconds", _=20
vbSystemModal, "OpenAndCloseSubfolders"
oFso.GetFile(sFolderTemplateFile).Delete
oScriptShell.RegDelete(conBagsPath & "\AllFolders\Shell\")
oScriptShell.RegDelete(conBagsPath & "\AllFolders\")
msg =3D "You have saved views for the following folder(s):" & vbCrLf
For each sPath in VPathCollection
msg =3D msg & vbTab & sPath & vbCrLf
Next
msg =3D msg & "You have saved views for " & iNewBagCount & " folders =
(8000 max)" & vbCrLf
msg =3D msg & vbCrLf & "Would you like to do another folder?"
bcontinue =3D msgbox (msg, vbYesNo) =3D vbYes
Loop
Set oAppShell =3D Nothing
Set oScriptShell =3D Nothing
Set oFSO =3D Nothing
'---------------------------------------End------------------------------=
-----------
Function MakeFolderTemplate (iBagNum)
Dim sTemplateRegPath, sTemplateFileName, sFolderTemplate, ts
sTemplateRegPath =3D conBagsPath & "\" & iBagNum
sTemplateFileName =3D "Folder Template" & iBagNum & ".reg"
sFolderTemplate =3D RegExport (sTemplateRegPath, sTemplateFileName)
'msgbox sFolderTemplate
Set ts =3D oFso.OpenTextFile(sFolderTemplate, ForReading)
sTemplateInfo =3D ts.ReadAll
ts.close
sSearch =3D "Bags\" & iNewBagCount
sReplace =3D "Bags\AllFolders"
sTemplateInfo =3D Replace (sTemplateInfo, sSearch, sReplace, 1, 2)
sTemplateInfo =3D Replace (sTemplateInfo, "My", "")
Set ts =3D oFso.CreateTextFile (sFolderTemplate, true)
ts.Write sTemplateInfo
ts.Close
Set ts =3D Nothing
MakeFolderTemplate =3D sFolderTemplate =20
End Function
'----------------------------------------
Function OpenAndCloseSubfolders (oFolder)
Dim iCount
iCount=3D0
For Each oItem in oFolder.Items
If oItem.IsFolder Then
If NotZipped(oItem) and NotAlreadySaved(oItem) Then
'Do Until oAppshell.windows.count =3D 0
' WScript.Sleep 100
'Loop
oAppshell.open oItem.GetFolder
'WScript.Sleep 1000
On Error Resume Next
Do
Err.Clear
oAppshell.windows.item.quit
Loop Until Err.Number =3D 0
iCount =3D iCount + 1
iCount =3D iCount + =
OpenAndCloseSubfolders(oItem.GetFolder)
End If
End If
Next
OpenAndCloseSubfolders =3D iCount
End Function
'-----------------------------------------
Sub DeleteBagsAndIncreaseLimit ()
Dim tFolder, tName, tFile, tString
Const TemporaryFolder =3D 2
Set tFolder =3D oFso.GetSpecialFolder(TemporaryFolder)
tName =3D oFso.GetTempName =20
Set tFile =3D tFolder.CreateTextFile(tName)
tString =3D _
"REGEDIT4" & vbCrLf & vbCrLf & _
"[-HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\BagMRU]" =
& vbCrLf & _
"[-HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags]" & =
vbCrLf & vbCrLf & _
"[HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell]" & vbCrLf & _
"""BagMRU Size""=3Ddword:00001f40" & vbCrLf & vbCrLf & _
"[HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam]" & =
vbCrLf & _
"""BagMRU Size""=3Ddword:00001f40" & vbCrLf & vbCrLf & _
=
"[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Ex=
plorer]" & vbCrLf & _
"""NoSaveSettings""=3Ddword:00000000" & vbCrLf & vbCrLf
tFile.write (tString)
tFile.close
RegImport (tFolder.Path & "\" & tName)
oFso.GetFile(tFolder.Path & "\" & tName).Delete
End Sub =20
'-----------------------------------------
Sub RegImport (sFileName)
Dim sCmd
sCmd =3D "regedit.exe /s """ & sFileName & """"
oScriptShell.Run sCmd, 0, True
End Sub
'-----------------------------------------
Function RegExport (sRegPath, sFileName)
Dim sCmd, sTemp
sTemp =3D oScriptShell.SpecialFolders("Desktop") & "\" & sFileName
sCmd =3D "regedit.exe /A """ & sTemp & """ " & """" & sRegPath & =
""""
oScriptShell.Run sCmd, 0, True
RegExport =3D sTemp
End Function
'-----------------------------------------
Function NotZipped (oFolder)
NotZipped =3D Not (CBool (InStr (oFolder.type, "zipped")))
End Function
'-----------------------------------------
Function VPath (oFolder)
on error resume next
sTemp =3D oFolder.ParentFolder.title
If Err.Number =3D 0 then=20
VPath =3D VPath (oFolder.ParentFolder) & "\" & oFolder.title
Else
VPath =3D oFolder.title
Err.Clear
End If
End Function
'-----------------------------------------
Function NotAlreadySaved (oFolder)
Dim sVPath
NotAlreadySaved =3D True
sVPath =3D VPath (oFolder.GetFolder)
For Each s in VPathCollection
If s =3D sVPath Then
NotAlreadySaved =3D False
Exit For
End If
Next =20
End Function
'-----------------------------------------
Sub InitMsgStrs ()
sIntroMsg =3D "This script will allow you to customize the view for =
a folder and " & _
"then have that view applied to all of the folder's subfolders. =
" & _
"All previously saved views will be lost. Your old settings " & =
_
"will be saved in two .reg files placed on the desktop that can =
be " & _
"merged to restore your old settings." & vbCrLf & vbCrLf & _
"Work your way up from lower-level folders to higher-level " & _
"folders -- i.e. do My Music and My Pictures before doing My =
Documents. " & _
"If a sub-folder has already had a view saved, It will not be =
affected by " & _
"applying a different view to its parent folder." & vbCrLf & =
vbCrLf & _
"Also, different views are saved for 'My Documents' and its " & =
_
"subfolders, depending on how they are accessed:" & vbCrLf & =
vbCrLf & _
vbTab & "'Desktop\My Documents'" & vbCrLf & vbTab & "'My =
Computer\My Documents'" & _
vbCrLf & vbTab & "'C:\Docs and Settings\<username>\My =
Documents'" & vbCrLf & _
vbCrLf & "are seperate and unique as far as views are concerned. =
You may want " & _
"to take a minute to verify which way you access these folders =
by opening one " & _
"and viewing the folder pane to determine the path." & vbCrLf & =
vbCrLf & _
"Do you wish to continue?"
sScriptTitle =3D "Customize Folder Views"
sIntro2 =3D "This script will be opening and closing explorer =
windows in order to " & _
"apply the views. It is recommended you close other =
applications to run " & _
"this Script. To function properly, It is IMPERATIVE that you =
not have " & _
"any Explorer or I.E. windows open. If you have any open, =
please close " & _
"them before clicking 'OK'" & vbCrLf & vbCrLf & "Do you wish to =
continue?"
sSetView =3D "Alt+Tab to the Folder window now open and set all view =
options to your " & _
"liking. DO NOT CLOSE THE FOLDER YOURSELF! When you are done, =
Alt+Tab back to this window & click 'OK'."=20
End Sub
------=_NextPart_000_01A3_01C526AA.CB4F12E0-- Tag: filepost.asp Tag: 171541
On Error Goto ErrorHandler
Hi All,
I am a newbie as far as VB scripting goes.
Would anybody be able to help me with error handling in vb script?
The following statement gives an error, though "ErrHandler:" tag exists in
the same routine
on error goto ErrHandler
kd Tag: filepost.asp Tag: 171539
round a number in vbs
This is a multi-part message in MIME format.
------=_NextPart_000_0026_01C52707.3F3947A0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi,
How to I format the output of a number in VBS, eg:
if the output is 1794, I want it to be 1790
if the output is 1795, I want it to be 1800
I was looking at FormatNumber and Round function, but neither seem to do =
what I want.
Here is the script to query CPU speed:
Set objWMIService =3D GetObject("winmgmts:" & =
"{impersonationLevel=3Dimpersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcessors =3D objWMIService.ExecQuery("SELECT * FROM =
Win32_Processor", "WQL", _
wbemFlagReturnImmediately + =
wbemFlagForwardOnly)
For Each objProcessor In colProcessors
strProcessorName =3D objProcessor.Name
strCurrentClockSpeed =3D objProcessor.CurrentClockSpeed
Next
Wscript.Echo "CPU speed: " & strCurrentClockSpeed & "Mhz"
Thanks
Frank
------=_NextPart_000_0026_01C52707.3F3947A0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1491" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>How to I format the output of a number =
in VBS,=20
eg:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>if the output is 1794, I want it to be=20
1790</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>if the output is 1795, I want it to be=20
1800</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV>I was looking at FormatNumber and Round function, but neither seem =
to do=20
what I want.</DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Here is the script to query CPU =
speed:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> Set objWMIService =3D =
GetObject("winmgmts:"=20
& "{impersonationLevel=3Dimpersonate}!\\" _<BR> =20
&=
nbsp; =20
& strComputer & "\root\cimv2")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> Set colProcessors =3D=20
objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL",=20
_<BR> &n=
bsp; &nb=
sp; &nbs=
p; =20
wbemFlagReturnImmediately + wbemFlagForwardOnly)<BR> For Each =
objProcessor=20
In colProcessors<BR> strProcessorName =3D=20
objProcessor.Name<BR> strCurrentClockSpeed =3D=20
objProcessor.CurrentClockSpeed<BR> Next<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> Wscript.Echo "CPU speed: " &=20
strCurrentClockSpeed & "Mhz"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Frank</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> </DIV></FONT></BODY></HTML>
------=_NextPart_000_0026_01C52707.3F3947A0-- Tag: filepost.asp Tag: 171536
Determine if Remote Parnet Share is shared out but not the childen
Hi I need a quick Idea:
I need to determine on a remote file server if a users shared parent folder
(Ex ACCT ID in the following location c:\data\users\Acct ID)is properly
shared out as a hidden share. Now I now how to reset it to a hidden share
remotely when creating the folder, but what I need is a vbs script that will
run on the server 24 / 7 and once an hour verify that all of the user shares
(But not the subfolders of the parent) are still shared out? Is there a way
of limiting the verification to just the parent folder and then loop through
all of the parent folders in the share? Thanks!!! Tag: filepost.asp Tag: 171530
Newbie asking for a script on automatic files management
Hi,
I'm trying to come up with a script that does the following in vbscript:
1) User drag and drop a folder
2) Process all files in dropped folder
3) For all files
Add a timestamp of last accessed to the end of the filename
move each file to the correct subfolder
for eg Allthisfile.xls is moved to the A subfolder
eg 12345.doc is moved to the 1 subfolder
Does anyone have a sample script that i can refer to?
Thanks Tag: filepost.asp Tag: 171529
MsgBox to display while processing
Hopefully there is a simple solution to my dilemma. I have a script as
follows:
1. A MsgBox is displayed to ask user if they want to proceed.
2. After they click Yes, the MsgBox disappears and the script begins
processing.
3. Processing takes about 30 seconds to complete.
4. After the processing has completed, a MsgBox is displayed to inform the
user the process has completed.
I'd like to have a MsgBox display during the 30 seconds of processing to
tell the user to "Please wait." I don't need a progress bar or anything
fancy like that - just a simple message so the user doesn't think the script
has hung.
Is this possible?
Thanks! Tag: filepost.asp Tag: 171526
scheduling a VBScript
I cannot for the life of me, schedule a VBScript to execute at X time of day
on a server... I even tried seting up a SQL job to execute the script but
that didn't work either... likely because I have no idea what I'm doing.
Any ideas on how to schedule a VBScript to run at a specified interval?
thanks in advance, this is very frustrating! Tag: filepost.asp Tag: 171521
Scan an image to fit
I know how to display an image from vbscript using IE from an earlier
posting
Option Explicit
Const cIMG = "<img src='c:\windows\space.bmp' border='0'>"
Dim objIEA
Set objIEA = CreateObject("InternetExplorer.Application")
objIEA.ToolBar = 0
objIEA.StatusBar = 0
objIEA.Width = 330
objIEA.Height = 180
objIEA.Left = 0
objIEA.Top = 0
objIEA.Visible = True
objIEA.Navigate "about:blank"
While objIEA.Busy
wscript.Sleep 100
Wend
objIEA.Document.Body.InnerHTML = cIMG
Is there some way to modify this so that the image is automatically scaled
to fit in the window as is done when you select the option
Tools -> Internet Options -> Advanced -> Enable Automatic Image Resizing Tag: filepost.asp Tag: 171519
Scripting.FileSystemObject
When uploading a file, the DLLHOST.exe max's out at 100% for files greater
than 400kb. Why?