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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? 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: ¿Ordenar un array? Tag: 171519
Searching XML files
Hi All,
I have around 1500 xml file in a folder and want to search for keywords in
the file. Please help me how to do this. Can it be done using Microsoft index
server ?? I am new to xml ....Please help
thanks, Tag: ¿Ordenar un array? Tag: 171513
setting a data type in excel
I am using code to put passwords into excel. I found that if a password
is all numbers that excel will save it as a number instead of as text.
Is there a way to programatically set some property so the cell will be
text instead of a number?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! Tag: ¿Ordenar un array? Tag: 171512
Copy an image
Hi
I want to create an Excel instance, copy a picture from my html page and
paste it into the Excel instance. Is this possible?
Se example below of what I'm trying to do (the copy part doesn't work
though):
Dim xlApp
Dim xlW
Dim xlS
Set xlApp = CreateObject( "Excel.Application" )
Set xlW = xlApp.Workbooks.Add
Set xlS = xlW.Worksheets.Add
myPicture.Copy
xlS.Paste
Regards
PO Tag: ¿Ordenar un array? Tag: 171511
Unlock
Is there a way to run a VBS script when someone unlocks there computer? For
example, if someone leaves for lunch, they typically will lock their
computer screen. Is there a way to run a script when the computer screen
becomes unlocked? Tag: ¿Ordenar un array? Tag: 171508
Identifying a USB drive by letter
How can I tell if a drive letter refers to a USB drive? I need to
differentiate between the kinds of removable drives (USB memory stick, PCMCIA
card, etc.).
--
Your email is being returned due to insufficient voltage. Tag: ¿Ordenar un array? Tag: 171506
VBscript Search and Replace conundrum
I have an application where the INI files are "dumb" and always write the
path c:\ to a couple of INI files. "vwcmim.ini" and "vwgsmm.ini" in the
windows directory.
I want to list drives (like xternal), check them for data directory, and if
it's found replace c:\ with <drive:\> in the INI files.
I've got to the point where it does process the files but instead of putting
in the drive letter it just erases the old drive letter c: with a null
string.
I am wondering what I'm doing wrong, or if anybody's got a better idea for
simple file text search/replace. VBscript code follows. It has to run from a
command prompt using cscript <scriptname>
' This script finds and replaces the drive C: with the correct drive letter
in the ' INI see below (see SubFolder)
' This allows vACBI to run even where the data drive letter is not c:
' Owen Gilmore - owen.gilmore@united.com
' aogilmore@sbcglobal.net
' 7:20 AM 1/10/2005
Option Explicit
Dim WshProcessEnvironment
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshProcessEnvironment = WshShell.Environment("Process")
'Define Object Variables
Dim FSys
Dim xFolder
Dim xFiles
Dim xFile
Dim tFile
Dim wshShell
'On Error Resume Next
Dim strComputer
Dim objWMIService
Dim colItems
Dim objFSO
Dim objShell
Dim strmsg
Dim u_Drv
Dim u_MedPath
Dim objItem
Dim EnvWinDir
' Define Working Variables
Dim SubFolder
Dim FileText
'Get some necessary environment variables
EnvWinDir = WshProcessEnvironment("windir")
'Define Constants
CONST U_File1 = "vwcmim.ini"
CONST U_File2 = "vwgsmm.ini"
Const ForReading = 1
Const ForWriting = 2
Const TristateUseDefault = -2
'On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
u_MedPath = "\United\VWCMI\DATA"
For Each objItem in colItems
strmsg=strmsg&"DeviceID: " & objItem.DeviceID&vbcrlf
If objFSO.FolderExists(objItem.DeviceID & u_MedPath) Then
u_Drv = objItem.DeviceID
End If
SubFolder = EnvWinDir
'Verify that the script runs in console mode
If UCase(Right(WScript.FullName,
Len(WScript.FullName)-InStrRev(WScript.FullName,"\"))) <> "CSCRIPT.EXE" Then
Set wshShell = WScript.CreateObject("WScript.Shell")
wshShell.Run "CSCRIPT.EXE " & WScript.ScriptFullName, 1, False
Set wshShell = Nothing
WScript.Quit
End If
'Set Objects
Set FSys = WScript.CreateObject("Scripting.FileSystemObject")
Set xFolder = FSys.GetFolder(SubFolder)
Set xFiles = xFolder.Files
WScript.Echo SubFolder
WScript.Echo "Directive to process " & xFiles.Count & " files."
'Parse Each file and perform replacements
For Each xFile in xFiles
if xFile.Name = u_File1 OR xFile.Name = u_File2 Then
WScript.Echo " --> " & xFile.Name
WScript.Echo " Reading in contents"
WScript.Echo u_Drv
Set tFile = xFile.OpenAsTextStream(ForReading, TristateUseDefault)
FileText = tFile.ReadAll
tFile.Close
WScript.Echo " Performing Replacement" & FileText & " with " & u_Drv
FileText = REPLACE(FileText, "C:", u_Drv)
WScript.Echo " Saving new file"
Set tFile = xFile.OpenAsTextStream(ForWriting, TristateUseDefault)
tFile.Write FileText
tFile.Close
Else
WScript.Echo " --> " & xFile.Name & " NOT APPLICABLE"
' FileText = ""
End If
Next
Next
'Clean Environment and exit
On Error Resume Next
Set tFile = Nothing
Set xFolder = Nothing
Set xFiles = Nothing
Set xFile = Nothing
Set FSys = Nothing
--
MSI packaging
Scripting
Deployments Tag: ¿Ordenar un array? Tag: 171501
vbscript comit changes to active directory
I need to know how to make a change in a field and comit it back into active
directory. This is code that I am using. I def NEED to have the
userPrincipalName to get the current logon user in the query, and change just
his profile path. Any ideas???
Thanks
'-----------------------------------------------------------------
Option Explicit
Const ADS_SCOPE_SUBTREE = 2
'these next 4 strings aren't very necessary but it makes it look cleaner
'towards the end
Dim strName
Dim strProfile
Dim strHomeDrive
Dim strHomeDirectory
Dim strDistinguishedName
Dim strlogon
'strprofile will error on a null value so I am
Dim rs
Dim cnn
Dim cmd
Dim objuser
Set cnn = CreateObject("ADODB.Connection")
Set cmd = CreateObject("ADODB.Command")
' Open the connection.
cnn.Provider = "ADsDSOObject" ' This is the ADSI OLE-DB provider name
cnn.Open "Active Directory Provider"
' Create a command object for this connection.
Set cmd.ActiveConnection = cnn
' Compose a search string and replace DC=YourDomain, DC=COM
cmd.CommandText = "select name, distinguishedname, profilepath, homedrive,
homedirectory, userPrincipalName" _
& " from 'LDAP:// OU= NY, DC=FFHSJ, DC=COM' WHERE objectCategory='user' And
objectCategory='person' and userPrincipalName='wahidta@ffhsj.com'"
cmd.Properties("Page Size") = 1000
cmd.Properties("Timeout") = 30
cmd.Properties("Searchscope") = ADS_SCOPE_SUBTREE 'search all containers
cmd.Properties("Cache Results") = False
Set rs = cmd.Execute
'------------------------------------------------------------------------------ Tag: ¿Ordenar un array? Tag: 171499
Import Access DB
Can VBScript be used to import data into MS Access? I have searched the web
and have not been able to find anything.
If someone could point me in the right direction, I would appreciate it.
Thanks Tag: ¿Ordenar un array? Tag: 171498
vbscript help
OK im trying to update the user profile of people that are logged on to the
machine. I was hoping to use something like the logon_user =
Request.ServerVariables("LOGON_USER") that we can use in .NET but if not
thats not a problem I know i can get it from registry. But if anyone knows
how can you please give me an example. Now Im using the following code to
query a perticular user in active directory. But I need to modify the user
profile
'---------------------------------------------------------------------------------------
Option Explicit
Const ADS_SCOPE_SUBTREE = 2
Dim strName
Dim strTSProfile
Dim strTSHomeDrive
Dim strProfile
Dim rs
Dim cnn
Dim cmd
Dim objuser
Set cnn = CreateObject("ADODB.Connection")
Set cmd = CreateObject("ADODB.Command")
' Open the connection.
cnn.Provider = "ADsDSOObject" ' This is the ADSI OLE-DB provider name
cnn.Open "Active Directory Provider"
' Create a command object for this connection.
Set cmd.ActiveConnection = cnn
' Compose a search string and replace DC=YourDomain, DC=COM
cmd.CommandText = "select name, distinguishedname, profilepath, homedrive,
homedirectory, userPrincipalName" _
& " from 'LDAP:// OU= NY, DC=FFHSJ, DC=COM' WHERE objectCategory='user' And
objectCategory='person' and userPrincipalName='wahidta@ffhsj.com'"
cmd.Properties("Page Size") = 1000
cmd.Properties("Timeout") = 30
cmd.Properties("Searchscope") = ADS_SCOPE_SUBTREE 'search all containers
cmd.Properties("Cache Results") = False
Set rs = cmd.Execute
MsgBox "done"
'-------------------------------------------------------------------------------------
How can I use the recordset to make a change on that field and comit it back
to active directory??
Thanks. Tag: ¿Ordenar un array? Tag: 171497
How to seach for a text inside a file
Hi All,
I' trying to find an specific word inside a file .I'd like to give my script
a wild card(*.txt) and a word or phrase in the file (exactly like what
widows dose) and find the files on my computer.Is it possible to do it in vb
script?
Thanks Tag: ¿Ordenar un array? Tag: 171495
LDAP query help
I'm trying to get the user logon name out with a query from Active Directory.
Whats the field name. I cant find it anywhere. I tried logon, logonname,
userlogon, login, loginname, etc.
cmd.CommandText = "select name, distinguishedname, profilepath, homedrive,
homedirectory, xxx" _
& " from 'LDAP:// OU= NY, DC=FFHSJ, DC=COM' WHERE objectCategory='user'"
Can someone help me out with what to put in the xxx to get the user logon
field from active directory?
Thanks. Tag: ¿Ordenar un array? Tag: 171490
ADO-Security Warnings accessing Datasource
Hi,
Im writing an asp site using vbscript. It accesses my SQL-Server
through an ODBC-Datasource that is defined on the IIS. The code is
set Conn = CreateObject("ADODB.Connection")
Conn.open "DSN=XXX;UID=YYY;pwd=ZZZ"
Set RS = CreateObject("ADODB.Recordset")
sql = "SELECT * FROM tblMyTab WHERE Col1='Test'"
RS.open sql, conn
msgbox RS.fields("Col2")
RS.close
I'm using this code twice: (1) Once in the main procedure that is
executed everytime the page ist displayed and a second time (2) in a
sub that is called by an on_click event. In both cases it works
correctly, but:
Only in case (2) there come up two messages (translated):
"ADO-Security Warning: This website uses an dataprovider who is
prabably not secure. If you trust the website, click OK, otherwiese
click cancel."
and thereafter
"ADO-Security Warning: This website is using your identity while
accessing a datasource. If you trust the website, click OK, otherwiese
click cancel."
Does anyone know how to prevent this messages? Why do they only come
up in (2)?
Thank you in advance!
Marco Tag: ¿Ordenar un array? Tag: 171486
Digitally signing macros
Hi!
I've created a couple of macros that I'd like to digitally sign. I just want
to issue a certificate myself and use that so the security level can remain
at "High". I've used selfcert.exe to create a certificate but when I sign
the macro and save my template I get an error: "There was a problem with the
digital certificate. The VBA project could not be signed. The signature will
be discarded." How can I solve this??
Thanks in advance.
Morten Tag: ¿Ordenar un array? Tag: 171474
Counting Files In A Folder
Hi
I need to count the number of iles in a folder.
I have amended a script I found:
This is fine but it will not do subdirectories
Please can someone assist?
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService. _
ExecQuery("Select * from CIM_DataFile where Path = '\\currency\\'")
For Each objFile in colFiles
'Wscript.Echo objFile.Name
count1 = count1 + 1
'Wscript.Echo count1
Next
Wscript.Echo count1 Tag: ¿Ordenar un array? Tag: 171473
How to close Internet Explorer ?
I am running this script (from a .vbs file) to reboot a router using the web
interface...
Set g_shell = CreateObject("WScript.Shell")
g_shell.Run "iexplore
http://admin:my_password@123.123.123.123/setup.cgi?todo=reboot"
It works, but how do I close IE afterwards ?
Thanks, Craig Tag: ¿Ordenar un array? Tag: 171472
VBscript and Visual Basic
I only know a little about both VBscript and Visual Basic.
I have written a few vbscripts that i would like to add a gui to. Can
any one tell me if i can simply make up a visual basic window (form) and
run the script with some text boxes and buttons.
thanks in advance
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! Tag: ¿Ordenar un array? Tag: 171471
Sound Recording with VBScript
Hi there,
does anybody know how i can record sound within vbscript?
Many thanks to you.
Ulrich Tag: ¿Ordenar un array? Tag: 171467
Wscript.Echo error in VBS Embeded in HTML
Hi All:
I have a script that I am writing that is basicly an HTML file with embeded
VBS Coding. I am basicly designing the script so that it uses a small
browser to open and have the user input an User ID & Server name (Via Text
Input boxes) and when the click the submitt button the script goes off and
verifies that a user folder is not on a share, and then creates it, shares
it, permissions and reports to a log any errors. Now here is my problem.
All of my VBS code is located in one big sub routine that is called when the
user clicks the button in the browser. Now any time that I try to access
anything with Wscript (Wscript.sleep or Wscript.echo) If give me an error
stating "Object Required: Wscript". Any suggestions on how to avoid this so
that I can use the wscript object. Thanks
Lost Tag: ¿Ordenar un array? Tag: 171442
Reading and displaying records from a table in a database with vbscript?
Okay I have a script straight from the windows 2000 scripting guide
that shows me how to connect to a database. This I have done. What
I'm trying to do is connect to an access dbase and read a tables
contents and display each record, or at least assign them to variables
in vbs so that I can use them to create accounts.
So far I have this.
*********************************************************************
const adopenstatic=3
Const adlockoptimistic=3
Const aduseclient=3
Set objConnection=CreateObject("ADODB.Connection")
Set objRecordset=CreateObject("ADODB.Recordset")
objConnection.Open "DSN=testdb;"
objRecordset.Cursorlocation=aduseclient
objRecordset.Open "SELECT * FROM main" , objConnection, adopenstatic,
adlockoptimistic
wscript.Echo objrecordset.recordcount
objrecordset.close
objconnection.close
************************************************************************
I have been all over the web looking for info about this but I must be
searching on the wrong things. Can someone help me out or at least
point me in the right direction?
Thanks
Jason Tag: ¿Ordenar un array? Tag: 171434
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
Re: =?ISO-8859-1?Q?=BFOrdenar_un_array=3F?= by Brian
Brian
Mon Mar 14 11:13:19 CST 2005
Tarllem wrote:
> 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