Search is not available for this dataset
content
stringlengths
0
376M
<gh_stars>10-100 REM REM LOCALIZATION REM L_SWITCH_OPERATION = "-t" L_SWITCH_SERVER = "-s" L_SWITCH_INSTANCE_ID = "-v" L_SWITCH_VROOT_NAME = "-n" L_SWITCH_VROOT_PATH = "-p" L_SWITCH_ALLOW_CLIENT_POSTING = "-c" L_SWITCH_RESTRICT_VISIBILITY = "-r" L_SWITCH_LOG_ACCESS = "-a" L_SWITCH_INDEX_NEWS_CONTENT = "-i" L_SWITCH_TYPE_OF_SYSTEM = "-x" REM L_OP_FIND = "f" L_OP_ADD = "a" L_OP_DELETE = "d" L_OP_GET = "g" L_OP_SET = "s" L_DESC_PROGRAM = "rvirdir - Manipulate NNTP Virtual Directories" L_DESC_ADD = "Add a Virtual Directory" L_DESC_DELETE = "Delete a Virtual Directory" L_DESC_GET = "Get a Virtual Directory's properties" L_DESC_SET = "Set a Virtual Directory's properties" REM L_DESC_FIND = "Find a Virtual Directory" L_DESC_OPERATIONS = "<operations>" L_DESC_SERVER = "<server> Specify computer to configure" L_DESC_INSTANCE_ID = "<virtual server id> Specify virtual server id" L_DESC_VROOT_NAME = "<virtual directory name> name of newsgroup(s) virtual directory includes" L_DESC_VROOT_PATH = "<virtual directory path>" L_DESC_ALLOW_CLIENT_POSTING = "<true/false> allow client posting" L_DESC_RESTRICT_VISIBILITY = "<false/true> restrict newsgroup visibility" L_DESC_LOG_ACCESS = "<true/false> log access" L_DESC_INDEX_NEWS_CONTENT = "<true/false> index news content" L_DESC_TYPE_OF_SYSTEM = "<fs/ex> Specify File System (fs) or Exchange Store (ex)" L_DESC_EXAMPLES = "Examples:" L_DESC_EXAMPLE1 = "rvirdir.vbs -t g -n rec.sports" L_DESC_EXAMPLE2 = "rvirdir.vbs -t a -n rec.sports -p c:\vroot\rec\sports" L_DESC_EXAMPLE3 = "rvirdir.vbs -t d -d my.old.vroot" L_STR_VROOT_NAME = "Virtual Directory:" L_STR_VROOT_PATH = "Path:" L_STR_VROOT_ALLOW_CLIENT_POSTING = "Allow Client Posting:" L_STR_VROOT_RESTRICT_VISIBILITY = "Restrict Newsgroup Visibility:" L_STR_VROOT_LOG_ACCESS = "Log Access:" L_STR_VROOT_INDEX_NEWS_CONTENT = "Index News Content:" L_STR_NUM_MATCHING_VIRTUAL_DIRETORY = "The Number of matching Virtual Roots is:" L_STR_TYPE_OF_VROOT_SYSTEM = "The Vroot is:" L_ERR_MUST_ENTER_VIRTUAL_DIRECTORY = "You must enter a virtual directory name" REM REM END LOCALIZATION REM REM REM --- Globals --- REM dim g_dictParms dim g_admin dim g_vroot set g_dictParms = CreateObject ( "Scripting.Dictionary" ) set g_admin = CreateObject ( "NntpAdm.VirtualServer" ) set g_vroot = CreateObject ( "NntpAdm.VirtualRoot" ) REM REM --- Set argument defaults --- REM g_dictParms(L_SWITCH_OPERATION) = "" g_dictParms(L_SWITCH_SERVER) = "" g_dictParms(L_SWITCH_INSTANCE_ID) = "1" g_dictParms(L_SWITCH_VROOT_NAME) = "" g_dictParms(L_SWITCH_VROOT_PATH) = "" g_dictParms(L_SWITCH_ALLOW_CLIENT_POSTING) = TRUE g_dictParms(L_SWITCH_RESTRICT_VISIBILITY) = FALSE g_dictParms(L_SWITCH_LOG_ACCESS ) = TRUE g_dictParms(L_SWITCH_INDEX_NEWS_CONTENT) = TRUE g_dictParms(L_SWITCH_TYPE_OF_SYSTEM) = "fs" REM REM --- Begin Main Program --- REM if NOT ParseCommandLine ( g_dictParms, WScript.Arguments ) then usage WScript.Quit ( 0 ) end if dim vroot dim vparm dim strVirDir dim i dim id dim index dim g_vroots dim g_vrootitem REM REM REM Debug: print out command line arguments: REM REM switches = g_dictParms.keys REM args = g_dictParms.items REM REM REM for i = 0 to g_dictParms.Count - 1 REM WScript.echo switches(i) & " = " & args(i) REM next REM g_admin.Server = g_dictParms(L_SWITCH_SERVER) g_admin.ServiceInstance = g_dictParms(L_SWITCH_INSTANCE_ID) strVirDir = g_dictParms(L_SWITCH_VROOT_NAME) set g_vroots = g_admin.VirtualRoots g_vroots.Enumerate REM WScript.echo g_vroots.Count REM WScript.echo g_vroots.Find select case g_dictParms(L_SWITCH_OPERATION) REM case L_OP_FIND REM REM REM REM Find virtual directory: REM REM REM REM if strVirDir = "" then REM WScript.Echo L_ERR_MUST_ENTER_VIRTUAL_DIRECTORY REM WScript.Quit 0 REM end if REM REM vparm = g_vroots.Find (strVirDir) REM Wscript.Echo vparm REM vroot = g_vroots.Item (vparm) REM WScript.Echo vroot REM g_vroot.Directory REM REM cVroots = g_vroots.Count REM REM WScript.Echo L_STR_NUM_MATCHING_VIRTUAL_DIRETORY & " " & cVroots - 1 REM REM for i = 0 to cVroots - 1 REM REM WScript.Echo g_voots.Enumerate REM REM next REM case L_OP_ADD if strVirDir = "" then WScript.Echo L_ERR_MUST_ENTER_VIRTUAL_DIRECTORY WScript.Quit 0 end if if g_dictParms(L_SWITCH_ALLOW_CLIENT_POSTING) = "" then g_dictParms(L_SWITCH_ALLOW_CLIENT_POSTING) = TRUE end if if g_dictParms(L_SWITCH_RESTRICT_VISIBILITY) = "" then g_dictParms(L_SWITCH_RESTRICT_VISIBILITY) = FALSE end if if g_dictParms(L_SWITCH_LOG_ACCESS) = "" then g_dictParms(L_SWITCH_LOG_ACCESS) = TRUE end if if g_dictParms(L_SWITCH_INDEX_NEWS_CONTENT) = "" then g_dictParms(L_SWITCH_INDEX_NEWS_CONTENT) = TRUE end if if g_dictParms(L_SWITCH_TYPE_OF_SYSTEM) = "" then g_dictParms(L_SWITCH_TYPE_OF_SYSTEM) = "NNTP.FSPrepare" elseif g_dictParms(L_SWITCH_TYPE_OF_SYSTEM) = "fs" then g_dictParms(L_SWITCH_TYPE_OF_SYSTEM) = "NNTP.FSPrepare" elseif g_dictParms(L_SWITCH_TYPE_OF_SYSTEM) = "ex" then g_dictParms(L_SWITCH_TYPE_OF_SYSTEM) = "NNTP.ExDriverPrepare" else Wscript.Echo "Enter either [fs] or [ex] with the -x option" end if g_vroot.NewsgroupSubtree = strVirDir g_vroot.Directory = g_dictParms (L_SWITCH_VROOT_PATH) g_vroot.GroupPropFile = g_dictParms (L_SWITCH_VROOT_PATH) g_vroot.AllowPosting = BooleanToBOOL (g_dictParms(L_SWITCH_ALLOW_CLIENT_POSTING)) g_vroot.RestrictGroupVisibility = BooleanToBOOL (g_dictParms(L_SWITCH_RESTRICT_VISIBILITY)) g_vroot.LogAccess = BooleanToBOOL (g_dictParms(L_SWITCH_LOG_ACCESS)) g_vroot.IndexContent = BooleanToBOOL (g_dictParms(L_SWITCH_INDEX_NEWS_CONTENT)) g_vroot.GroupPropFile = g_dictParms (L_SWITCH_VROOT_PATH) g_vroot.DriverProgId = g_dictParms(L_SWITCH_TYPE_OF_SYSTEM) On Error Resume Next g_vroots.Add g_vroot if ( Err.Number <> 0 ) then WScript.echo " Error creating group: " & Err.Description & "(" & Err.Number & ")" else PrintVirturalDirectory (g_vroot) end if case L_OP_DELETE if strVirDir = "" then WScript.Echo L_ERR_MUST_ENTER_VIRTUAL_DIRECTORY WScript.Quit 0 end if On Error Resume Next vparm = g_vroots.Find (strVirDir) g_vroots.Remove vparm if ( Err.Number <> 0 ) then WScript.echo " Error deleting group: " & Err.Description & "(" & Err.Number & ")" else Wscript.Echo "Virtual Root " & strVirDir & " has been removed." end if case L_OP_GET if strVirDir = "" then WScript.Echo L_ERR_MUST_ENTER_VIRTUAL_DIRECTORY WScript.Quit 0 end if On Error Resume Next i = g_vroots.Find (strVirDir) set g_vroot = g_vroots.Item (i) if ( Err.Number <> 0 ) then WScript.echo " Error getting group: " & Err.Description & "(" & Err.Number & ")" else PrintVirturalDirectory (g_vroot) end if case L_OP_SET if strVirDir = "" then WScript.Echo L_ERR_MUST_ENTER_VIRTUAL_DIRECTORY WScript.Quit 0 end if On Error Resume Next WScript.Echo "I'm Changing the " & g_dictParms(L_SWITCH_VROOT_NAME) & " Vroot to:" WScript.Echo i = g_vroots.Find (strVirDir) set g_vroot = g_vroots.Item (i) if ( Err.Number <> 0 ) then WScript.echo "Error setting group: " & Err.Description & "(" & Err.Number & ")" else if g_dictParms(L_SWITCH_VROOT_NAME) = "" then g_dictParms(L_SWITCH_VROOT_NAME) = g_vroot.NewsgroupSubtree end if if g_dictParms(L_SWITCH_VROOT_PATH) = "" then g_dictParms(L_SWITCH_VROOT_PATH) = g_vroot.Directory g_dictParms(L_SWITCH_VROOT_PATH) = g_vroot.GroupPropFile end if if g_dictParms(L_SWITCH_ALLOW_CLIENT_POSTING) = "" then g_dictParms(L_SWITCH_ALLOW_CLIENT_POSTING) = g_vroot.AllowPosting end if if g_dictParms(L_SWITCH_RESTRICT_VISIBILITY) = "" then g_dictParms(L_SWITCH_RESTRICT_VISIBILITY) = g_vroot.RestrictGroupVisibility end if if g_dictParms(L_SWITCH_LOG_ACCESS) = "" then g_dictParms(L_SWITCH_LOG_ACCESS) = g_vroot.LogAccess end if if g_dictParms(L_SWITCH_INDEX_NEWS_CONTENT) = "" then g_dictParms(L_SWITCH_INDEX_NEWS_CONTENT) = g_vroot.IndexContent end if if g_dictParms(L_SWITCH_TYPE_OF_SYSTEM) = "" then g_dictParms(L_SWITCH_TYPE_OF_SYSTEM) = g_vroot.DriverProgId elseif g_dictParms(L_SWITCH_TYPE_OF_SYSTEM) = "fs" then g_dictParms(L_SWITCH_TYPE_OF_SYSTEM) = "NNTP.FSPrepare" elseif g_dictParms(L_SWITCH_TYPE_OF_SYSTEM) = "ex" then g_dictParms(L_SWITCH_TYPE_OF_SYSTEM) = "NNTP.ExDriverPrepare" end if g_vroot.NewsgroupSubtree = g_dictParms(L_SWITCH_VROOT_NAME) g_vroot.Directory = g_dictParms(L_SWITCH_VROOT_PATH) g_vroot.GroupPropFile = g_dictParms(L_SWITCH_VROOT_PATH) g_vroot.AllowPosting = BooleanToBOOL (g_dictParms(L_SWITCH_ALLOW_CLIENT_POSTING)) g_vroot.RestrictGroupVisibility = BooleanToBOOL (g_dictParms(L_SWITCH_RESTRICT_VISIBILITY)) g_vroot.LogAccess = BooleanToBOOL (g_dictParms(L_SWITCH_LOG_ACCESS)) g_vroot.IndexContent = BooleanToBOOL (g_dictParms(L_SWITCH_INDEX_NEWS_CONTENT)) g_vroot.DriverProgId = g_dictParms(L_SWITCH_TYPE_OF_SYSTEM) end if On Error Resume Next g_vroots.Set i, g_vroot if ( Err.Number <> 0 ) then WScript.echo "You probably entered an invalid Virtual Root." else PrintVirturalDirectory g_vroot end if case else usage end select WScript.Quit 0 REM REM --- End Main Program --- REM REM REM ParseCommandLine ( dictParameters, cmdline ) REM Parses the command line parameters into the given dictionary REM REM Arguments: REM dictParameters - A dictionary containing the global parameters REM cmdline - Collection of command line arguments REM REM Returns - Success code REM Function ParseCommandLine ( dictParameters, cmdline ) dim fRet dim cArgs dim i dim strSwitch dim strArgument fRet = TRUE cArgs = cmdline.Count i = 0 do while (i < cArgs) REM REM Parse the switch and its argument REM if i + 1 >= cArgs then REM REM Not enough command line arguments - Fail REM fRet = FALSE exit do end if strSwitch = cmdline(i) i = i + 1 strArgument = cmdline(i) i = i + 1 REM REM Add the switch,argument pair to the dictionary REM if NOT dictParameters.Exists ( strSwitch ) then REM REM Bad switch - Fail REM fRet = FALSE exit do end if dictParameters(strSwitch) = strArgument loop ParseCommandLine = fRet end function REM REM Usage () REM prints out the description of the command line arguments REM Sub Usage WScript.Echo L_DESC_PROGRAM WScript.Echo vbTab & L_SWITCH_OPERATION & " " & L_DESC_OPERATIONS REM WScript.Echo vbTab & vbTab & L_OP_FIND & vbTab & L_DESC_FIND WScript.Echo vbTab & vbTab & L_OP_ADD & vbTab & L_DESC_ADD WScript.Echo vbTab & vbTab & L_OP_DELETE & vbTab & L_DESC_DELETE WScript.Echo vbTab & vbTab & L_OP_GET & vbTab & L_DESC_GET WScript.Echo vbTab & vbTab & L_OP_SET & vbTab & L_DESC_SET WScript.Echo vbTab & L_SWITCH_SERVER & " " & L_DESC_SERVER WScript.Echo vbTab & L_SWITCH_INSTANCE_ID & " " & L_DESC_INSTANCE_ID WScript.Echo vbTab & L_SWITCH_VROOT_NAME & " " & L_DESC_VROOT_NAME WScript.Echo vbTab & L_SWITCH_VROOT_PATH & " " & L_DESC_VROOT_PATH WScript.Echo vbTab & L_SWITCH_ALLOW_CLIENT_POSTING & " " & L_DESC_ALLOW_CLIENT_POSTING WScript.Echo vbTab & L_SWITCH_RESTRICT_VISIBILITY & " " & L_DESC_RESTRICT_VISIBILITY WScript.Echo vbTab & L_SWITCH_LOG_ACCESS & " " & L_DESC_LOG_ACCESS WScript.Echo vbTab & L_SWITCH_INDEX_NEWS_CONTENT & " " & L_DESC_INDEX_NEWS_CONTENT WScript.Echo vbTab & L_SWITCH_TYPE_OF_SYSTEM & " " & L_DESC_TYPE_OF_SYSTEM WScript.Echo WScript.Echo L_DESC_EXAMPLES WScript.Echo L_DESC_EXAMPLE1 WScript.Echo L_DESC_EXAMPLE2 WScript.Echo L_DESC_EXAMPLE3 end sub Sub PrintVirturalDirectory ( g_vroot ) WScript.Echo L_STR_VROOT_NAME & " " & g_vroot.NewsgroupSubtree WScript.Echo L_STR_VROOT_PATH & " " & g_vroot.Directory WScript.Echo L_STR_TYPE_OF_VROOT_SYSTEM & " " & g_vroot.DriverProgId if ( g_vroot.AllowPosting = 1) then WScript.Echo L_STR_VROOT_ALLOW_CLIENT_POSTING & " = TRUE" else WScript.Echo L_STR_VROOT_ALLOW_CLIENT_POSTING & " = FALSE" end if if ( g_vroot.RestrictGroupVisibility = 1) then WScript.Echo L_STR_VROOT_RESTRICT_VISIBILITY & " = TRUE" else WScript.Echo L_STR_VROOT_RESTRICT_VISIBILITY & " = FALSE" end if if ( g_vroot.LogAccess = 1) then WScript.Echo L_STR_VROOT_LOG_ACCESS & " = TRUE" else WScript.Echo L_STR_VROOT_LOG_ACCESS & " = FALSE" end if if ( g_vroot.IndexContent = 1) then WScript.Echo L_STR_VROOT_INDEX_NEWS_CONTENT & " = TRUE" else WScript.Echo L_STR_VROOT_INDEX_NEWS_CONTENT & " = FALSE" end if end sub Function BooleanToBOOL ( b ) if b then BooleanToBOOL = 1 else BooleanToBOOL = 0 end if end function Function BOOLToBoolean ( b ) BOOLToBoolean = (b = 1) end function
'*************************************************************************** 'This script tests the browsing of schema '*************************************************************************** On Error Resume Next Set Process = GetObject("winmgmts:Win32_Process") WScript.Echo "Class name is", Process.Path_.Class 'Get the properties WScript.Echo "Properties:" for each Property in Process.Properties_ WScript.Echo Property.Name next 'Get the qualifiers WScript.Echo "Qualifiers:" for each Qualifier in Process.Qualifiers_ WScript.Echo Qualifier.Name next 'Get the methods WScript.Echo "Methods:" for each Method in Process.Methods_ WScript.Echo Method.Name next if Err <> 0 Then WScript.Echo Err.Description Err.Clear End if
<filename>Task/Spiral-matrix/Visual-Basic/spiral-matrix-4.vb Module modSpiralArray Sub Main() print2dArray(getSpiralArray(5)) End Sub Function getSpiralArray(dimension As Integer) As Object Dim spiralArray(,) As Integer Dim numConcentricSquares As Integer ReDim spiralArray(dimension - 1, dimension - 1) numConcentricSquares = dimension \ 2 If (dimension Mod 2) Then numConcentricSquares = numConcentricSquares + 1 Dim j As Integer, sideLen As Integer, currNum As Integer sideLen = dimension Dim i As Integer For i = 0 To numConcentricSquares - 1 ' do top side For j = 0 To sideLen - 1 spiralArray(i, i + j) = currNum currNum = currNum + 1 Next ' do right side For j = 1 To sideLen - 1 spiralArray(i + j, dimension - 1 - i) = currNum currNum = currNum + 1 Next ' do bottom side For j = sideLen - 2 To 0 Step -1 spiralArray(dimension - 1 - i, i + j) = currNum currNum = currNum + 1 Next ' do left side For j = sideLen - 2 To 1 Step -1 spiralArray(i + j, i) = currNum currNum = currNum + 1 Next sideLen = sideLen - 2 Next getSpiralArray = spiralArray End Function Sub print2dArray(arr) Dim row As Integer, col As Integer, s As String For row = 0 To UBound(arr, 1) s = "" For col = 0 To UBound(arr, 2) s = s & " " & Right(" " & arr(row, col), 3) Next Debug.Print(s) Next End Sub End Module
<gh_stars>10-100 set wso = CreateObject("WScript.Shell") SAPIROOT = wso.ExpandEnvironmentStrings("%SAPIROOT%") function GetErrLine(logname) set fso = CreateObject("Scripting.FileSystemObject") set logfile = fso.GetFile(SAPIROOT & "\builder\logs\" & logname) set fstream = logfile.OpenAsTextStream do while fstream.AtEndOfStream <> True linein = fstream.ReadLine ' get last line in file loop fstream.Close() GetErrLine = linein end function ' format of VS6 error line is: ' all - 0 error(s), 4 warning(s) chkerrline = GetErrLine("chkbld.log") chkvals = split(chkerrline) chkerrs = chkvals(2) chkwarns = chkvals(4) wscript.echo "Debug build completed with: errors=" & chkerrs & ", warnings=" & chkwarns freerrline = GetErrLine("frebld.log") frevals = split(freerrline) freerrs = frevals(2) frewarns = frevals(4) wscript.echo "Release build completed with: errors=" & freerrs & ", warnings=" & frewarns if (chkerrs > 0 and freerrs > 0) then wscript.echo "Both builds completed with errors, build will be halted" wscript.quit -1 else wscript.quit 0 end if
'---------------------------------------------------------------------- ' ' Copyright (c) Microsoft Corporation. All rights reserved. ' ' Abstract: ' prndrvr.vbs - driver script for WMI on Whistler ' used to add, delete, and list drivers. ' ' Usage: ' prndrvr [-adlx?] [-m model][-v version][-e environment][-s server] ' [-u user name][-w password][-h file path][-i inf file] ' ' Example: ' prndrvr -a -m "driver" -v 3 -e "Windows NT x86" ' prndrvr -d -m "driver" -v 2 -e "Windows NT x86" ' prndrvr -x -s server ' prndrvr -l -s server ' '---------------------------------------------------------------------- option explicit ' ' Debugging trace flags, to enable debug output trace message ' change gDebugFlag to true. ' const kDebugTrace = 1 const kDebugError = 2 dim gDebugFlag gDebugFlag = false ' ' Operation action values. ' const kActionUnknown = 0 const kActionAdd = 1 const kActionDel = 2 const kActionDelAll = 3 const kActionList = 4 const kErrorSuccess = 0 const kErrorFailure = 1 const kNameSpace = "root\cimv2" ' ' Generic strings ' const L_Empty_Text = "" const L_Space_Text = " " const L_Error_Text = "Error" const L_Success_Text = "Success" const L_Failed_Text = "Failed" const L_Hex_Text = "0x" const L_Printer_Text = "Printer" const L_Operation_Text = "Operation" const L_Provider_Text = "Provider" const L_Description_Text = "Description" const L_Debug_Text = "Debug:" ' ' General usage messages ' const L_Help_Help_General01_Text = "Usage: prndrvr [-adlx?] [-m model][-v version][-e environment][-s server]" const L_Help_Help_General02_Text = " [-u user name][-w password][-h path][-i inf file]" const L_Help_Help_General03_Text = "Arguments:" const L_Help_Help_General04_Text = "-a - add the specified driver" const L_Help_Help_General05_Text = "-d - delete the specified driver" const L_Help_Help_General06_Text = "-e - environment" const L_Help_Help_General07_Text = "-h - driver file path" const L_Help_Help_General08_Text = "-i - fully qualified inf file name" const L_Help_Help_General09_Text = "-l - list all drivers" const L_Help_Help_General10_Text = "-m - driver model name" const L_Help_Help_General11_Text = "-s - server name" const L_Help_Help_General12_Text = "-u - user name" const L_Help_Help_General13_Text = "-v - version" const L_Help_Help_General14_Text = "-w - password" const L_Help_Help_General15_Text = "-x - delete all drivers that are not in use" const L_Help_Help_General16_Text = "-? - display command usage" const L_Help_Help_General17_Text = "Examples:" const L_Help_Help_General18_Text = "prndrvr -a -m ""driver"" -v 3 -e ""Windows NT x86""" const L_Help_Help_General19_Text = "prndrvr -d -m ""driver"" -v 3 -e ""Windows NT x86""" const L_Help_Help_General20_Text = "prndrvr -a -m ""driver"" -v 3 -e ""Windows NT x86"" -i c:\temp\drv\drv.inf -h c:\temp\drv" const L_Help_Help_General21_Text = "prndrvr -l -s server" const L_Help_Help_General22_Text = "prndrvr -x -s server" const L_Help_Help_General23_Text = "Remarks:" const L_Help_Help_General24_Text = "The inf file name must be fully qualified. If the inf name is not specified, the script uses" const L_Help_Help_General25_Text = "the ntprint.inf file in the inf subdirectory of the Windows directory." const L_Help_Help_General26_Text = "If the driver path is not specified, the script searches for driver files in the driver.cab file." const L_Help_Help_General27_Text = "The -x option deletes all additional printer drivers (drivers installed for use on clients running" const L_Help_Help_General28_Text = "alternate versions of Windows), even if the primary driver is in use. If the fax component is installed," const L_Help_Help_General29_Text = "this option deletes any additional fax drivers. The primary fax driver is also deleted if it is not" const L_Help_Help_General30_Text = "in use (i.e. if there is no queue using it). If the primary fax driver is deleted, the only way to" const L_Help_Help_General31_Text = "re-enable fax is to reinstall the fax component." ' ' Messages to be displayed if the scripting host is not cscript ' const L_Help_Help_Host01_Text = "Please run this script using CScript." const L_Help_Help_Host02_Text = "This can be achieved by" const L_Help_Help_Host03_Text = "1. Using ""CScript script.vbs arguments"" or" const L_Help_Help_Host04_Text = "2. Changing the default Windows Scripting Host to CScript" const L_Help_Help_Host05_Text = " using ""CScript //H:CScript //S"" and running the script " const L_Help_Help_Host06_Text = " ""script.vbs arguments""." ' ' General error messages ' const L_Text_Error_General01_Text = "The scripting host could not be determined." const L_Text_Error_General02_Text = "Unable to parse command line." const L_Text_Error_General03_Text = "Win32 error code" ' ' Miscellaneous messages ' const L_Text_Msg_General01_Text = "Added printer driver" const L_Text_Msg_General02_Text = "Unable to add printer driver" const L_Text_Msg_General03_Text = "Unable to delete printer driver" const L_Text_Msg_General04_Text = "Deleted printer driver" const L_Text_Msg_General05_Text = "Unable to enumerate printer drivers" const L_Text_Msg_General06_Text = "Number of printer drivers enumerated" const L_Text_Msg_General07_Text = "Number of printer drivers deleted" const L_Text_Msg_General08_Text = "Attempting to delete printer driver" const L_Text_Msg_General09_Text = "Unable to list dependent files" const L_Text_Msg_General10_Text = "Unable to get SWbemLocator object" const L_Text_Msg_General11_Text = "Unable to connect to WMI service" ' ' Printer driver properties ' const L_Text_Msg_Driver01_Text = "Server name" const L_Text_Msg_Driver02_Text = "Driver name" const L_Text_Msg_Driver03_Text = "Version" const L_Text_Msg_Driver04_Text = "Environment" const L_Text_Msg_Driver05_Text = "Monitor name" const L_Text_Msg_Driver06_Text = "Driver path" const L_Text_Msg_Driver07_Text = "Data file" const L_Text_Msg_Driver08_Text = "Config file" const L_Text_Msg_Driver09_Text = "Help file" const L_Text_Msg_Driver10_Text = "Dependent files" ' ' Debug messages ' const L_Text_Dbg_Msg01_Text = "In function AddDriver" const L_Text_Dbg_Msg02_Text = "In function DelDriver" const L_Text_Dbg_Msg03_Text = "In function DelAllDrivers" const L_Text_Dbg_Msg04_Text = "In function ListDrivers" const L_Text_Dbg_Msg05_Text = "In function ParseCommandLine" main ' ' Main execution starts here ' sub main dim iAction dim iRetval dim strServer dim strModel dim strPath dim uVersion dim strEnvironment dim strInfFile dim strUser dim strPassword ' ' Abort if the host is not cscript ' if not IsHostCscript() then call wscript.echo(L_Help_Help_Host01_Text & vbCRLF & L_Help_Help_Host02_Text & vbCRLF & _ L_Help_Help_Host03_Text & vbCRLF & L_Help_Help_Host04_Text & vbCRLF & _ L_Help_Help_Host05_Text & vbCRLF & L_Help_Help_Host06_Text & vbCRLF) wscript.quit end if ' ' Get command line parameters ' iRetval = ParseCommandLine(iAction, strServer, strModel, strPath, uVersion, _ strEnvironment, strInfFile, strUser, strPAssword) if iRetval = kErrorSuccess then select case iAction case kActionAdd iRetval = AddDriver(strServer, strModel, strPath, uVersion, _ strEnvironment, strInfFile, strUser, strPassword) case kActionDel iRetval = DelDriver(strServer, strModel, uVersion, strEnvironment, strUser, strPassword) case kActionDelAll iRetval = DelAllDrivers(strServer, strUser, strPassword) case kActionList iRetval = ListDrivers(strServer, strUser, strPassword) case kActionUnknown Usage(true) exit sub case else Usage(true) exit sub end select end if end sub ' ' Add a driver ' function AddDriver(strServer, strModel, strFilePath, uVersion, strEnvironment, strInfFile, strUser, strPassword) on error resume next DebugPrint kDebugTrace, L_Text_Dbg_Msg01_Text dim oDriver dim oService dim iResult dim uResult ' ' Initialize return value ' iResult = kErrorFailure if WmiConnect(strServer, kNameSpace, strUser, strPassword, oService) then set oDriver = oService.Get("Win32_PrinterDriver") else AddDriver = kErrorFailure exit function end if ' ' Check if Get was successful ' if Err.Number = kErrorSuccess then oDriver.Name = strModel oDriver.SupportedPlatform = strEnvironment oDriver.Version = uVersion oDriver.FilePath = strFilePath oDriver.InfName = strInfFile uResult = oDriver.AddPrinterDriver(oDriver) if Err.Number = kErrorSuccess then if uResult = kErrorSuccess then wscript.echo L_Text_Msg_General01_Text & L_Space_Text & oDriver.Name iResult = kErrorSuccess else wscript.echo L_Text_Msg_General02_Text & L_Space_Text & strModel & L_Space_Text _ & L_Text_Error_General03_Text & L_Space_Text & uResult end if else wscript.echo L_Text_Msg_General02_Text & L_Space_Text & strModel & L_Space_Text _ & L_Error_Text & L_Space_Text & L_Hex_Text & hex(Err.Number) & L_Space_Text & Err.Description end if else wscript.echo L_Text_Msg_General02_Text & L_Space_Text & strModel & L_Space_Text _ & L_Error_Text & L_Space_Text & L_Hex_Text & hex(Err.Number) & L_Space_Text & Err.Description end if AddDriver = iResult end function ' ' Delete a driver ' function DelDriver(strServer, strModel, uVersion, strEnvironment, strUser, strPassword) on error resume next DebugPrint kDebugTrace, L_Text_Dbg_Msg02_Text dim oDriver dim oService dim iResult dim strObject ' ' Initialize return value ' iResult = kErrorFailure ' ' Build the key that identifies the driver instance. ' strObject = strModel & "," & CStr(uVersion) & "," & strEnvironment if WmiConnect(strServer, kNameSpace, strUser, strPassword, oService) then set oDriver = oService.Get("Win32_PrinterDriver.Name='" & strObject & "'") else DelDriver = kErrorFailure exit function end if ' ' Check if Get was successful ' if Err.Number = kErrorSuccess then ' ' Delete the printer driver instance ' oDriver.Delete_ if Err.Number = kErrorSuccess then wscript.echo L_Text_Msg_General04_Text & L_Space_Text & oDriver.Name iResult = kErrorSuccess else wscript.echo L_Text_Msg_General03_Text & L_Space_Text & strModel & L_Space_Text _ & L_Error_Text & L_Space_Text & L_Hex_Text & hex(Err.Number) _ & L_Space_Text & Err.Description call LastError() end if else wscript.echo L_Text_Msg_General03_Text & L_Space_Text & strModel & L_Space_Text _ & L_Error_Text & L_Space_Text & L_Hex_Text & hex(Err.Number) _ & L_Space_Text & Err.Description end if DelDriver = iResult end function ' ' Delete all drivers ' function DelAllDrivers(strServer, strUser, strPassword) on error resume next DebugPrint kDebugTrace, L_Text_Dbg_Msg03_Text dim Drivers dim oDriver dim oService dim iResult dim iTotal dim iTotalDeleted dim vntDependentFiles dim strDriverName if WmiConnect(strServer, kNameSpace, strUser, strPassword, oService) then set Drivers = oService.InstancesOf("Win32_PrinterDriver") else DelAllDrivers = kErrorFailure exit function end if if Err.Number <> kErrorSuccess then wscript.echo L_Text_Msg_General05_Text & L_Space_Text & L_Error_Text & L_Space_Text _ & L_Hex_Text & hex(Err.Number) & L_Space_Text & Err.Description DelAllDrivers = kErrorFailure exit function end if iTotal = 0 iTotalDeleted = 0 for each oDriver in Drivers iTotal = iTotal + 1 wscript.echo wscript.echo L_Text_Msg_General08_Text wscript.echo L_Text_Msg_Driver01_Text & L_Space_Text & strServer wscript.echo L_Text_Msg_Driver02_Text & L_Space_Text & oDriver.Name wscript.echo L_Text_Msg_Driver03_Text & L_Space_Text & oDriver.Version wscript.echo L_Text_Msg_Driver04_Text & L_Space_Text & oDriver.SupportedPlatform strDriverName = oDriver.Name ' ' Example of how to delete an instance of a printer driver ' oDriver.Delete_ if Err.Number = kErrorSuccess then wscript.echo L_Text_Msg_General04_Text & L_Space_Text & oDriver.Name iTotalDeleted = iTotalDeleted + 1 else ' ' We cannot use oDriver.Name to display the driver name, because the SWbemLastError ' that the function LastError() looks at would be overwritten. For that reason we ' use strDriverName for accessing the driver name ' wscript.echo L_Text_Msg_General03_Text & L_Space_Text & strDriverName & L_Space_Text _ & L_Error_Text & L_Space_Text & L_Hex_Text & hex(Err.Number) _ & L_Space_Text & Err.Description ' ' Try getting extended error information ' call LastError() Err.Clear end if next wscript.echo L_Empty_Text wscript.echo L_Text_Msg_General06_Text & L_Space_Text & iTotal wscript.echo L_Text_Msg_General07_Text & L_Space_Text & iTotalDeleted DelAllDrivers = kErrorSuccess end function ' ' List drivers ' function ListDrivers(strServer, strUser, strPassword) on error resume next DebugPrint kDebugTrace, L_Text_Dbg_Msg04_Text dim Drivers dim oDriver dim oService dim iResult dim iTotal dim vntDependentFiles if WmiConnect(strServer, kNameSpace, strUser, strPassword, oService) then set Drivers = oService.InstancesOf("Win32_PrinterDriver") else ListDrivers = kErrorFailure exit function end if if Err.Number <> kErrorSuccess then wscript.echo L_Text_Msg_General05_Text & L_Space_Text & L_Error_Text & L_Space_Text _ & L_Hex_Text & hex(Err.Number) & L_Space_Text & Err.Description ListDrivers = kErrorFailure exit function end if iTotal = 0 for each oDriver in Drivers iTotal = iTotal + 1 wscript.echo wscript.echo L_Text_Msg_Driver01_Text & L_Space_Text & strServer wscript.echo L_Text_Msg_Driver02_Text & L_Space_Text & oDriver.Name wscript.echo L_Text_Msg_Driver03_Text & L_Space_Text & oDriver.Version wscript.echo L_Text_Msg_Driver04_Text & L_Space_Text & oDriver.SupportedPlatform wscript.echo L_Text_Msg_Driver05_Text & L_Space_Text & oDriver.MonitorName wscript.echo L_Text_Msg_Driver06_Text & L_Space_Text & oDriver.DriverPath wscript.echo L_Text_Msg_Driver07_Text & L_Space_Text & oDriver.DataFile wscript.echo L_Text_Msg_Driver08_Text & L_Space_Text & oDriver.ConfigFile wscript.echo L_Text_Msg_Driver09_Text & L_Space_Text & oDriver.HelpFile vntDependentFiles = oDriver.DependentFiles ' ' If there are no dependent files, the method will set DependentFiles to ' an empty variant, so we check if the variant is an array of variants ' if VarType(vntDependentFiles) = (vbArray + vbVariant) then PrintDepFiles oDriver.DependentFiles end if Err.Clear next wscript.echo L_Empty_Text wscript.echo L_Text_Msg_General06_Text & L_Space_Text & iTotal ListDrivers = kErrorSuccess end function ' ' Prints the contents of an array of variants ' sub PrintDepFiles(Param) on error resume next dim iIndex iIndex = LBound(Param) if Err.Number = 0 then wscript.echo L_Text_Msg_Driver10_Text for iIndex = LBound(Param) to UBound(Param) wscript.echo L_Space_Text & Param(iIndex) next else wscript.echo L_Text_Msg_General09_Text & L_Space_Text & L_Error_Text & L_Space_Text _ & L_Hex_Text & hex(Err.Number) & L_Space_Text & Err.Description end if end sub ' ' Debug display helper function ' sub DebugPrint(uFlags, strString) if gDebugFlag = true then if uFlags = kDebugTrace then wscript.echo L_Debug_Text & L_Space_Text & strString end if if uFlags = kDebugError then if Err <> 0 then wscript.echo L_Debug_Text & L_Space_Text & strString & L_Space_Text _ & L_Error_Text & L_Space_Text & L_Hex_Text & hex(Err.Number) _ & L_Space_Text & Err.Description end if end if end if end sub ' ' Parse the command line into its components ' function ParseCommandLine(iAction, strServer, strModel, strPath, uVersion, _ strEnvironment, strInfFile, strUser, strPassword) on error resume next DebugPrint kDebugTrace, L_Text_Dbg_Msg05_Text dim oArgs dim iIndex iAction = kActionUnknown iIndex = 0 set oArgs = wscript.Arguments while iIndex < oArgs.Count select case oArgs(iIndex) case "-a" iAction = kActionAdd case "-d" iAction = kActionDel case "-l" iAction = kActionList case "-x" iAction = kActionDelAll case "-s" iIndex = iIndex + 1 strServer = RemoveBackslashes(oArgs(iIndex)) case "-m" iIndex = iIndex + 1 strModel = oArgs(iIndex) case "-h" iIndex = iIndex + 1 strPath = oArgs(iIndex) case "-v" iIndex = iIndex + 1 uVersion = oArgs(iIndex) case "-e" iIndex = iIndex + 1 strEnvironment = oArgs(iIndex) case "-i" iIndex = iIndex + 1 strInfFile = oArgs(iIndex) case "-u" iIndex = iIndex + 1 strUser = oArgs(iIndex) case "-w" iIndex = iIndex + 1 strPassword = oArgs(iIndex) case "-?" Usage(true) exit function case else Usage(true) exit function end select iIndex = iIndex + 1 wend if Err.Number <> 0 then wscript.echo L_Text_Error_General02_Text & L_Space_Text & L_Error_Text & L_Space_Text _ & L_Hex_Text & hex(Err.Number) & L_Space_text & Err.Description ParseCommandLine = kErrorFailure else ParseCommandLine = kErrorSuccess end if end function ' ' Display command usage. ' sub Usage(bExit) wscript.echo L_Help_Help_General01_Text wscript.echo L_Help_Help_General02_Text wscript.echo L_Help_Help_General03_Text wscript.echo L_Help_Help_General04_Text wscript.echo L_Help_Help_General05_Text wscript.echo L_Help_Help_General06_Text wscript.echo L_Help_Help_General07_Text wscript.echo L_Help_Help_General08_Text wscript.echo L_Help_Help_General09_Text wscript.echo L_Help_Help_General10_Text wscript.echo L_Help_Help_General11_Text wscript.echo L_Help_Help_General12_Text wscript.echo L_Help_Help_General13_Text wscript.echo L_Help_Help_General14_Text wscript.echo L_Help_Help_General15_Text wscript.echo L_Help_Help_General16_Text wscript.echo L_Empty_Text wscript.echo L_Help_Help_General17_Text wscript.echo L_Help_Help_General18_Text wscript.echo L_Help_Help_General19_Text wscript.echo L_Help_Help_General20_Text wscript.echo L_Help_Help_General21_Text wscript.echo L_Help_Help_General22_Text wscript.echo L_Help_Help_General23_Text wscript.echo L_Help_Help_General24_Text wscript.echo L_Help_Help_General25_Text wscript.echo L_Help_Help_General26_Text wscript.echo L_Empty_Text wscript.echo L_Help_Help_General27_Text wscript.echo L_Help_Help_General28_Text wscript.echo L_Help_Help_General29_Text wscript.echo L_Help_Help_General30_Text wscript.echo L_Help_Help_General31_Text if bExit then wscript.quit(1) end if end sub ' ' Determines which program is being used to run this script. ' Returns true if the script host is cscript.exe ' function IsHostCscript() on error resume next dim strFullName dim strCommand dim i, j dim bReturn bReturn = false strFullName = WScript.FullName i = InStr(1, strFullName, ".exe", 1) if i <> 0 then j = InStrRev(strFullName, "\", i, 1) if j <> 0 then strCommand = Mid(strFullName, j+1, i-j-1) if LCase(strCommand) = "cscript" then bReturn = true end if end if end if if Err <> 0 then wscript.echo L_Text_Error_General01_Text & L_Space_Text & L_Error_Text & L_Space_Text _ & L_Hex_Text & hex(Err.Number) & L_Space_Text & Err.Description end if IsHostCscript = bReturn end function ' ' Retrieves extended information about the last error that occurred ' during a WBEM operation. The methods that set an SWbemLastError ' object are GetObject, PutInstance, DeleteInstance ' sub LastError() on error resume next dim oError set oError = CreateObject("WbemScripting.SWbemLastError") if Err = kErrorSuccess then wscript.echo L_Operation_Text & L_Space_Text & oError.Operation wscript.echo L_Provider_Text & L_Space_Text & oError.ProviderName wscript.echo L_Description_Text & L_Space_Text & oError.Description wscript.echo L_Text_Error_General03_Text & L_Space_Text & oError.StatusCode end if end sub ' ' Connects to the WMI service on a server. oService is returned as a service ' object (SWbemServices) ' function WmiConnect(strServer, strNameSpace, strUser, strPassword, oService) on error resume next dim oLocator dim bResult oService = null bResult = false set oLocator = CreateObject("WbemScripting.SWbemLocator") if Err = kErrorSuccess then set oService = oLocator.ConnectServer(strServer, strNameSpace, strUser, strPassword) if Err = kErrorSuccess then bResult = true oService.Security_.impersonationlevel = 3 ' ' Required to perform administrative tasks on the spooler service ' oService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege" Err.Clear else wscript.echo L_Text_Msg_General11_Text & L_Space_Text & L_Error_Text _ & L_Space_Text & L_Hex_Text & hex(Err.Number) & L_Space_Text _ & Err.Description end if else wscript.echo L_Text_Msg_General10_Text & L_Space_Text & L_Error_Text _ & L_Space_Text & L_Hex_Text & hex(Err.Number) & L_Space_Text _ & Err.Description end if WmiConnect = bResult end function ' ' Remove leading "\\" from server name ' function RemoveBackslashes(strServer) dim strRet strRet = strServer if Left(strServer, 2) = "\\" and Len(strServer) > 2 then strRet = Mid(strServer, 3) end if RemoveBackslashes = strRet end function
<filename>Task/Roman-numerals-Decode/VBScript/roman-numerals-decode.vb<gh_stars>1-10 ' Roman numerals Encode - Visual Basic - 18/04/2019 Function toRoman(ByVal value) Dim arabic Dim roman Dim i, result arabic = Array(1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1) roman = Array("M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I") For i = 0 To 12 Do While value >= arabic(i) result = result + roman(i) value = value - arabic(i) Loop Next 'i toRoman = result End Function 'toRoman n=InputBox("Number, please","Roman numerals/Encode") code=MsgBox(n & vbCrlf & toRoman(n),vbOKOnly+vbExclamation,"Roman numerals/Encode") If code=vbOK Then ok=1
<filename>Task/100-doors/VBA/100-doors.vba Sub Rosetta_100Doors() Dim Door(100) As Boolean, i As Integer, j As Integer For i = 1 To 100 Step 1 For j = i To 100 Step i Door(j) = Not Door(j) Next j If Door(i) = True Then Debug.Print "Door " & i & " is Open" Else Debug.Print "Door " & i & " is Closed" End If Next i End Sub
<reponame>npocmaka/Windows-Server-2003 REM REM LOCALIZATION REM L_SWITCH_OPERATION = "-t" L_SWITCH_SERVER = "-s" L_SWITCH_INSTANCE_ID = "-v" L_SWITCH_EXPIRE_ID = "-i" L_SWITCH_TIME = "-h" L_SWITCH_NEWSGROUPS = "-n" L_SWITCH_NAME = "-p" L_SWITCH_ONETIME = "-o" L_OP_ADD = "a" L_OP_DELETE = "d" L_OP_GET = "g" L_OP_SET = "s" L_OP_ENUMERATE = "e" L_DESC_PROGRAM = "rexpire - Set server expiration policies" L_DESC_ADD = "add expiration policy" L_DESC_DELETE = "delete expiration policy" L_DESC_GET = "get expiration policy" L_DESC_SET = "set expiration policy" L_DESC_ENUMERATE = "enumerate expiration policies" L_DESC_OPERATIONS = "<operations>" L_DESC_SERVER = "<server> Specify computer to configure" L_DESC_INSTANCE_ID = "<virtual server id> Specify virtual server id" L_DESC_EXPIRE_ID = "<expire id> Specify expiration policy id" L_DESC_TIME = "<expire time> Specify number of hours until articles are expired" L_DESC_NEWSGROUPS = "<newsgroups> Specify newsgroup to which policy is applied" L_DESC_NAME = "<policy name> Expire policy name" L_DESC_ONETIME = "[true | false] One time expire policy?" L_DESC_EXAMPLES = "Examples:" L_DESC_EXAMPLE1 = "rexpire.vbs -t e -v 1" L_DESC_EXAMPLE2 = "rexpire.vbs -t a -n alt.binaries.* -h 24" L_DESC_EXAMPLE3 = "rexpire.vbs -t s -i 1 -h 24" L_DESC_EXAMPLE4 = "rexpire.vbs -t d -i 1" L_STR_EXPIRE_NAME = "Name:" L_STR_EXPIRE_ID = "Expire ID:" L_STR_EXPIRE_TIME = "Time horizon:" L_STR_NEWSGROUPS = "Newsgroups:" L_STR_OLD_POLICY = "Old Policy" L_STR_NEW_POLICY = "New Policy" L_ERR_MUST_ENTER_ID = "You must enter an expire policy ID" L_ERR_EXPIRE_ID_NOT_FOUND = "Error: There is no expiration policy with that ID" REM REM END LOCALIZATION REM REM REM --- Globals --- REM dim g_dictParms dim g_admin set g_dictParms = CreateObject ( "Scripting.Dictionary" ) set g_admin = CreateObject ( "NntpAdm.Expiration" ) REM REM --- Set argument defaults --- REM g_dictParms(L_SWITCH_OPERATION) = "" g_dictParms(L_SWITCH_SERVER) = "" g_dictParms(L_SWITCH_INSTANCE_ID) = "1" g_dictParms(L_SWITCH_EXPIRE_ID) = "" g_dictParms(L_SWITCH_TIME) = "-1" g_dictParms(L_SWITCH_NEWSGROUPS) = "" g_dictParms(L_SWITCH_NAME) = "" g_dictParms(L_SWITCH_ONETIME) = False REM REM --- Begin Main Program --- REM if NOT ParseCommandLine ( g_dictParms, WScript.Arguments ) then usage WScript.Quit ( 0 ) end if dim cExpires dim i dim id dim index REM REM Debug: print out command line arguments: REM REM switches = g_dictParms.keys REM args = g_dictParms.items REM REM REM for i = 0 to g_dictParms.Count - 1 REM WScript.echo switches(i) & " = " & args(i) REM next REM g_admin.Server = g_dictParms(L_SWITCH_SERVER) g_admin.ServiceInstance = g_dictParms(L_SWITCH_INSTANCE_ID) On Error Resume Next g_admin.Enumerate if ( Err.Number <> 0 ) then WScript.echo " Error enumerating Expiration: " & Err.Description & "(" & Err.Number & ")" end if id = g_dictParms ( L_SWITCH_EXPIRE_ID ) select case g_dictParms(L_SWITCH_OPERATION) case L_OP_ENUMERATE REM REM List the existing expiration policies: REM cExpires = g_admin.Count for i = 0 to cExpires - 1 On Error Resume Next g_admin.GetNth i if ( Err.Number <> 0 ) then WScript.echo " Error getting Expiration: " & Err.Description & "(" & Err.Number & ")" else PrintExpire g_admin end if next case L_OP_ADD REM REM Add a new expiration policy REM if ( g_dictParms ( L_SWITCH_NEWSGROUPS ) = "" ) then usage else dim strPolicyName strPolicyName = g_dictParms ( L_SWITCH_NAME ) if ( g_dictParms ( L_SWITCH_ONETIME ) ) then strPolicyName = strPolicyName & "@EXPIRE:ROADKILL" end if g_admin.PolicyName = strPolicyName g_admin.ExpireTime = g_dictParms ( L_SWITCH_TIME ) g_admin.ExpireSize = "-1" g_admin.NewsgroupsVariant = SemicolonListToArray ( g_dictParms ( L_SWITCH_NEWSGROUPS ) ) g_admin.Add PrintExpire g_admin end if case L_OP_DELETE REM REM Delete an expiration policy REM if id = "" OR NOT IsNumeric ( id ) then WScript.Echo L_ERR_MUST_ENTER_ID WScript.Quit 0 end if index = g_admin.FindID ( id ) if index = -1 then WScript.Echo L_ERR_EXPIRE_ID_NOT_FOUND WScript.Quit 0 end if On Error Resume Next g_admin.Remove id if ( Err.Number <> 0 ) then WScript.echo " Error Removing Expiration: " & Err.Description & "(" & Err.Number & ")" else PrintExpire g_admin end if case L_OP_GET REM REM Get a specific expiration policy: REM index = g_admin.FindID(id) if index = -1 then WScript.Echo L_ERR_EXPIRE_ID_NOT_FOUND WScript.Quit 0 end if On Error Resume Next g_admin.GetNth index if ( Err.Number <> 0 ) then WScript.echo " Error getting Expiration: " & Err.Description & "(" & Err.Number & ")" else PrintExpire g_admin end if case L_OP_SET REM REM Change an existing expiration policy: REM dim strNewName dim nNewTime dim rgNewGroups index = g_admin.FindID(id) if index = -1 then WScript.Echo L_ERR_EXPIRE_ID_NOT_FOUND WScript.Quit 0 end if On Error Resume Next g_admin.GetNth index if ( Err.Number <> 0 ) then WScript.echo " Error getting Expiration: " & Err.Description & "(" & Err.Number & ")" else WScript.echo L_STR_OLD_POLICY PrintExpire g_admin WScript.echo WScript.echo L_STR_NEW_POLICY end if strNewName = g_admin.PolicyName nNewTime = g_admin.ExpireTime rgNewGroups = g_admin.NewsgroupsVariant if g_dictParms ( L_SWITCH_NAME ) <> "" then strNewName = g_dictParms ( L_SWITCH_NAME ) end if if g_dictParms ( L_SWITCH_TIME ) <> "" then nNewTime = g_dictParms ( L_SWITCH_TIME ) end if if g_dictParms ( L_SWITCH_NEWSGROUPS ) <> "" then rgNewGroups = SemicolonListToArray ( g_dictParms ( L_SWITCH_NEWSGROUPS ) ) end if if g_dictParms ( L_SWITCH_ONETIME ) then strNewName = strNewName & "@EXPIRE:ROADKILL" end if g_admin.PolicyName = strNewName g_admin.ExpireTime = nNewTime g_admin.NewsgroupsVariant = rgNewGroups On Error Resume Next g_admin.Set if ( Err.Number <> 0 ) then WScript.echo " Error setting Expiration: " & Err.Description & "(" & Err.Number & ")" else PrintExpire g_admin end if case else usage end select WScript.Quit 0 REM REM --- End Main Program --- REM REM REM ParseCommandLine ( dictParameters, cmdline ) REM Parses the command line parameters into the given dictionary REM REM Arguments: REM dictParameters - A dictionary containing the global parameters REM cmdline - Collection of command line arguments REM REM Returns - Success code REM Function ParseCommandLine ( dictParameters, cmdline ) dim fRet dim cArgs dim i dim strSwitch dim strArgument fRet = TRUE cArgs = cmdline.Count i = 0 do while (i < cArgs) REM REM Parse the switch and its argument REM if i + 1 >= cArgs then REM REM Not enough command line arguments - Fail REM fRet = FALSE exit do end if strSwitch = cmdline(i) i = i + 1 strArgument = cmdline(i) i = i + 1 REM REM Add the switch,argument pair to the dictionary REM if NOT dictParameters.Exists ( strSwitch ) then REM REM Bad switch - Fail REM fRet = FALSE exit do end if dictParameters(strSwitch) = strArgument loop ParseCommandLine = fRet end function REM REM SemicolonListToArray ( strList ) REM Converts a semi colon delimited list to an array of strings REM REM eg. str1;str2;str3;str4 -> ["str1", "str2", "str3", "str4"] REM Function SemicolonListToArray ( strListIn ) dim rgItems dim strItem dim strList dim index dim i ReDim rgItems ( 10 ) strList = strListIn i = 0 do until strList = "" REM REM Debug: print out newsgroup list as we go: REM WScript.Echo strList REM index = InStr ( strList, ";" ) if index = 0 then REM No trailing ";", so use the whole string strItem = strList strList = "" else REM Use the string up to the ";" strItem = Left ( strList, index - 1 ) strList = Right ( strList, Len ( strList ) - index ) end if ReDim preserve rgItems ( i ) rgItems ( i ) = strItem i = i + 1 loop REM return the array SemicolonListToArray = rgItems end function REM REM Usage () REM prints out the description of the command line arguments REM Sub Usage WScript.Echo L_DESC_PROGRAM WScript.Echo vbTab & L_SWITCH_OPERATION & " " & L_DESC_OPERATIONS WScript.Echo vbTab & vbTab & L_OP_ADD & vbTab & L_DESC_ADD WScript.Echo vbTab & vbTab & L_OP_DELETE & vbTab & L_DESC_DELETE WScript.Echo vbTab & vbTab & L_OP_GET & vbTab & L_DESC_GET WScript.Echo vbTab & vbTab & L_OP_SET & vbTab & L_DESC_SET WScript.Echo vbTab & vbTab & L_OP_ENUMERATE & vbTab & L_DESC_ENUMERATE WScript.Echo vbTab & L_SWITCH_SERVER & " " & L_DESC_SERVER WScript.Echo vbTab & L_SWITCH_INSTANCE_ID & " " & L_DESC_INSTANCE_ID WScript.Echo vbTab & L_SWITCH_EXPIRE_ID & " " & L_DESC_EXPIRE_ID WScript.Echo vbTab & L_SWITCH_TIME & " " & L_DESC_TIME WScript.Echo vbTab & L_SWITCH_NEWSGROUPS & " " & L_DESC_NEWSGROUPS WScript.Echo vbTab & L_SWITCH_NAME & " " & L_DESC_NAME WScript.Echo vbTab & L_SWITCH_ONETIME & " " & L_DESC_ONETIME WScript.Echo WScript.Echo L_DESC_EXAMPLES WScript.Echo L_DESC_EXAMPLE1 WScript.Echo L_DESC_EXAMPLE2 WScript.Echo L_DESC_EXAMPLE3 WScript.Echo L_DESC_EXAMPLE4 end sub Sub PrintExpire ( admobj ) WScript.Echo L_STR_EXPIRE_ID & " " & admobj.ExpireId WScript.Echo L_STR_EXPIRE_NAME & " " & admobj.PolicyName WScript.Echo L_STR_EXPIRE_TIME & " " & admobj.ExpireTime dim newsgroups dim cGroups dim i newsgroups = admobj.NewsgroupsVariant cGroups = UBound ( newsgroups ) for i = 0 to cGroups WScript.Echo L_STR_NEWSGROUPS & " " & newsgroups(i) next end sub
Function Luhn_Test(cc) cc = RevString(cc) s1 = 0 s2 = 0 For i = 1 To Len(cc) If i Mod 2 > 0 Then s1 = s1 + CInt(Mid(cc,i,1)) Else tmp = CInt(Mid(cc,i,1))*2 If tmp < 10 Then s2 = s2 + tmp Else s2 = s2 + CInt(Right(CStr(tmp),1)) + 1 End If End If Next If Right(CStr(s1 + s2),1) = "0" Then Luhn_Test = "Valid" Else Luhn_Test = "Invalid" End If End Function Function RevString(s) For i = Len(s) To 1 Step -1 RevString = RevString & Mid(s,i,1) Next End Function WScript.Echo "49927398716 is " & Luhn_Test("49927398716") WScript.Echo "49927398717 is " & Luhn_Test("49927398717") WScript.Echo "1234567812345678 is " & Luhn_Test("1234567812345678") WScript.Echo "1234567812345670 is " & Luhn_Test("1234567812345670")
<filename>Task/Set-consolidation/VBA/set-consolidation.vba Private Function has_intersection(set1 As Collection, set2 As Collection) As Boolean For Each element In set1 On Error Resume Next tmp = set2(element) If tmp = element Then has_intersection = True Exit Function End If Next element End Function Private Sub union(set1 As Collection, set2 As Collection) For Each element In set2 On Error Resume Next tmp = set1(element) If tmp <> element Then set1.Add element, element End If Next element End Sub Private Function consolidate(sets As Collection) As Collection For i = sets.Count To 1 Step -1 For j = sets.Count To i + 1 Step -1 If has_intersection(sets(i), sets(j)) Then union sets(i), sets(j) sets.Remove j End If Next j Next i Set consolidate = sets End Function Private Function mc(s As Variant) As Collection Dim res As New Collection For i = 1 To Len(s) res.Add Mid(s, i, 1), Mid(s, i, 1) Next i Set mc = res End Function Private Function ms(t As Variant) As Collection Dim res As New Collection Dim element As Collection For i = LBound(t) To UBound(t) Set element = t(i) res.Add t(i) Next i Set ms = res End Function Private Sub show(x As Collection) Dim t() As String Dim u() As String ReDim t(1 To x.Count) For i = 1 To x.Count ReDim u(1 To x(i).Count) For j = 1 To x(i).Count u(j) = x(i)(j) Next j t(i) = "{" & Join(u, ", ") & "}" Next i Debug.Print "{" & Join(t, ", ") & "}" End Sub Public Sub main() show consolidate(ms(Array(mc("AB"), mc("CD")))) show consolidate(ms(Array(mc("AB"), mc("BD")))) show consolidate(ms(Array(mc("AB"), mc("CD"), mc("DB")))) show consolidate(ms(Array(mc("HIK"), mc("AB"), mc("CD"), mc("DB"), mc("FGH")))) End Sub
<filename>Task/Topological-sort/VBScript/topological-sort-2.vb dim toposort set toposort = new topological toposort.dependencies = "des_system_lib std synopsys std_cell_lib des_system_lib dw02 dw01 ramlib ieee" & vbNewLine & _ "dw01 ieee dw01 dware gtech" & vbNewLine & _ "dw02 ieee dw02 dware" & vbNewLine & _ "dw03 std synopsys dware dw03 dw02 dw01 ieee gtech" & vbNewLine & _ "dw04 dw04 ieee dw01 dware gtech" & vbNewLine & _ "dw05 dw05 ieee dware" & vbNewLine & _ "dw06 dw06 ieee dware" & vbNewLine & _ "dw07 ieee dware" & vbNewLine & _ "dware ieee dware" & vbNewLine & _ "gtech ieee gtech" & vbNewLine & _ "ramlib std ieee" & vbNewLine & _ "std_cell_lib ieee std_cell_lib" & vbNewLine & _ "synopsys " dim k for each k in toposort.keys wscript.echo "----- " & k toposort.resolve k wscript.echo "-----" toposort.reset next
Option Base 1 Private Function countingSort(array_ As Variant, mina As Long, maxa As Long) As Variant Dim count() As Integer ReDim count(maxa - mina + 1) For i = 1 To UBound(array_) count(array_(i) - mina + 1) = count(array_(i) - mina + 1) + 1 Next i Dim z As Integer: z = 1 For i = mina To maxa For j = 1 To count(i - mina + 1) array_(z) = i z = z + 1 Next j Next i countingSort = array_ End Function Public Sub main() s = [{5, 3, 1, 7, 4, 1, 1, 20}] Debug.Print Join(countingSort(s, WorksheetFunction.Min(s), WorksheetFunction.Max(s)), ", ") End Sub
'//on error resume next set objArgs = wscript.Arguments if objArgs.count < 1 then PrintUsage() wscript.quit(1) end if if objArgs.count = 1 then if objArgs(0) = "/?" then PrintUsage() wscript.quit end if end if strVolume = Replace(objArgs(0), "\", "\\") DIM fFixErrors DIM fRecoverBadSectors DIM fForceDismount DIM fVigorousIndex DIM fSkipFolderCycle DIM fOkToRunAtBootup fFixErrors = False fRecoverBadSectors = False fForceDismount = False fVigorousIndex= True fSkipFolderCycle= False fOkToRunAtBootup= False DIM i, j for i = 0 to objArgs.count-1 if (LCase(objArgs(i)) = "/f") then fFixErrors = True end if if (LCase(objArgs(i)) = "/r") then fRecoverBadSectors = True end if if (LCase(objArgs(i)) = "/x") then fForceDismount = True end if if (LCase(objArgs(i)) = "/i") then fVigorousIndex= False end if if (LCase(objArgs(i)) = "/c") then fSkipFolderCycle= True end if if (LCase(objArgs(i)) = "/b") then fOkToRunAtBootup= True end if next '// Get the volume strQuery = "select * from Win32_Volume where Name = '" & strVolume & "'" set VolumeSet = GetObject("winmgmts:").ExecQuery(strQuery) for each obj in VolumeSet set Volume = obj exit for next wscript.echo "Volume: " & Volume.Name Result = Volume.Chkdsk(fFixErrors, fVigorousIndex, fSkipFolderCycle, fForceDismount, fRecoverBadSectors, fOkToRunAtBootup) strMessage = MapErrorCode("Win32_Volume", "Chkdsk", Result) wscript.echo "Volume.Chkdsk returned: " & Result & " : " & strMessage Function MapErrorCode(ByRef strClass, ByRef strMethod, ByRef intCode) set objClass = GetObject("winmgmts:").Get(strClass, &h20000) set objMethod = objClass.methods_(strMethod) values = objMethod.qualifiers_("values") if ubound(values) < intCode then wscript.echo " FAILURE - no error message found for " & intCode & " : " & strClass & "." & strMethod f.writeline ("FAILURE - no error message found for " & intCode & " : " & strClass & "." & strMethod) MapErrorCode = "" else MapErrorCode = values(intCode) end if End Function Function PrintUsage() wscript.echo "chkdsk volumePath /f /r /i /c /x /b" wscript.echo "" wscript.echo "volumePath Specifies the drive path, mount point, or volume name." wscript.echo " /f Fixes errors on the disk." wscript.echo " /r Locates bad sectors and recovers readable information" wscript.echo " (implies /F)." wscript.echo " /x Forces the volume to dismount first if necessary." wscript.echo " All opened handles to the volume would then be invalid" wscript.echo " (implies /F)." wscript.echo " /i NTFS only: Performs a less vigorous check of index entries." wscript.echo " /c NTFS only: Skips checking of cycles within the folder" wscript.echo " structure." wscript.echo " /b Schedules chkdsk operation on reboot if volume is locked" wscript.echo "" wscript.echo "The /i or /c switch reduces the amount of time required to run Chkdsk by" wscript.echo "skipping certain checks of the volume." End Function
<reponame>LaudateCorpus1/RosettaCodeData Function IsSelfDescribing(n) IsSelfDescribing = False Set digit = CreateObject("Scripting.Dictionary") For i = 1 To Len(n) k = Mid(n,i,1) If digit.Exists(k) Then digit.Item(k) = digit.Item(k) + 1 Else digit.Add k,1 End If Next c = 0 For j = 0 To Len(n)-1 l = Mid(n,j+1,1) If digit.Exists(CStr(j)) Then If digit.Item(CStr(j)) = CInt(l) Then c = c + 1 End If ElseIf l = 0 Then c = c + 1 Else Exit For End If Next If c = Len(n) Then IsSelfDescribing = True End If End Function 'testing start_time = Now s = "" For m = 1 To 100000000 If IsSelfDescribing(m) Then WScript.StdOut.WriteLine m End If Next end_time = Now WScript.StdOut.WriteLine "Elapse Time: " & DateDiff("s",start_time,end_time) & " seconds"
VERSION 5.00 Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX" Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX" Begin VB.Form frmData BorderStyle = 0 'None Caption = "Data Profile" ClientHeight = 5730 ClientLeft = 0 ClientTop = 0 ClientWidth = 9570 LinkTopic = "Form1" MaxButton = 0 'False MDIChild = -1 'True MinButton = 0 'False Moveable = 0 'False NegotiateMenus = 0 'False ScaleHeight = 5730 ScaleWidth = 9570 ShowInTaskbar = 0 'False Begin TabDlg.SSTab SSTab1 Height = 5055 Left = 0 TabIndex = 1 TabStop = 0 'False Top = 360 Width = 9480 _ExtentX = 16722 _ExtentY = 8916 _Version = 393216 Tabs = 8 Tab = 7 TabsPerRow = 8 TabHeight = 794 ShowFocusRect = 0 'False TabCaption(0) = "Dial Options" TabPicture(0) = "frmData.frx":0000 Tab(0).ControlEnabled= 0 'False Tab(0).Control(0)= "List1" Tab(0).ControlCount= 1 TabCaption(1) = "Call Setup Fail Timeout" TabPicture(1) = "frmData.frx":001C Tab(1).ControlEnabled= 0 'False Tab(1).Control(0)= "Combo1" Tab(1).ControlCount= 1 TabCaption(2) = "Inactivity Timeout" TabPicture(2) = "frmData.frx":0038 Tab(2).ControlEnabled= 0 'False Tab(2).Control(0)= "Combo2" Tab(2).ControlCount= 1 TabCaption(3) = "Speaker Volume" TabPicture(3) = "frmData.frx":0054 Tab(3).ControlEnabled= 0 'False Tab(3).Control(0)= "List2" Tab(3).ControlCount= 1 TabCaption(4) = "Speaker Mode" TabPicture(4) = "frmData.frx":0070 Tab(4).ControlEnabled= 0 'False Tab(4).Control(0)= "List3" Tab(4).ControlCount= 1 TabCaption(5) = "Modem Options" TabPicture(5) = "frmData.frx":008C Tab(5).ControlEnabled= 0 'False Tab(5).Control(0)= "List4" Tab(5).ControlCount= 1 TabCaption(6) = "Max DTE Rate" TabPicture(6) = "frmData.frx":00A8 Tab(6).ControlEnabled= 0 'False Tab(6).Control(0)= "Combo3" Tab(6).ControlCount= 1 TabCaption(7) = "Max DCE Rate" TabPicture(7) = "frmData.frx":00C4 Tab(7).ControlEnabled= -1 'True Tab(7).Control(0)= "Combo4" Tab(7).Control(0).Enabled= 0 'False Tab(7).ControlCount= 1 Begin VB.ComboBox Combo4 BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 360 ItemData = "frmData.frx":00E0 Left = 120 List = "frmData.frx":0111 TabIndex = 9 Top = 600 Width = 9135 End Begin VB.ComboBox Combo3 BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 360 ItemData = "frmData.frx":0179 Left = -74880 List = "frmData.frx":019E TabIndex = 8 Top = 600 Width = 9135 End Begin VB.ListBox List4 Columns = 2 Height = 4335 ItemData = "frmData.frx":01E8 Left = -74880 List = "frmData.frx":0258 Style = 1 'Checkbox TabIndex = 7 Top = 600 Width = 9135 End Begin VB.ListBox List3 Columns = 2 Height = 4335 ItemData = "frmData.frx":03DC Left = -74880 List = "frmData.frx":0440 Style = 1 'Checkbox TabIndex = 6 Top = 600 Width = 9135 End Begin VB.ListBox List2 Columns = 2 Height = 4335 ItemData = "frmData.frx":0502 Left = -74880 List = "frmData.frx":0566 Style = 1 'Checkbox TabIndex = 5 Top = 600 Width = 9135 End Begin VB.ComboBox Combo2 BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 360 ItemData = "frmData.frx":0622 Left = -74880 List = "frmData.frx":062C TabIndex = 4 Top = 600 Width = 9135 End Begin VB.ComboBox Combo1 BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 360 ItemData = "frmData.frx":0639 Left = -74880 List = "frmData.frx":0640 TabIndex = 3 Top = 600 Width = 9135 End Begin VB.ListBox List1 Columns = 2 Height = 4335 ItemData = "frmData.frx":0649 Left = -74880 List = "frmData.frx":06B1 Style = 1 'Checkbox TabIndex = 2 Top = 600 Width = 9135 End End Begin VB.TextBox Text1 Height = 285 Left = 0 TabIndex = 0 Text = "HKR,, Properties, 1, 00,00,00,00, 00,00,00,00, 00,00,00,00, 00,00,00,00, 00,00,00,00, 00,00,00,00, 00,00,00,00, 00,00,00,00" Top = 0 Width = 9495 End Begin ComctlLib.StatusBar StatusBar1 Align = 2 'Align Bottom Height = 300 Left = 0 TabIndex = 10 Top = 5430 Width = 9570 _ExtentX = 16880 _ExtentY = 529 SimpleText = "" _Version = 327682 BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7} NumPanels = 3 BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7} AutoSize = 1 Object.Width = 13229 TextSave = "" Object.Tag = "" EndProperty BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7} Style = 6 AutoSize = 2 Object.Width = 1773 MinWidth = 1764 TextSave = "9/1/98" Object.Tag = "" EndProperty BeginProperty Panel3 {0713E89F-850A-101B-AFC0-4210102A8DA7} Style = 5 AutoSize = 2 Object.Width = 1773 MinWidth = 1764 TextSave = "5:55 PM" Object.Tag = "" EndProperty EndProperty BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty End End Attribute VB_Name = "frmData" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Const HKR As String = "HKR,, Properties, 1, " Const Delim As String = "," Const H As String = "&H" Dim FirstBit1, FirstBit2, FirstBit3, FirstBit4 As String Dim SecondBit1, SecondBit2, SecondBit3, SecondBit4 As String Dim ThirdBit1, ThirdBit2, ThirdBit3, ThirdBit4 As String Dim FourthBit1, FourthBit2, FourthBit3, FourthBit4 As String Dim FifthBit1, FifthBit2, FifthBit3, FifthBit4 As String Dim SixthBit1, SixthBit2, SixthBit3, SixthBit4 As String Dim SeventhBit1, SeventhBit2, SeventhBit3, SeventhBit4 As String Dim EighthBit1, EighthBit2, EighthBit3, EighthBit4 As String Dim T1, T2, T3, T4, T5, T6, T7, T8 As String Dim DialOptionsComment(31) As String Dim SpeakerVolumeComment(31) As String Dim SpeakerModeComment(31) As String Dim ModemOptionsComment(31) As String Dim PreviousText As Boolean Public Sub ClearControl() Dim c As Integer For c = 0 To 31 List1.Selected(c) = False Next c T1 = "00,00,00,00" T2 = "00,00,00,00" Combo1 = "" T3 = "00,00,00,00" Combo2 = "" For c = 0 To 31 List2.Selected(c) = False Next c T4 = "00,00,00,00" For c = 0 To 31 List3.Selected(c) = False Next c T5 = "00,00,00,00" For c = 0 To 31 List4.Selected(c) = False Next c T6 = "00,00,00,00" T7 = "00,00,00,00" Combo3 = "" T8 = "00,00,00,00" Combo4 = "" Update SSTab1.Tab = 0 Dim strFirst As String strFirst = Len("HKR,, Properties, 1, ") Text1.SelStart = strFirst Text1.SelLength = Len(T1) If frmData.Visible = False Then frmData.Show End If Text1.SetFocus End Sub Public Sub Paste(Incoming As String) ClearControl GetWord (Incoming) If T8 = "" Then Message = MsgBox(Q & Incoming & Q & " is not a valid input") ClearControl End If End Sub Public Sub EditCopy() Text1.SelStart = 0 Text1.SelLength = Len(Text1.Text) Text1.SetFocus Clipboard.Clear Clipboard.SetText Text1.Text End Sub Public Sub EditPaste() Dim X Paste (Clipboard.GetText) 'Take all the values, assign them to their respective controls and then use Update() to create Output T1 = FirstBit1 & Delim & FirstBit2 & Delim & FirstBit3 & Delim & FirstBit4 PreVert (T1) T1 = "00,00,00,00" X = H & PreNum List1.Selected(0) = X And &H1 List1.Selected(1) = X And &H2 List1.Selected(2) = X And &H4 List1.Selected(3) = X And &H8 List1.Selected(4) = X And &H10 List1.Selected(5) = X And &H20 List1.Selected(6) = X And &H40 List1.Selected(7) = X And &H80 List1.Selected(8) = X And &H100 List1.Selected(9) = X And &H200 List1.Selected(10) = X And &H400 List1.Selected(11) = X And &H800 List1.Selected(12) = X And &H1000 List1.Selected(13) = X And &H2000 List1.Selected(14) = X And &H4000 List1.Selected(15) = X And &H8000 List1.Selected(16) = X And &H10000 List1.Selected(17) = X And &H20000 List1.Selected(18) = X And &H40000 List1.Selected(19) = X And &H80000 List1.Selected(20) = X And &H100000 List1.Selected(21) = X And &H200000 List1.Selected(22) = X And &H400000 List1.Selected(23) = X And &H800000 List1.Selected(24) = X And &H1000000 List1.Selected(25) = X And &H2000000 List1.Selected(26) = X And &H4000000 List1.Selected(27) = X And &H8000000 List1.Selected(28) = X And &H10000000 List1.Selected(29) = X And &H20000000 List1.Selected(30) = X And &H40000000 List1.Selected(31) = X And &H80000000 T2 = SecondBit1 & Delim & SecondBit2 & Delim & SecondBit3 & Delim & SecondBit4 PreVert (T2) Combo1.Text = CDec(H & PreNum) T3 = ThirdBit1 & Delim & ThirdBit2 & Delim & ThirdBit3 & Delim & ThirdBit4 PreVert (T3) Combo2.Text = CDec(H & PreNum) T4 = FourthBit1 & Delim & FourthBit2 & Delim & FourthBit3 & Delim & FourthBit4 PreVert (T4) T4 = "00,00,00,00" X = H & PreNum List2.Selected(0) = X And &H1 List2.Selected(1) = X And &H2 List2.Selected(2) = X And &H4 List2.Selected(3) = X And &H8 List2.Selected(4) = X And &H10 List2.Selected(5) = X And &H20 List2.Selected(6) = X And &H40 List2.Selected(7) = X And &H80 List2.Selected(8) = X And &H100 List2.Selected(9) = X And &H200 List2.Selected(10) = X And &H400 List2.Selected(11) = X And &H800 List2.Selected(12) = X And &H1000 List2.Selected(13) = X And &H2000 List2.Selected(14) = X And &H4000 List2.Selected(15) = X And &H8000 List2.Selected(16) = X And &H10000 List2.Selected(17) = X And &H20000 List2.Selected(18) = X And &H40000 List2.Selected(19) = X And &H80000 List2.Selected(20) = X And &H100000 List2.Selected(21) = X And &H200000 List2.Selected(22) = X And &H400000 List2.Selected(23) = X And &H800000 List2.Selected(24) = X And &H1000000 List2.Selected(25) = X And &H2000000 List2.Selected(26) = X And &H4000000 List2.Selected(27) = X And &H8000000 List2.Selected(28) = X And &H10000000 List2.Selected(29) = X And &H20000000 List2.Selected(30) = X And &H40000000 List2.Selected(31) = X And &H80000000 T5 = FifthBit1 & Delim & FifthBit2 & Delim & FifthBit3 & Delim & FifthBit4 PreVert (T5) T5 = "00,00,00,00" X = H & PreNum List3.Selected(0) = X And &H1 List3.Selected(1) = X And &H2 List3.Selected(2) = X And &H4 List3.Selected(3) = X And &H8 List3.Selected(4) = X And &H10 List3.Selected(5) = X And &H20 List3.Selected(6) = X And &H40 List3.Selected(7) = X And &H80 List3.Selected(8) = X And &H100 List3.Selected(9) = X And &H200 List3.Selected(10) = X And &H400 List3.Selected(11) = X And &H800 List3.Selected(12) = X And &H1000 List3.Selected(13) = X And &H2000 List3.Selected(14) = X And &H4000 List3.Selected(15) = X And &H8000 List3.Selected(16) = X And &H10000 List3.Selected(17) = X And &H20000 List3.Selected(18) = X And &H40000 List3.Selected(19) = X And &H80000 List3.Selected(20) = X And &H100000 List3.Selected(21) = X And &H200000 List3.Selected(22) = X And &H400000 List3.Selected(23) = X And &H800000 List3.Selected(24) = X And &H1000000 List3.Selected(25) = X And &H2000000 List3.Selected(26) = X And &H4000000 List3.Selected(27) = X And &H8000000 List3.Selected(28) = X And &H10000000 List3.Selected(29) = X And &H20000000 List3.Selected(30) = X And &H40000000 List3.Selected(31) = X And &H80000000 T6 = SixthBit1 & Delim & SixthBit2 & Delim & SixthBit3 & Delim & SixthBit4 PreVert (T6) T6 = "00,00,00,00" X = H & PreNum List4.Selected(0) = X And &H1 List4.Selected(1) = X And &H2 List4.Selected(2) = X And &H4 List4.Selected(3) = X And &H8 List4.Selected(4) = X And &H10 List4.Selected(5) = X And &H20 List4.Selected(6) = X And &H40 List4.Selected(7) = X And &H80 List4.Selected(8) = X And &H100 List4.Selected(9) = X And &H200 List4.Selected(10) = X And &H400 List4.Selected(11) = X And &H800 List4.Selected(12) = X And &H1000 List4.Selected(13) = X And &H2000 List4.Selected(14) = X And &H4000 List4.Selected(15) = X And &H8000 List4.Selected(16) = X And &H10000 List4.Selected(17) = X And &H20000 List4.Selected(18) = X And &H40000 List4.Selected(19) = X And &H80000 List4.Selected(20) = X And &H100000 List4.Selected(21) = X And &H200000 List4.Selected(22) = X And &H400000 List4.Selected(23) = X And &H800000 List4.Selected(24) = X And &H1000000 List4.Selected(25) = X And &H2000000 List4.Selected(26) = X And &H4000000 List4.Selected(27) = X And &H8000000 List4.Selected(28) = X And &H10000000 List4.Selected(29) = X And &H20000000 List4.Selected(30) = X And &H40000000 List4.Selected(31) = X And &H80000000 T7 = SeventhBit1 & Delim & SeventhBit2 & Delim & SeventhBit3 & Delim & SeventhBit4 PreVert (T7) Combo3.Text = CDec(H & PreNum) T8 = EighthBit1 & Delim & EighthBit2 & Delim & EighthBit3 & Delim & EighthBit4 PreVert (T8) Combo4.Text = CDec(H & PreNum) Update SSTab1.Tab = 0 Dim strFirst As String strFirst = Len("HKR,, Properties, 1, ") Text1.SelStart = strFirst Text1.SelLength = Len(T1) Text1.SetFocus End Sub Public Sub Update() Text1.Text = "HKR,, Properties, 1, " & T1 & ", " & T2 & ", " & T3 & ", " & T4 & ", " & T5 & ", " & T6 & ", " & T7 & ", " & T8 End Sub Private Sub Combo1_Click() T2 = Combo1.Text If T2 = "" Then T2 = 0 End If If T2 > 100000000 Then T2 = 0 Combo1.Text = 0 End If HexCon (T2) T2 = HexNum Update Dim strFirst As String strFirst = Len("HKR,, Properties, 1, " & T1) Text1.SelStart = strFirst Text1.SelLength = Len(T2) Text1.SetFocus End Sub Private Sub Combo1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then T2 = Combo1.Text If T2 = "" Then T2 = 0 End If If T2 > 100000000 Then T2 = 0 Combo1.Text = 0 End If HexCon (T2) T2 = HexNum Update Dim strFirst As String strFirst = Len("HKR,, Properties, 1, " & T1) Text1.SelStart = strFirst Text1.SelLength = Len(T2) Text1.SetFocus ElseIf (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 46 Then Beep KeyAscii = 0 End If End Sub Private Sub Combo1_LostFocus() T2 = Combo1.Text If T2 = "" Then T2 = 0 End If If T2 > 100000000 Then T2 = 0 Combo1.Text = 0 End If HexCon (T2) T2 = HexNum Update End Sub Private Sub Combo2_Click() T3 = Combo2.Text If T3 = "" Then T3 = 0 End If If T3 > 100000000 Then T3 = 0 Combo2.Text = 0 End If HexCon (T3) T3 = HexNum Update Dim strFirst As String strFirst = Len("HKR,, Properties, 1, " & T1 & T2) Text1.SelStart = strFirst Text1.SelLength = Len(T3) Text1.SetFocus End Sub Private Sub Combo2_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then T3 = Combo2.Text If T3 = "" Then T3 = 0 End If If T3 > 100000000 Then T3 = 0 Combo2.Text = 0 End If HexCon (T3) T3 = HexNum Update Dim strFirst As String strFirst = Len("HKR,, Properties, 1, " & T1 & T2) Text1.SelStart = strFirst Text1.SelLength = Len(T3) Text1.SetFocus ElseIf (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 46 Then Beep KeyAscii = 0 End If End Sub Private Sub Combo2_LostFocus() T3 = Combo2.Text If T3 = "" Then T3 = 0 End If If T3 > 100000000 Then T3 = 0 Combo2.Text = 0 End If HexCon (T3) T3 = HexNum Update End Sub Private Sub Combo3_Click() T7 = Combo3.Text If T7 = "" Then T7 = 0 End If If T7 > 100000000 Then T7 = 0 Combo3.Text = 0 End If HexCon (T7) T7 = HexNum Update Dim strFirst As String strFirst = Len("HKR,, Properties, 1, " & T1 & T2 & T3 & T4 & T5 & T6) Text1.SelStart = strFirst Text1.SelLength = Len(T7) Text1.SetFocus End Sub Private Sub Combo3_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then T7 = Combo3.Text If T7 = "" Then T7 = 0 End If If T7 > 100000000 Then T7 = 0 Combo3.Text = 0 End If HexCon (T7) T7 = HexNum Update Dim strFirst As String strFirst = Len("HKR,, Properties, 1, " & T1 & T2 & T3 & T4 & T5 & T6) Text1.SelStart = strFirst Text1.SelLength = Len(T7) Text1.SetFocus ElseIf (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 46 Then Beep KeyAscii = 0 End If End Sub Private Sub Combo3_LostFocus() T7 = Combo3.Text If T7 = "" Then T7 = 0 End If If T7 > 100000000 Then T7 = 0 Combo3.Text = 0 End If HexCon (T7) T7 = HexNum Update End Sub Private Sub Combo4_Click() T8 = Combo4.Text If T8 = "" Then T8 = 0 End If If T8 > 100000000 Then T8 = 0 Combo4.Text = 0 End If HexCon (T8) T8 = HexNum Update Dim strFirst As String strFirst = Len("HKR,, Properties, 1, " & T1 & T2 & T3 & T4 & T5 & T6 & T7) Text1.SelStart = strFirst Text1.SelLength = Len(T8) Text1.SetFocus End Sub Private Sub Combo4_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then T8 = Combo4.Text If T8 = "" Then T8 = 0 End If If T8 > 100000000 Then T8 = 0 Combo4.Text = 0 End If HexCon (T8) T8 = HexNum Update Dim strFirst As String strFirst = Len("HKR,, Properties, 1, " & T1 & T2 & T3 & T4 & T5 & T6 & T7) Text1.SelStart = strFirst Text1.SelLength = Len(T8) Text1.SetFocus ElseIf (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 46 Then Beep KeyAscii = 0 End If End Sub Private Sub Combo4_LostFocus() T8 = Combo4.Text If T8 = "" Then T8 = 0 End If If T8 > 100000000 Then T8 = 0 Combo4.Text = 0 End If HexCon (T8) T8 = HexNum Update End Sub Private Sub Form_Load() GetWord (Text1.Text) DialOptionsComment(0) = "" DialOptionsComment(1) = "" DialOptionsComment(2) = "" DialOptionsComment(3) = "" DialOptionsComment(4) = "" DialOptionsComment(5) = "" DialOptionsComment(6) = "Supports wait for bong '$'" DialOptionsComment(7) = "Supports wait for quiet '@'" DialOptionsComment(8) = "Supports wait for dial tone 'W'" DialOptionsComment(9) = "" DialOptionsComment(10) = "" DialOptionsComment(11) = "" DialOptionsComment(12) = "" DialOptionsComment(13) = "" DialOptionsComment(14) = "" DialOptionsComment(15) = "" DialOptionsComment(16) = "" DialOptionsComment(17) = "" DialOptionsComment(18) = "" DialOptionsComment(19) = "" DialOptionsComment(20) = "" DialOptionsComment(21) = "" DialOptionsComment(22) = "" DialOptionsComment(23) = "" DialOptionsComment(24) = "" DialOptionsComment(25) = "" DialOptionsComment(26) = "" DialOptionsComment(27) = "" DialOptionsComment(28) = "" DialOptionsComment(29) = "" DialOptionsComment(30) = "" DialOptionsComment(31) = "" SpeakerVolumeComment(0) = "Supports low speaker volume." SpeakerVolumeComment(1) = "Supports med speaker volume." SpeakerVolumeComment(2) = "Supports high speaker volume." SpeakerVolumeComment(3) = "" SpeakerVolumeComment(4) = "" SpeakerVolumeComment(5) = "" SpeakerVolumeComment(6) = "" SpeakerVolumeComment(7) = "" SpeakerVolumeComment(8) = "" SpeakerVolumeComment(9) = "" SpeakerVolumeComment(10) = "" SpeakerVolumeComment(11) = "" SpeakerVolumeComment(12) = "" SpeakerVolumeComment(13) = "" SpeakerVolumeComment(14) = "" SpeakerVolumeComment(15) = "" SpeakerVolumeComment(16) = "" SpeakerVolumeComment(17) = "" SpeakerVolumeComment(18) = "" SpeakerVolumeComment(19) = "" SpeakerVolumeComment(20) = "" SpeakerVolumeComment(21) = "" SpeakerVolumeComment(22) = "" SpeakerVolumeComment(23) = "" SpeakerVolumeComment(24) = "" SpeakerVolumeComment(25) = "" SpeakerVolumeComment(26) = "" SpeakerVolumeComment(27) = "" SpeakerVolumeComment(28) = "" SpeakerVolumeComment(29) = "" SpeakerVolumeComment(30) = "" SpeakerVolumeComment(31) = "" SpeakerModeComment(0) = "Supports speaker mode off." SpeakerModeComment(1) = "Supports speaker mode dial." SpeakerModeComment(2) = "Supports speaker mode on." SpeakerModeComment(3) = "Supports speaker mode setup." SpeakerModeComment(4) = "" SpeakerModeComment(5) = "" SpeakerModeComment(6) = "" SpeakerModeComment(7) = "" SpeakerModeComment(8) = "" SpeakerModeComment(9) = "" SpeakerModeComment(10) = "" SpeakerModeComment(11) = "" SpeakerModeComment(12) = "" SpeakerModeComment(13) = "" SpeakerModeComment(14) = "" SpeakerModeComment(15) = "" SpeakerModeComment(16) = "" SpeakerModeComment(17) = "" SpeakerModeComment(18) = "" SpeakerModeComment(19) = "" SpeakerModeComment(20) = "" SpeakerModeComment(21) = "" SpeakerModeComment(22) = "" SpeakerModeComment(23) = "" SpeakerModeComment(24) = "" SpeakerModeComment(25) = "" SpeakerModeComment(26) = "" SpeakerModeComment(27) = "" SpeakerModeComment(28) = "" SpeakerModeComment(29) = "" SpeakerModeComment(30) = "" SpeakerModeComment(31) = "" ModemOptionsComment(0) = "Supports enabling/disabling of data compression negotiation." ModemOptionsComment(1) = "Supports enabling/disabling of error control protocol negotiation." ModemOptionsComment(2) = "Supports enabling/disabling of forced error control." ModemOptionsComment(3) = "Supports enabling/disabling of a cellular protocol." ModemOptionsComment(4) = "Supports enabling/disabling of hardware flow control." ModemOptionsComment(5) = "Supports enabling/disabling of software flow control." ModemOptionsComment(6) = "Supports CCITT/Bell toggling." ModemOptionsComment(7) = "Supports enabling/disabling of speed negotiation." ModemOptionsComment(8) = "Supports tone and pulse dialing." ModemOptionsComment(9) = "Supports blind dialing." ModemOptionsComment(10) = "Supports CCITT V.21-V.22/CCITT V.23 toggling." ModemOptionsComment(11) = "Supports #UD diagnostics command." ModemOptionsComment(12) = "" ModemOptionsComment(13) = "" ModemOptionsComment(14) = "" ModemOptionsComment(15) = "" ModemOptionsComment(16) = "" ModemOptionsComment(17) = "" ModemOptionsComment(18) = "" ModemOptionsComment(19) = "" ModemOptionsComment(20) = "" ModemOptionsComment(21) = "" ModemOptionsComment(22) = "" ModemOptionsComment(23) = "" ModemOptionsComment(24) = "" ModemOptionsComment(25) = "" ModemOptionsComment(26) = "" ModemOptionsComment(27) = "" ModemOptionsComment(28) = "" ModemOptionsComment(29) = "" ModemOptionsComment(30) = "" ModemOptionsComment(31) = "" ClearControl End Sub Private Sub Form_Resize() Text1.Width = frmData.Width SSTab1.Width = frmData.Width - 75 SSTab1.Height = frmData.Height - 675 List1.Height = SSTab1.Height - 645 List1.Width = SSTab1.Width - 270 List2.Height = SSTab1.Height - 645 List2.Width = SSTab1.Width - 270 List3.Height = SSTab1.Height - 645 List3.Width = SSTab1.Width - 270 List4.Height = SSTab1.Height - 645 List4.Width = SSTab1.Width - 270 'cmdAddValue.Top = frmData.Height - 245 'cmdAddValue.Left = frmData.Width - 3015 Combo1.Width = SSTab1.Width - 270 Combo2.Width = SSTab1.Width - 270 Combo3.Width = SSTab1.Width - 270 Combo4.Width = SSTab1.Width - 270 End Sub Private Sub GetWord(strString As String) Dim strSubString As String Dim lStart As Long Dim lStop As Long lStart = 1 lStop = Len(strString) While lStart < lStop And "," <> Mid$(strString, lStart, 1) ' Loop until first 1 found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strString, lStop + 1, 1) And lStop <= Len(strString) ' Loop until next , found lStop = lStop + 1 Wend strSubString = Mid$(strString, lStop + 2) lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first 1 found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until next , found lStop = lStop + 1 Wend strSubString = Mid$(strSubString, lStop + 1) lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend FirstBit1 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (FirstBit1) FirstBit1 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend FirstBit2 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (FirstBit2) FirstBit2 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend FirstBit3 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (FirstBit3) FirstBit3 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend FirstBit4 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (FirstBit4) FirstBit4 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend SecondBit1 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (SecondBit1) SecondBit1 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend SecondBit2 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (SecondBit2) SecondBit2 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend SecondBit3 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (SecondBit3) SecondBit3 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend SecondBit4 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (SecondBit4) SecondBit4 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend ThirdBit1 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (ThirdBit1) ThirdBit1 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend ThirdBit2 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (ThirdBit2) ThirdBit2 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) And " " <> Mid$(strSubString, lStop + 1, 1) And vbTab <> Mid$(strSubString, lStop + 1, 1) ' Loop until last , found lStop = lStop + 1 Wend ThirdBit3 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (ThirdBit3) ThirdBit3 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) And " " <> Mid$(strSubString, lStop + 1, 1) And vbTab <> Mid$(strSubString, lStop + 1, 1) ' Loop until last , found lStop = lStop + 1 Wend ThirdBit4 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (ThirdBit4) ThirdBit4 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend FourthBit1 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (FourthBit1) FourthBit1 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend FourthBit2 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (FourthBit2) FourthBit2 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend FourthBit3 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (FourthBit3) FourthBit3 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend FourthBit4 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (FourthBit4) FourthBit4 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend FifthBit1 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (FifthBit1) FifthBit1 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend FifthBit2 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (FifthBit2) FifthBit2 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend FifthBit3 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (FifthBit3) FifthBit3 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend FifthBit4 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (FifthBit4) FifthBit4 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend SixthBit1 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (SixthBit1) SixthBit1 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend SixthBit2 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (SixthBit2) SixthBit2 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) And " " <> Mid$(strSubString, lStop + 1, 1) And vbTab <> Mid$(strSubString, lStop + 1, 1) ' Loop until last , found lStop = lStop + 1 Wend SixthBit3 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (SixthBit3) SixthBit3 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) And " " <> Mid$(strSubString, lStop + 1, 1) And vbTab <> Mid$(strSubString, lStop + 1, 1) ' Loop until last , found lStop = lStop + 1 Wend SixthBit4 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (SixthBit4) SixthBit4 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend SeventhBit1 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (SeventhBit1) SeventhBit1 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend SeventhBit2 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (SeventhBit2) SeventhBit2 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend SeventhBit3 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (SeventhBit3) SeventhBit3 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend SeventhBit4 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (SeventhBit4) SeventhBit4 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend EighthBit1 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (EighthBit1) EighthBit1 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found lStop = lStop + 1 Wend EighthBit2 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (EighthBit2) EighthBit2 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) And " " <> Mid$(strSubString, lStop + 1, 1) And vbTab <> Mid$(strSubString, lStop + 1, 1) ' Loop until last , found lStop = lStop + 1 Wend EighthBit3 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (EighthBit3) EighthBit3 = CleanNum lStart = 1 lStop = Len(strSubString) While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found lStart = lStart + 1 Wend lStop = lStart While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) And " " <> Mid$(strSubString, lStop + 1, 1) And vbTab <> Mid$(strSubString, lStop + 1, 1) ' Loop until last , found lStop = lStop + 1 Wend EighthBit4 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s strSubString = Mid$(strSubString, lStop + 1) Clean (EighthBit4) EighthBit4 = CleanNum T1 = FirstBit1 & Delim & FirstBit2 & Delim & FirstBit3 & Delim & FirstBit4 T2 = SecondBit1 & Delim & SecondBit2 & Delim & SecondBit3 & Delim & SecondBit4 T3 = ThirdBit1 & Delim & ThirdBit2 & Delim & ThirdBit3 & Delim & ThirdBit4 T4 = FourthBit1 & Delim & FourthBit2 & Delim & FourthBit3 & Delim & FourthBit4 T5 = FifthBit1 & Delim & FifthBit2 & Delim & FifthBit3 & Delim & FifthBit4 T6 = SixthBit1 & Delim & SixthBit2 & Delim & SixthBit3 & Delim & SixthBit4 T7 = SeventhBit1 & Delim & SeventhBit2 & Delim & SeventhBit3 & Delim & SeventhBit4 T8 = EighthBit1 & Delim & EighthBit2 & Delim & EighthBit3 & Delim & EighthBit4 End Sub Private Sub List1_Click() List1.Refresh StatusBar1.Panels.Item(1).Text = DialOptionsComment(List1.ListIndex) strFirst = Len("HKR,, Properties, 1, ") Text1.SelStart = strFirst Text1.SelLength = Len(T1) Text1.SetFocus End Sub Private Sub List1_ItemCheck(Item As Integer) Dim Num As Long Dim Number As Long PreVert (T1) T1 = PreNum Number = CDec(H & T1) Num = CDec(H & List1.ItemData(Item)) If List1.Selected(Item) = True Then T1 = Hex(Num + Number) ElseIf T1 <> "00" Then T1 = Hex(Number - Num) End If If Len(T1) < 8 Then T1 = "00000000" & T1 T1 = Right(T1, 8) PostVert (T1) T1 = PostNum End If Update End Sub Private Sub List2_Click() List2.Refresh StatusBar1.Panels.Item(1).Text = SpeakerVolumeComment(List2.ListIndex) strFirst = Len("HKR,, Properties, 1, " & T1 & T2 & T3) Text1.SelStart = strFirst Text1.SelLength = Len(T4) Text1.SetFocus End Sub Private Sub List2_ItemCheck(Item As Integer) Dim Num As Long Dim Number As Long PreVert (T4) T4 = PreNum Number = CDec(H & T4) Num = CDec(H & List2.ItemData(Item)) If List2.Selected(Item) = True Then T4 = Hex(Num + Number) ElseIf T4 <> "00" Then T4 = Hex(Number - Num) End If If Len(T4) < 8 Then T4 = "00000000" & T4 T4 = Right(T4, 8) PostVert (T4) T4 = PostNum End If Update End Sub Private Sub List3_Click() List3.Refresh StatusBar1.Panels.Item(1).Text = SpeakerModeComment(List3.ListIndex) strFirst = Len("HKR,, Properties, 1, " & T1 & T2 & T3 & T4) Text1.SelStart = strFirst Text1.SelLength = Len(T5) Text1.SetFocus End Sub Private Sub List3_ItemCheck(Item As Integer) Dim Num As Long Dim Number As Long PreVert (T5) T5 = PreNum Number = CDec(H & T5) Num = CDec(H & List3.ItemData(Item)) If List3.Selected(Item) = True Then T5 = Hex(Num + Number) ElseIf T5 <> "00" Then T5 = Hex(Number - Num) End If If Len(T5) < 8 Then T5 = "00000000" & T5 T5 = Right(T5, 8) PostVert (T5) T5 = PostNum End If Update End Sub Private Sub List4_Click() List4.Refresh StatusBar1.Panels.Item(1).Text = ModemOptionsComment(List4.ListIndex) strFirst = Len("HKR,, Properties, 1, " & T1 & T2 & T3 & T4 & T5) Text1.SelStart = strFirst Text1.SelLength = Len(T6) Text1.SetFocus End Sub Private Sub List4_ItemCheck(Item As Integer) Dim Num As Long Dim Number As Long PreVert (T6) T6 = PreNum Number = CDec(H & T6) Num = CDec(H & List4.ItemData(Item)) If List4.Selected(Item) = True Then T6 = Hex(Num + Number) ElseIf T6 <> "00" Then T6 = Hex(Number - Num) End If If Len(T6) < 8 Then T6 = "00000000" & T6 T6 = Right(T6, 8) PostVert (T6) T6 = PostNum End If Update End Sub Private Sub SSTab1_Click(PreviousTab As Integer) Dim CurrentTab As Integer Dim strFirst As Integer CurrentTab = SSTab1.Tab + 1 Select Case CurrentTab Case "1" strFirst = Len("HKR,, Properties, 1, ") Text1.SelStart = strFirst Text1.SelLength = Len(T1) StatusBar1.Panels.Item(1).Text = "" Case "2" strFirst = Len("HKR,, Properties, 1, " & T1) Text1.SelStart = strFirst Text1.SelLength = Len(T2) StatusBar1.Panels.Item(1).Text = "This is the maximum value that can be set for the call setup timer." Case "3" strFirst = Len("HKR,, Properties, 1, " & T1 & T2) Text1.SelStart = strFirst Text1.SelLength = Len(T3) StatusBar1.Panels.Item(1).Text = "This is the maximum value that can be set for the data inactivity timer." Case "4" strFirst = Len("HKR,, Properties, 1, " & T1 & T2 & T3) Text1.SelStart = strFirst Text1.SelLength = Len(T4) StatusBar1.Panels.Item(1).Text = "" Case "5" strFirst = Len("HKR,, Properties, 1, " & T1 & T2 & T3 & T4) Text1.SelStart = strFirst Text1.SelLength = Len(T5) StatusBar1.Panels.Item(1).Text = "" Case "6" strFirst = Len("HKR,, Properties, 1, " & T1 & T2 & T3 & T4 & T5) Text1.SelStart = strFirst Text1.SelLength = Len(T6) StatusBar1.Panels.Item(1).Text = "" Case "7" strFirst = Len("HKR,, Properties, 1, " & T1 & T2 & T3 & T4 & T5 & T6) Text1.SelStart = strFirst Text1.SelLength = Len(T7) StatusBar1.Panels.Item(1).Text = "Maximum data rate supported between the modem and the computer (DTE rate)." Case "8" strFirst = Len("HKR,, Properties, 1, " & T1 & T2 & T3 & T4 & T5 & T6 & T7) Text1.SelStart = strFirst Text1.SelLength = Len(T8) StatusBar1.Panels.Item(1).Text = "Maximum data transmission speed between modem to modem (DCE rate)." End Select If frmData.Visible = False Then frmData.Show End If Text1.SetFocus End Sub Private Sub Text1_Click() Dim Start As Integer Start = Text1.SelStart If 19 < Start And Start < 33 Then If SSTab1.Tab = 0 Then Exit Sub End If SSTab1.Tab = 0 End If If 32 < Start And Start < 46 Then If SSTab1.Tab = 1 Then Exit Sub End If SSTab1.Tab = 1 End If If 45 < Start And Start < 59 Then If SSTab1.Tab = 2 Then Exit Sub End If SSTab1.Tab = 2 End If If 58 < Start And Start < 72 Then If SSTab1.Tab = 3 Then Exit Sub End If SSTab1.Tab = 3 End If If 71 < Start And Start < 85 Then If SSTab1.Tab = 4 Then Exit Sub End If SSTab1.Tab = 4 End If If 84 < Start And Start < 98 Then If SSTab1.Tab = 5 Then Exit Sub End If SSTab1.Tab = 5 End If If 97 < Start And Start < 111 Then If SSTab1.Tab = 6 Then Exit Sub End If SSTab1.Tab = 6 End If If 110 < Start And Start < 124 Then If SSTab1.Tab = 7 Then Exit Sub End If SSTab1.Tab = 7 End If End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then WhichTab = SSTab1.Tab Dim X Paste (Text1.Text) 'Take all the values, assign them to their respective controls and then use Update() to create Output T1 = FirstBit1 & Delim & FirstBit2 & Delim & FirstBit3 & Delim & FirstBit4 PreVert (T1) T1 = "00,00,00,00" X = H & PreNum List1.Selected(0) = X And &H1 List1.Selected(1) = X And &H2 List1.Selected(2) = X And &H4 List1.Selected(3) = X And &H8 List1.Selected(4) = X And &H10 List1.Selected(5) = X And &H20 List1.Selected(6) = X And &H40 List1.Selected(7) = X And &H80 List1.Selected(8) = X And &H100 List1.Selected(9) = X And &H200 List1.Selected(10) = X And &H400 List1.Selected(11) = X And &H800 List1.Selected(12) = X And &H1000 List1.Selected(13) = X And &H2000 List1.Selected(14) = X And &H4000 List1.Selected(15) = X And &H8000 List1.Selected(16) = X And &H10000 List1.Selected(17) = X And &H20000 List1.Selected(18) = X And &H40000 List1.Selected(19) = X And &H80000 List1.Selected(20) = X And &H100000 List1.Selected(21) = X And &H200000 List1.Selected(22) = X And &H400000 List1.Selected(23) = X And &H800000 List1.Selected(24) = X And &H1000000 List1.Selected(25) = X And &H2000000 List1.Selected(26) = X And &H4000000 List1.Selected(27) = X And &H8000000 List1.Selected(28) = X And &H10000000 List1.Selected(29) = X And &H20000000 List1.Selected(30) = X And &H40000000 List1.Selected(31) = X And &H80000000 T2 = SecondBit1 & Delim & SecondBit2 & Delim & SecondBit3 & Delim & SecondBit4 PreVert (T2) Combo1.Text = CDec(H & PreNum) T3 = ThirdBit1 & Delim & ThirdBit2 & Delim & ThirdBit3 & Delim & ThirdBit4 PreVert (T3) Combo2.Text = CDec(H & PreNum) T4 = FourthBit1 & Delim & FourthBit2 & Delim & FourthBit3 & Delim & FourthBit4 PreVert (T4) T4 = "00,00,00,00" X = H & PreNum List2.Selected(0) = X And &H1 List2.Selected(1) = X And &H2 List2.Selected(2) = X And &H4 List2.Selected(3) = X And &H8 List2.Selected(4) = X And &H10 List2.Selected(5) = X And &H20 List2.Selected(6) = X And &H40 List2.Selected(7) = X And &H80 List2.Selected(8) = X And &H100 List2.Selected(9) = X And &H200 List2.Selected(10) = X And &H400 List2.Selected(11) = X And &H800 List2.Selected(12) = X And &H1000 List2.Selected(13) = X And &H2000 List2.Selected(14) = X And &H4000 List2.Selected(15) = X And &H8000 List2.Selected(16) = X And &H10000 List2.Selected(17) = X And &H20000 List2.Selected(18) = X And &H40000 List2.Selected(19) = X And &H80000 List2.Selected(20) = X And &H100000 List2.Selected(21) = X And &H200000 List2.Selected(22) = X And &H400000 List2.Selected(23) = X And &H800000 List2.Selected(24) = X And &H1000000 List2.Selected(25) = X And &H2000000 List2.Selected(26) = X And &H4000000 List2.Selected(27) = X And &H8000000 List2.Selected(28) = X And &H10000000 List2.Selected(29) = X And &H20000000 List2.Selected(30) = X And &H40000000 List2.Selected(31) = X And &H80000000 T5 = FifthBit1 & Delim & FifthBit2 & Delim & FifthBit3 & Delim & FifthBit4 PreVert (T5) T5 = "00,00,00,00" X = H & PreNum List3.Selected(0) = X And &H1 List3.Selected(1) = X And &H2 List3.Selected(2) = X And &H4 List3.Selected(3) = X And &H8 List3.Selected(4) = X And &H10 List3.Selected(5) = X And &H20 List3.Selected(6) = X And &H40 List3.Selected(7) = X And &H80 List3.Selected(8) = X And &H100 List3.Selected(9) = X And &H200 List3.Selected(10) = X And &H400 List3.Selected(11) = X And &H800 List3.Selected(12) = X And &H1000 List3.Selected(13) = X And &H2000 List3.Selected(14) = X And &H4000 List3.Selected(15) = X And &H8000 List3.Selected(16) = X And &H10000 List3.Selected(17) = X And &H20000 List3.Selected(18) = X And &H40000 List3.Selected(19) = X And &H80000 List3.Selected(20) = X And &H100000 List3.Selected(21) = X And &H200000 List3.Selected(22) = X And &H400000 List3.Selected(23) = X And &H800000 List3.Selected(24) = X And &H1000000 List3.Selected(25) = X And &H2000000 List3.Selected(26) = X And &H4000000 List3.Selected(27) = X And &H8000000 List3.Selected(28) = X And &H10000000 List3.Selected(29) = X And &H20000000 List3.Selected(30) = X And &H40000000 List3.Selected(31) = X And &H80000000 T6 = SixthBit1 & Delim & SixthBit2 & Delim & SixthBit3 & Delim & SixthBit4 PreVert (T6) T6 = "00,00,00,00" X = H & PreNum List4.Selected(0) = X And &H1 List4.Selected(1) = X And &H2 List4.Selected(2) = X And &H4 List4.Selected(3) = X And &H8 List4.Selected(4) = X And &H10 List4.Selected(5) = X And &H20 List4.Selected(6) = X And &H40 List4.Selected(7) = X And &H80 List4.Selected(8) = X And &H100 List4.Selected(9) = X And &H200 List4.Selected(10) = X And &H400 List4.Selected(11) = X And &H800 List4.Selected(12) = X And &H1000 List4.Selected(13) = X And &H2000 List4.Selected(14) = X And &H4000 List4.Selected(15) = X And &H8000 List4.Selected(16) = X And &H10000 List4.Selected(17) = X And &H20000 List4.Selected(18) = X And &H40000 List4.Selected(19) = X And &H80000 List4.Selected(20) = X And &H100000 List4.Selected(21) = X And &H200000 List4.Selected(22) = X And &H400000 List4.Selected(23) = X And &H800000 List4.Selected(24) = X And &H1000000 List4.Selected(25) = X And &H2000000 List4.Selected(26) = X And &H4000000 List4.Selected(27) = X And &H8000000 List4.Selected(28) = X And &H10000000 List4.Selected(29) = X And &H20000000 List4.Selected(30) = X And &H40000000 List4.Selected(31) = X And &H80000000 T7 = SeventhBit1 & Delim & SeventhBit2 & Delim & SeventhBit3 & Delim & SeventhBit4 PreVert (T7) Combo3.Text = CDec(H & PreNum) T8 = EighthBit1 & Delim & EighthBit2 & Delim & EighthBit3 & Delim & EighthBit4 PreVert (T8) Combo4.Text = CDec(H & PreNum) Update SSTab1.Tab = WhichTab End If End Sub
Sub Eratost() Dim sieve() As Boolean Dim n As Integer, i As Integer, j As Integer n = InputBox("limit:", n) ReDim sieve(n) For i = 1 To n sieve(i) = True Next i For i = 2 To n If sieve(i) Then For j = i * 2 To n Step i sieve(j) = False Next j End If Next i For i = 2 To n If sieve(i) Then Debug.Print i Next i End Sub 'Eratost
<gh_stars>1-10 Private Function Ethiopian_Multiplication_Non_Optimized(First As Long, Second As Long) As Long Dim Left_Hand_Column As New Collection, Right_Hand_Column As New Collection, i As Long, temp As Long 'Take two numbers to be multiplied and write them down at the top of two columns. Left_Hand_Column.Add First, CStr(First) Right_Hand_Column.Add Second, CStr(Second) 'In the left-hand column repeatedly halve the last number, discarding any remainders, 'and write the result below the last in the same column, until you write a value of 1. Do First = lngHalve(First) Left_Hand_Column.Add First, CStr(First) Loop While First > 1 'In the right-hand column repeatedly double the last number and write the result below. 'stop when you add a result in the same row as where the left hand column shows 1. For i = 2 To Left_Hand_Column.Count Second = lngDouble(Second) Right_Hand_Column.Add Second, CStr(Second) Next 'Examine the table produced and discard any row where the value in the left column is even. For i = Left_Hand_Column.Count To 1 Step -1 If IsEven(Left_Hand_Column(i)) Then Right_Hand_Column.Remove CStr(Right_Hand_Column(i)) Next 'Sum the values in the right-hand column that remain to produce the result of multiplying 'the original two numbers together For i = 1 To Right_Hand_Column.Count temp = temp + Right_Hand_Column(i) Next Ethiopian_Multiplication_Non_Optimized = temp End Function
<gh_stars>10-100 ' Script shows how to use the script engines hosted by MMC. Dim doc Dim snapins Dim frame Set frame = MMCApplication.Frame Set doc = MMCApplication.Document Set snapins = doc.snapins snapins.Add "{58221c66-ea27-11cf-adcf-00aa00a80033}" ' the services snap-in ' Script ends
<reponame>LaudateCorpus1/RosettaCodeData Sub String_Assignment() Dim myString$ 'Here, myString is created and equal "" 'assignments : myString = vbNullString 'return : "" myString = "Hello World" 'return : "Hello World" myString = String(12, "A") 'return : "AAAAAAAAAAAA" End Sub
On Error Resume Next while true Set Service = GetObject("winmgmts:root/default") Set Class = Service.Get () Set Property = Class.Properties_.Add( "myProp", 8, true) Property.Value = Array ("Hello", "World") WScript.Echo Property.Name WScript.Echo Property.CIMType WScript.Echo Property.IsArray WScript.Echo Property.IsLocal WScript.Echo Property.Origin Dim str str = "{" for x=0 to UBound(Property.Value) if x <> 0 Then str = str & ", " End If str = str & Property(x) Next str = str & "}" WScript.Echo str if Err <> 0 Then WScript.Echo Err.Description End if wend
<reponame>LaudateCorpus1/RosettaCodeData<gh_stars>1-10 dim a a = array(300, 1, -2, 3, -4, 5, -6, 7, -8, 100, 11 ) wscript.echo join( a, ", " ) countingSort a wscript.echo join( a, ", " )
<filename>Task/Evolutionary-algorithm/Visual-Basic/evolutionary-algorithm.vb Option Explicit Private Sub Main() Dim Target Dim Parent Dim mutation_rate Dim children Dim bestfitness Dim bestindex Dim Index Dim fitness Target = "METHINKS IT IS LIKE A WEASEL" Parent = "IU RFSGJABGOLYWF XSMFXNIABKT" mutation_rate = 0.5 children = 10 ReDim child(children) Do bestfitness = 0 bestindex = 0 For Index = 1 To children child(Index) = FNmutate(Parent, mutation_rate, Target) fitness = FNfitness(Target, child(Index)) If fitness > bestfitness Then bestfitness = fitness bestindex = Index End If Next Index Parent = child(bestindex) Debug.Print Parent Loop Until Parent = Target End End Sub Function FNmutate(Text, Rate, ref) Dim C As Integer Dim Aux As Integer If Rate > Rnd(1) Then C = 63 + 27 * Rnd() + 1 If C = 64 Then C = 32 Aux = Len(Text) * Rnd() + 1 If Mid(Text, Aux, 1) <> Mid(ref, Aux, 1) Then Text = Left(Text, Aux - 1) & Chr(C) & Mid(Text, Aux + 1) End If End If FNmutate = Text End Function Function FNfitness(Text, ref) Dim I, F For I = 1 To Len(Text) If Mid(Text, I, 1) = Mid(ref, I, 1) Then F = F + 1 Next FNfitness = F / Len(Text) End Function
<reponame>LaudateCorpus1/RosettaCodeData Option Explicit Sub LoopEx() Dim i As Long, j As Long, s As String For i = 1 To 5 s = "" For j = 1 To i s = s + "*" Next Debug.Print s Next End Sub
Attribute VB_Name = "BrokenLinkDetection" Option Explicit Private Const HTTP_C As String = "http://" Private Const HTTP_LEN_C As Long = 7 Private Const HCP_SERVICES_C As String = "hcp://services/" Private Const HCP_SERVICES_LEN_C As Long = 15 Private Const APP_C As String = "app:" Private Const APP_LEN_C As Long = 4 Private Const MS_ITS_HELP_LOCATION_C As String = "ms-its:%help_location%\" Private Const MS_ITS_HELP_LOCATION_LEN_C As Long = 23 Private Const HCP_HELP_C As String = "hcp://help/" Private Const HCP_HELP_LEN_C As Long = 11 Private Const HCP_SYSTEM_C As String = "hcp://system/" Private Const HCP_SYSTEM_LEN_C As Long = 13 Private Const HCP_C As String = "hcp://" Private Const HCP_LEN_C As Long = 6 Private Const HELP_DIR_C As String = "\help\" Private Const SYSTEM_DIR_C As String = "\pchealth\helpctr\system\" Private Const VENDORS_DIR_C As String = "\pchealth\helpctr\vendors\" Public Function LinkValid( _ ByRef i_strWinDir As String, _ ByRef i_strVendor As String, _ ByRef i_strURI As String, _ ByRef o_strTransformedURI As String _ ) As Boolean ' Assume that i_strWinDir = c:\windows ' ' http://... ' hcp://services/... ' app:... ' ' MS-ITS:%HELP_LOCATION%\abc\def.chm::/ghi/jkl.htm -> ' c:\windows\help\abc\def.chm\ghi\jkl.htm ' ' hcp://help/abc/def/ghi.htm -> ' c:\windows\help\abc\def\ghi.htm ' ' hcp://system/abc/def/ghi.htm -> ' c:\windows\pchealth\helpctr\system\abc.chm\def\ghi.htm ' c:\windows\pchealth\helpctr\system\abc\def.chm\ghi.htm ' c:\windows\pchealth\helpctr\system\abc\def\ghi.htm ' ' hcp://<Vendor>/abc/def/ghi.htm -> ' abc/def/ghi.htm ' c:\windows\pchealth\helpctr\vendors\<Vendor>\abc.chm\def\ghi.htm ' c:\windows\pchealth\helpctr\vendors\<Vendor>\abc\def.chm\ghi.htm ' c:\windows\pchealth\helpctr\vendors\<Vendor>\abc\def\ghi.htm ' ' If (i_strURI in recognized format) Then ' If (transformations exist) Then ' If (transformation refers to existing file) Then ' LinkValid = True ' o_strTransformedURI = transformation ' Else ' LinkValid = False ' End If ' Else ' LinkValid = True ' o_strTransformedURI = i_strURI ' End If ' Else ' LinkValid = False ' End If Dim FSO As Scripting.FileSystemObject Dim strURI As String Dim strNewURI As String Dim strVendor As String Dim str As String Dim intIndex As Long Dim intLength As Long Set FSO = New Scripting.FileSystemObject strURI = LCase$(i_strURI) ' GetAbsolutePathName replaces / and \\ by \ If ((strURI = "") Or _ (Left$(strURI, HTTP_LEN_C) = HTTP_C) Or _ (Left$(strURI, HCP_SERVICES_LEN_C) = HCP_SERVICES_C) Or _ (Left$(strURI, APP_LEN_C) = APP_C)) Then ' recognized format ' no transformations exist LinkValid = True o_strTransformedURI = i_strURI Exit Function End If If (InStr(strURI, ":") = 0) Then strURI = HCP_C & i_strVendor & "/" & strURI End If If (Left$(strURI, MS_ITS_HELP_LOCATION_LEN_C) = MS_ITS_HELP_LOCATION_C) Then strNewURI = i_strWinDir & HELP_DIR_C & Mid$(i_strURI, MS_ITS_HELP_LOCATION_LEN_C + 1) strNewURI = Replace$(strNewURI, "::", "\") strNewURI = FSO.GetAbsolutePathName(strNewURI) If (FileExists(strNewURI)) Then LinkValid = True o_strTransformedURI = strNewURI Else LinkValid = False End If ElseIf (Left$(strURI, HCP_HELP_LEN_C) = HCP_HELP_C) Then strNewURI = i_strWinDir & HELP_DIR_C & Mid$(i_strURI, HCP_HELP_LEN_C + 1) strNewURI = FSO.GetAbsolutePathName(strNewURI) If (FileExists(strNewURI)) Then LinkValid = True o_strTransformedURI = strNewURI Else LinkValid = False End If ElseIf (Left$(strURI, HCP_SYSTEM_LEN_C) = HCP_SYSTEM_C) Then str = Mid$(i_strURI, HCP_SYSTEM_LEN_C + 1) LinkValid = p_TestPaths(FSO, i_strWinDir & SYSTEM_DIR_C, str, o_strTransformedURI) ElseIf (Left$(strURI, HCP_LEN_C) = HCP_C) Then ' Assume that its hcp://<Vendor> intIndex = InStr(HCP_LEN_C + 1, strURI, "/") If (intIndex = 0) Then LinkValid = False Exit Function End If strVendor = Mid$(strURI, HCP_LEN_C + 1, intIndex - HCP_LEN_C - 1) str = Mid$(strURI, intIndex + 1) LinkValid = p_TestPaths(FSO, i_strWinDir & VENDORS_DIR_C & strVendor & "\", str, _ o_strTransformedURI) Else ' unrecognized format LinkValid = False End If End Function Private Function p_TestPaths( _ ByRef i_FSO As Scripting.FileSystemObject, _ ByRef i_strPrefix As String, _ ByRef i_strPathIn As String, _ ByRef o_strPathOut As String _ ) As Boolean Dim str As String Dim intLength As Long Dim intIndex As Long Dim strPathOut As String ' i_strPrefix is something like c:\windows\pchealth\helpctr\system\ ' i_strPathIn is something like abc/def/ghi.htm ' This function tests to see if any of these paths exist: ' c:\windows\pchealth\helpctr\system\abc.chm\def\ghi.htm ' c:\windows\pchealth\helpctr\system\abc\def.chm\ghi.htm ' c:\windows\pchealth\helpctr\system\abc\def\ghi.htm ' If a path exists, then o_strPathOut is set to that path and the function ' returns True. Otherwise, it returns False str = Replace$(i_strPathIn, "/", "\") intLength = Len(str) For intIndex = 1 To intLength If (Mid$(str, intIndex, 1) = "\") Then strPathOut = i_strPrefix & _ Mid$(str, 1, intIndex - 1) & ".chm" & _ Mid$(str, intIndex) If (FileExists(strPathOut)) Then p_TestPaths = True o_strPathOut = i_FSO.GetAbsolutePathName(strPathOut) Exit Function End If End If Next p_TestPaths = False End Function
Sub Join_Strings() Dim A$, B As String A = "Hello" B = "world" Debug.Print A & " " & B 'return : Hello world 'If you're sure that A and B are Strings, you can use + instead of & : Debug.Print A + " " + B 'return : Hello world End Sub
VERSION 5.00 Begin VB.Form CertVwr Caption = "Certificate Authority Viewer" ClientHeight = 7050 ClientLeft = 60 ClientTop = 345 ClientWidth = 8100 LinkTopic = "Form1" ScaleHeight = 7050 ScaleWidth = 8100 StartUpPosition = 3 'Windows Default Begin VB.CommandButton ViewLog Caption = "View Log" Height = 375 Left = 1800 TabIndex = 5 Top = 6000 Visible = 0 'False Width = 1455 End Begin VB.CommandButton ViewQueue Caption = "View Schema" Default = -1 'True Height = 375 Left = 240 TabIndex = 4 Top = 6000 Width = 1455 End Begin VB.Frame CAFrame Caption = "Certificate Authority" Height = 975 Left = 240 TabIndex = 2 Top = 240 Width = 4335 Begin VB.ComboBox CACombo Height = 315 Left = 240 TabIndex = 3 Top = 360 Width = 3855 End End Begin VB.CommandButton ExitButton Cancel = -1 'True Caption = "Exit" Height = 375 Left = 3360 TabIndex = 1 Top = 6000 Width = 1215 End Begin VB.ListBox SchemaList Columns = 3 Height = 3765 Left = 240 TabIndex = 0 Top = 1800 Width = 7575 End Begin VB.Label MengthLabel Caption = "Maximum Length" Height = 255 Left = 5280 TabIndex = 8 Top = 1560 Width = 1575 End Begin VB.Label TypeLabel Caption = "Type" Height = 495 Left = 2760 TabIndex = 7 Top = 1560 Width = 1815 End Begin VB.Label NameLabel Caption = "Column Name" Height = 375 Left = 240 TabIndex = 6 Top = 1560 Width = 1815 End End Attribute VB_Name = "CertVwr" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub ExitButton_Click() End End Sub Private Sub Form_Load() Dim Config As CCertConfig Dim ConfigStr As String Dim r As Long Dim i As Long Set Config = New CCertConfig i = 0 Do While True r = Config.Next If (-1 = r) Then Exit Do ConfigStr = Config.GetField("Config") 'ConfigStr = ConfigStr & Config.GetField("Comment") If (0 = i) Then CACombo.Text = ConfigStr CACombo.AddItem ConfigStr, i i = i + 1 Loop Set Config = Nothing End Sub Private Sub ViewQueue_Click() Dim CertView As CCertView Dim EnumCol As CEnumCERTVIEWCOLUMN Dim ColStr As String Dim ccol As Long Dim ccolTotal As Long Dim icol As Long Dim coltype As Long Dim idx As Long Dim chunk As Long Dim length As Long chunk = 17 Set CertView = New CCertView Set EnumCol = Nothing CertView.OpenConnection CACombo.Text ccolTotal = CertView.GetColumnCount(False) Set EnumCol = CertView.EnumCertViewColumn(False) SchemaList.Clear ccol = ccolTotal While (0 <> ccol) icol = EnumCol.Next() If (-1 = icol) Then MsgBox ("Bad column index") ColStr = EnumCol.GetName() idx = Int(icol / chunk) * chunk * 2 'MsgBox "Name = " & icol + idx SchemaList.AddItem ColStr, icol + idx 'While (32 > Len(ColStr)) 'ColStr = ColStr & " " 'Wend coltype = EnumCol.GetType() If (1 = coltype) Then ColStr = "Long" ElseIf (2 = coltype) Then ColStr = "Date" ElseIf (3 = coltype) Then ColStr = "Binary" ElseIf (4 = coltype) Then ColStr = "String" Else ColStr = "Type=" & coltyp End If 'MsgBox "idx = " & idx & " Type = " & (2 * icol) + 1 + idx / 2 SchemaList.AddItem ColStr, (2 * icol) + 1 + idx / 2 length = EnumCol.GetMaxLength() 'If (0 <> length) Then 'MsgBox "Len = " & 3 * icol + 2 SchemaList.AddItem length, 3 * icol + 2 ccol = ccol - 1 Wend ccolListTotal = Int((ccolTotal + chunk - 1) / chunk) * chunk ccolFragment = ccolListTotal - ccolTotal idx = 3 * (ccolTotal - (chunk - ccolFragment)) + ccolFragment - 1 For icol = ccolTotal To ccolListTotal - 1 SchemaList.AddItem "", idx Next icol idx = idx + chunk For icol = ccolTotal To ccolListTotal - 1 SchemaList.AddItem "", idx Next icol Set EnumCol = Nothing Set CertView = Nothing End Sub
set winnt = GetObject("umi:///winnt/computer=alanbos4") set users = winnt.InstancesOf ("User") for each u in users WScript.Echo u.Description next
<gh_stars>100-1000 10 REM Lunar Lander 20 REM By <NAME> 25 REM Chipmunk Basic version 30 PRINT "You aboard the Lunar Lander about to leave the spacecraft." 60 GOSUB 4000 70 GOSUB 1000 80 GOSUB 2000 90 GOSUB 3000 100 H = H - V 110 V = ((V + G) * 10 - U * 2) / 10 120 F = F - U 130 IF H > 0 THEN 80 135 H = 0 140 GOSUB 2000 150 IF V > 5 THEN 200 160 PRINT "Congratulations! This was a very good landing." 170 GOSUB 5000 180 GOTO 10 200 PRINT "You have crashed." 210 GOTO 170 1000 REM Initialise 1010 V = 70 1020 F = 500 1030 H = 1000 1040 G = 2 1050 RETURN 2000 REM Print values 2010 PRINT " Meter readings" 2015 PRINT " --------------" 2020 PRINT "Fuel (gal):" 2030 PRINT F 2040 GOSUB 2100 + 100 * (H <> 0) 2050 PRINT V 2060 PRINT "Height (m):" 2070 PRINT H 2080 RETURN 2100 PRINT "Landing velocity (m/sec):" 2110 RETURN 2200 PRINT "Velocity (m/sec):" 2210 RETURN 3000 REM User input 3005 IF F = 0 THEN 3070 3010 PRINT "How much fuel will you use?" 3020 INPUT U 3025 IF U < 0 THEN 3090 3030 IF U <= F THEN 3060 3040 PRINT "Sorry, you have not got that much fuel!" 3045 PRINT F 3050 GOTO 3010 3060 RETURN 3070 U = 0 3080 RETURN 3090 PRINT "No cheating please! Fuel must be >= 0." 3100 GOTO 3010 4000 REM Detachment 4005 PRINT "Ready for detachment" 4007 PRINT "-- COUNTDOWN --" 4010 FOR I = 1 TO 11 4020 PRINT 11 - I 4025 GOSUB 4500 4030 NEXT I 4035 PRINT "You have left the spacecraft." 4037 PRINT "Try to land with velocity less than 5 m/sec." 4040 RETURN 4500 REM Delay 4510 FOR J = 1 TO 500 4520 NEXT J 4530 RETURN 5000 PRINT "Do you want to play again? (0 = no, 1 = yes)" 5010 INPUT Y 5020 IF Y = 0 THEN 5040 5030 RETURN 5040 PRINT "Have a nice day." 5050 END 9992 rem --- End of source code --- 9993 rem I know it stinks as a game, but see it as a relic from old times. 9994 rem <NAME>, PhD 9995 rem Image processing, Mac shareware games 9996 rem E-mail address: <EMAIL> or <EMAIL>
<filename>admin/pchealth/authtools/prodtools/ui/frmuri.frm VERSION 5.00 Begin VB.Form frmURI Caption = "Create URI" ClientHeight = 4215 ClientLeft = 60 ClientTop = 345 ClientWidth = 7695 LinkTopic = "Form1" ScaleHeight = 4215 ScaleWidth = 7695 StartUpPosition = 3 'Windows Default Begin VB.TextBox txtOldURI BackColor = &H8000000F& Height = 495 Left = 1080 Locked = -1 'True MultiLine = -1 'True TabIndex = 7 Tag = "1" Top = 1680 Width = 6495 End Begin VB.TextBox txtNewURI BackColor = &H8000000F& Height = 495 Left = 1080 Locked = -1 'True MultiLine = -1 'True TabIndex = 5 Tag = "1" Top = 1080 Width = 6495 End Begin VB.TextBox txtExample BackColor = &H8000000F& Height = 495 Left = 1080 Locked = -1 'True MultiLine = -1 'True TabIndex = 3 Top = 480 Width = 6495 End Begin VB.Frame fraVariables Caption = "Variables" Height = 1335 Left = 120 TabIndex = 8 Top = 2280 Width = 7455 Begin VB.TextBox txtVariable Height = 285 Index = 2 Left = 3480 TabIndex = 14 Tag = "1" Top = 960 Width = 3855 End Begin VB.TextBox txtVariable Height = 285 Index = 1 Left = 3480 TabIndex = 12 Tag = "1" Top = 600 Width = 3855 End Begin VB.TextBox txtVariable Height = 285 Index = 0 Left = 3480 TabIndex = 10 Tag = "1" Top = 240 Width = 3855 End Begin VB.Label lblVariable Alignment = 1 'Right Justify Caption = "Variable2" Height = 255 Index = 2 Left = 120 TabIndex = 13 Top = 960 Width = 3135 End Begin VB.Label lblVariable Alignment = 1 'Right Justify Caption = "Variable1" Height = 255 Index = 1 Left = 120 TabIndex = 11 Top = 600 Width = 3135 End Begin VB.Label lblVariable Alignment = 1 'Right Justify Caption = "Variable0" Height = 255 Index = 0 Left = 120 TabIndex = 9 Top = 240 Width = 3135 End End Begin VB.CommandButton cmdCancel Caption = "Cancel" Height = 375 Left = 6360 TabIndex = 16 Top = 3720 Width = 1215 End Begin VB.CommandButton cmdOK Caption = "OK" Height = 375 Left = 5040 TabIndex = 15 Top = 3720 Width = 1215 End Begin VB.ComboBox cboURIType Height = 315 Left = 1080 TabIndex = 1 Top = 120 Width = 6495 End Begin VB.Label lblOldURI Caption = "Old URI:" Height = 255 Left = 120 TabIndex = 6 Top = 1680 Width = 855 End Begin VB.Label lblNewURI Caption = "New URI:" Height = 255 Left = 120 TabIndex = 4 Top = 1080 Width = 855 End Begin VB.Label lblExample Caption = "Example:" Height = 255 Left = 120 TabIndex = 2 Top = 480 Width = 735 End Begin VB.Label lblURIType Caption = "URI Type:" Height = 255 Left = 120 TabIndex = 0 Top = 120 Width = 855 End End Attribute VB_Name = "frmURI" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Private Type URIStructure strDescription As String intNumVariables As Long arrStrings() As String arrVariables() As String End Type Private Const MAX_VARIABLES_C As Long = 3 Private Const NUM_URI_TYPES_C As Long = 8 Private p_URIStructures(NUM_URI_TYPES_C - 1) As URIStructure Private p_clsSizer As Sizer Private p_strOldURI As String Private Sub Form_Activate() cmdOK.Default = True cmdCancel.Cancel = True p_SetSizingInfo p_InitializeURIStructsArray p_InitializeComboBox cboURIType_Click txtOldURI = p_strOldURI p_SetToolTips SetFontInternal Me End Sub Private Sub Form_Load() Set p_clsSizer = New Sizer End Sub Private Sub Form_Unload(Cancel As Integer) Set p_clsSizer = Nothing Set frmURI = Nothing End Sub Private Sub Form_Resize() p_clsSizer.Resize End Sub Private Sub cboURIType_Click() Dim intIndex1 As Long Dim intIndex2 As Long Dim UStruct As URIStructure intIndex1 = cboURIType.ListIndex If (intIndex1 < 0) Then txtExample = "" txtNewURI = "" p_HideControls 0 Exit Sub End If UStruct = p_URIStructures(intIndex1) txtExample.Text = p_GetExample(UStruct) For intIndex2 = 0 To UStruct.intNumVariables - 1 lblVariable(intIndex2).Caption = UStruct.arrVariables(intIndex2) lblVariable(intIndex2).Visible = True txtVariable(intIndex2).Visible = True Next p_HideControls UStruct.intNumVariables txtVariable_Change 0 End Sub Private Sub txtVariable_Change(Index As Integer) Dim intIndex As Long Dim UStruct As URIStructure intIndex = cboURIType.ListIndex If (intIndex < 0) Then Exit Sub End If UStruct = p_URIStructures(intIndex) txtNewURI.Text = p_GetNewURI(UStruct) End Sub Private Sub cmdOK_Click() frmMain.SetURI txtNewURI Unload Me End Sub Private Sub cmdCancel_Click() Unload Me End Sub Public Sub SetOldURI( _ ByVal i_strURI As String _ ) p_strOldURI = i_strURI End Sub Private Sub p_InitializeURIStructsArray() Dim UStruct As URIStructure Dim intIndex As Long UStruct.strDescription = "MS-ITS:%HELP_LOCATION%\<CHM>::/<HTM>" UStruct.intNumVariables = 2 ReDim UStruct.arrStrings(UStruct.intNumVariables - 1) UStruct.arrStrings(0) = "MS-ITS:%HELP_LOCATION%\" UStruct.arrStrings(1) = "::/" ReDim UStruct.arrVariables(UStruct.intNumVariables - 1) UStruct.arrVariables(0) = "CHM" UStruct.arrVariables(1) = "HTM" p_URIStructures(intIndex) = UStruct intIndex = intIndex + 1 UStruct.strDescription = "Call a specific SUBSITE" UStruct.intNumVariables = 1 ReDim UStruct.arrStrings(UStruct.intNumVariables - 1) UStruct.arrStrings(0) = "hcp://services/subsite?node=" ReDim UStruct.arrVariables(UStruct.intNumVariables - 1) UStruct.arrVariables(0) = "subsite location" p_URIStructures(intIndex) = UStruct intIndex = intIndex + 1 UStruct.strDescription = "Call a specific SUBSITE, with a specific TOPIC open" UStruct.intNumVariables = 2 ReDim UStruct.arrStrings(UStruct.intNumVariables - 1) UStruct.arrStrings(0) = "hcp://services/subsite?node=" UStruct.arrStrings(1) = "&topic=" ReDim UStruct.arrVariables(UStruct.intNumVariables - 1) UStruct.arrVariables(0) = "subsite location" UStruct.arrVariables(1) = "url of the topic to display" p_URIStructures(intIndex) = UStruct intIndex = intIndex + 1 UStruct.strDescription = "Call a specific SUBSITE, with a specific TOPIC open and the appropriate NODE SELECTED" UStruct.intNumVariables = 3 ReDim UStruct.arrStrings(UStruct.intNumVariables - 1) UStruct.arrStrings(0) = "hcp://services/subsite?node=" UStruct.arrStrings(1) = "&topic=" UStruct.arrStrings(2) = "&select=" ReDim UStruct.arrVariables(UStruct.intNumVariables - 1) UStruct.arrVariables(0) = "subsite location" UStruct.arrVariables(1) = "url of the topic to display" UStruct.arrVariables(2) = "subnode to highlight" p_URIStructures(intIndex) = UStruct intIndex = intIndex + 1 UStruct.strDescription = "Call a topic that takes up the entire bottom pane (both left and right sides)" UStruct.intNumVariables = 1 ReDim UStruct.arrStrings(UStruct.intNumVariables - 1) UStruct.arrStrings(0) = "hcp://services/fullwindow?topic=" ReDim UStruct.arrVariables(UStruct.intNumVariables - 1) UStruct.arrVariables(0) = "url of the topic to display" p_URIStructures(intIndex) = UStruct intIndex = intIndex + 1 UStruct.strDescription = "Open an exe from HSS" UStruct.intNumVariables = 3 ReDim UStruct.arrStrings(UStruct.intNumVariables - 1) UStruct.arrStrings(0) = "app:" UStruct.arrStrings(1) = "?arg=" UStruct.arrStrings(2) = "&topic=" ReDim UStruct.arrVariables(UStruct.intNumVariables - 1) UStruct.arrVariables(0) = "application to launch" UStruct.arrVariables(1) = "optional arguments" UStruct.arrVariables(2) = "url of optional topic to display" p_URIStructures(intIndex) = UStruct intIndex = intIndex + 1 UStruct.strDescription = "Call a web page in IE" UStruct.intNumVariables = 2 ReDim UStruct.arrStrings(UStruct.intNumVariables - 1) UStruct.arrStrings(0) = "app:iexplore.exe?arg=" UStruct.arrStrings(1) = "&topic=" ReDim UStruct.arrVariables(UStruct.intNumVariables - 1) UStruct.arrVariables(0) = "optional arguments" UStruct.arrVariables(1) = "url of optional topic to display" p_URIStructures(intIndex) = UStruct intIndex = intIndex + 1 UStruct.strDescription = "Call a topic with a switch so that if the .chm isn't there, a default topic appears, telling the user to go and install optional components" UStruct.intNumVariables = 2 ReDim UStruct.arrStrings(UStruct.intNumVariables - 1) UStruct.arrStrings(0) = "hcp://services/redirect?online=" UStruct.arrStrings(1) = "&offline=" ReDim UStruct.arrVariables(UStruct.intNumVariables - 1) UStruct.arrVariables(0) = "url" UStruct.arrVariables(1) = "backup url" p_URIStructures(intIndex) = UStruct intIndex = intIndex + 1 End Sub Private Sub p_InitializeComboBox() Dim intIndex As Long For intIndex = 0 To NUM_URI_TYPES_C - 1 cboURIType.AddItem p_URIStructures(intIndex).strDescription Next cboURIType.ListIndex = 0 End Sub Private Sub p_HideControls(ByVal i_intIndex As Long) Dim intIndex As Long For intIndex = i_intIndex To MAX_VARIABLES_C - 1 lblVariable(intIndex).Visible = False txtVariable(intIndex).Visible = False Next End Sub Private Function p_GetExample( _ ByRef i_UStruct As URIStructure _ ) As String Dim intIndex As Long For intIndex = 0 To i_UStruct.intNumVariables - 1 p_GetExample = p_GetExample & _ i_UStruct.arrStrings(intIndex) & _ "<" & i_UStruct.arrVariables(intIndex) & ">" Next End Function Private Function p_GetNewURI( _ ByRef i_UStruct As URIStructure _ ) As String Dim intIndex As Long For intIndex = 0 To i_UStruct.intNumVariables - 1 p_GetNewURI = p_GetNewURI & _ i_UStruct.arrStrings(intIndex) & _ txtVariable(intIndex) Next End Function Private Sub p_SetSizingInfo() Static blnInfoSet As Boolean Dim intIndex As Long If (blnInfoSet) Then Exit Sub End If p_clsSizer.AddControl cboURIType Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = Me p_clsSizer.ReferenceDimension(DIM_RIGHT_E) = DIM_WIDTH_E p_clsSizer.AddControl txtExample Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = cboURIType p_clsSizer.AddControl txtNewURI Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = cboURIType p_clsSizer.AddControl txtOldURI Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = cboURIType p_clsSizer.AddControl fraVariables Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = cboURIType For intIndex = 0 To MAX_VARIABLES_C - 1 p_clsSizer.AddControl lblVariable(intIndex) Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = fraVariables p_clsSizer.ReferenceDimension(DIM_RIGHT_E) = DIM_WIDTH_E p_clsSizer.Operation(DIM_RIGHT_E) = OP_MULTIPLY_E p_clsSizer.AddControl txtVariable(intIndex) Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = fraVariables p_clsSizer.ReferenceDimension(DIM_LEFT_E) = DIM_WIDTH_E p_clsSizer.Operation(DIM_LEFT_E) = OP_MULTIPLY_E Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = fraVariables p_clsSizer.ReferenceDimension(DIM_RIGHT_E) = DIM_WIDTH_E Next p_clsSizer.AddControl cmdOK Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = Me p_clsSizer.ReferenceDimension(DIM_LEFT_E) = DIM_WIDTH_E p_clsSizer.AddControl cmdCancel Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = Me p_clsSizer.ReferenceDimension(DIM_LEFT_E) = DIM_WIDTH_E blnInfoSet = True End Sub Private Sub p_SetToolTips() Dim intIndex As Long lblURIType.ToolTipText = "Select the desired format of the URI for the selected topic." cboURIType.ToolTipText = lblURIType.ToolTipText For intIndex = 0 To MAX_VARIABLES_C - 1 txtVariable(intIndex).ToolTipText = "Type the file or path that matches your selected URI type." Next End Sub
'This script displays all currently installed services for each Service in _ GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf ("win32_service") WScript.Echo "" WScript.Echo Service.Description WScript.Echo " Executable: ", Service.PathName WScript.Echo " Status: ", Service.Status WScript.Echo " State: ", Service.State WScript.Echo " Start Mode: ", Service.StartMode Wscript.Echo " Start Name: ", Service.StartName next
class callback dim sRule public property let rule( x ) sRule = x end property public default function applyTo(a) dim p1 for i = lbound( a ) to ubound( a ) p1 = a( i ) a( i ) = eval( sRule ) next applyTo = a end function end class
n = 0 m = 1 first20 = "" after1k = "" Do If IsHarshad(m) And n <= 20 Then first20 = first20 & m & ", " n = n + 1 m = m + 1 ElseIf IsHarshad(m) And m > 1000 Then after1k = m Exit Do Else m = m + 1 End If Loop WScript.StdOut.Write "First twenty Harshad numbers are: " WScript.StdOut.WriteLine WScript.StdOut.Write first20 WScript.StdOut.WriteLine WScript.StdOut.Write "The first Harshad number after 1000 is: " WScript.StdOut.WriteLine WScript.StdOut.Write after1k Function IsHarshad(s) IsHarshad = False sum = 0 For i = 1 To Len(s) sum = sum + CInt(Mid(s,i,1)) Next If s Mod sum = 0 Then IsHarshad = True End If End Function
<reponame>npocmaka/Windows-Server-2003 '//+---------------------------------------------------------------------------- '// '// File: loadreg.frm '// '// Module: pbadmin.exe '// '// Synopsis: The regions dialog. '// '// Copyright (c) 1997-1999 Microsoft Corporation '// '// Author: quintinb Created Header 09/02/99 '// '//+---------------------------------------------------------------------------- VERSION 5.00 Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX" Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX" Begin VB.Form frmLoadRegion BorderStyle = 3 'Fixed Dialog ClientHeight = 4665 ClientLeft = 135 ClientTop = 1545 ClientWidth = 4485 Icon = "LoadReg.frx":0000 LinkTopic = "Form1" LockControls = -1 'True MaxButton = 0 'False MinButton = 0 'False PaletteMode = 1 'UseZOrder ScaleHeight = 4665 ScaleWidth = 4485 ShowInTaskbar = 0 'False WhatsThisButton = -1 'True WhatsThisHelp = -1 'True Begin VB.CommandButton cmbEdit Caption = "edit" Height = 345 Left = 3120 TabIndex = 2 Top = 630 WhatsThisHelpID = 90010 Width = 1215 End Begin VB.CommandButton cmbDelete Caption = "del" Height = 345 Left = 3120 TabIndex = 3 Top = 1125 WhatsThisHelpID = 90020 Width = 1215 End Begin VB.CommandButton cmbregsave Caption = "add" Height = 330 Left = 3120 TabIndex = 1 Top = 120 WhatsThisHelpID = 90000 Width = 1215 End Begin VB.Frame Frame1 Height = 60 Left = 3120 TabIndex = 7 Top = 1680 Width = 1245 End Begin VB.CommandButton cmbOK Caption = "ok" Height = 345 Left = 3120 TabIndex = 5 Top = 3720 WhatsThisHelpID = 10030 Width = 1215 End Begin VB.CommandButton cmbCancel Cancel = -1 'True Caption = "cancel" Height = 345 Left = 3120 TabIndex = 6 Top = 4200 WhatsThisHelpID = 10040 Width = 1230 End Begin VB.CommandButton loadReg Caption = "import" Height = 375 Left = 3120 TabIndex = 4 Top = 1920 WhatsThisHelpID = 90030 Width = 1215 End Begin ComctlLib.ListView RegionList Height = 4455 Left = 120 TabIndex = 0 Top = 105 WhatsThisHelpID = 90040 Width = 2835 _ExtentX = 5001 _ExtentY = 7858 View = 3 LabelWrap = -1 'True HideSelection = 0 'False _Version = 327682 ForeColor = -2147483640 BackColor = -2147483643 Appearance = 1 BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty NumItems = 1 BeginProperty ColumnHeader(1) {0713E8C7-850A-101B-AFC0-4210102A8DA7} Key = "" Object.Tag = "" Text = "region" Object.Width = 4022 EndProperty End Begin MSComDlg.CommonDialog commonregion Left = 3480 Top = 2640 _ExtentX = 847 _ExtentY = 847 _Version = 393216 DialogTitle = "Open Region File" Filter = "*.pbr Region file| *.pbr" End End Attribute VB_Name = "frmLoadRegion" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim intMaxRegionID As Integer Dim EditList As EditLists Dim bEditMode As Boolean Dim nNewOne As Integer Dim FirstEntry As Boolean Dim dbDataRegion As Database Dim rsDataRegion As Recordset Function FillRegionList() On Error GoTo ErrTrap Dim strTemp As String Dim intRowID As Integer Dim itmX As ListItem RegionList.ListItems.Clear RegionList.Sorted = False intMaxRegionID = 0 If rsDataRegion.BOF = False Then rsDataRegion.MoveFirst Do While Not rsDataRegion.EOF Set itmX = RegionList.ListItems.Add() intRowID = rsDataRegion!ID With itmX .Text = rsDataRegion!Region strTemp = "Key:" & intRowID .Key = strTemp End With If intMaxRegionID < intRowID Then intMaxRegionID = intRowID End If rsDataRegion.MoveNext If rsDataRegion.AbsolutePosition Mod 40 = 0 Then DoEvents Loop End If RegionList.Sorted = True Exit Function ErrTrap: Exit Function End Function Function LoadRegionRes() On Error GoTo LoadErr Me.Caption = LoadResString(2003) & " " & gsCurrentPB RegionList.ColumnHeaders(1).Text = LoadResString(2005) cmbregsave.Caption = LoadResString(1011) cmbEdit.Caption = LoadResString(1012) cmbDelete.Caption = LoadResString(1013) loadReg.Caption = LoadResString(2004) cmbOK.Caption = LoadResString(1002) cmbCancel.Caption = LoadResString(1003) ' set fonts SetFonts Me RegionList.Font.Charset = gfnt.Charset RegionList.Font.Name = gfnt.Name RegionList.Font.Size = gfnt.Size On Error GoTo 0 Exit Function LoadErr: Exit Function End Function Function SaveEdit(ByVal Action As String, ByVal ID As Integer, ByVal NewRegion As String, Optional ByVal OldRegion As String) As Integer ' populate the array - for performance reasons Dim intX As Integer Dim bFound As Boolean On Error GoTo SaveErr bFound = False If Action = "U" Or Action = "D" Then intX = 1 Do While intX <= EditList.Count If ID = EditList.ID(intX) Then ' this handles Adds that have been Updated before being ' written to the db. If Action = "U" And EditList.Action(intX) = "A" Then Action = "A" 'If EditList.Region(intX) = "" And _ EditList.Action(intX) = "A" Then Action = "A" End If bFound = True Exit Do End If intX = intX + 1 Loop End If If Not bFound Then intX = EditList.Count + 1 EditList.Count = intX ReDim Preserve EditList.Action(intX) ReDim Preserve EditList.ID(intX) ReDim Preserve EditList.Region(intX) ReDim Preserve EditList.OldRegion(intX) End If EditList.Action(intX) = Action EditList.ID(intX) = ID EditList.Region(intX) = NewRegion If Action = "U" Then EditList.OldRegion(intX) = OldRegion End If On Error GoTo 0 Exit Function SaveErr: Exit Function End Function Private Sub cmbCancel_Click() Unload Me End Sub Private Sub cmbDelete_Click() Dim intX As Integer On Error Resume Next intX = MsgBox(LoadResString(6024), vbQuestion + vbYesNo + vbDefaultButton2) If intX = 6 Then SaveEdit "D", _ Right(RegionList.SelectedItem.Key, Len(RegionList.SelectedItem.Key) - 4), _ RegionList.SelectedItem.Text RegionList.ListItems.Remove RegionList.SelectedItem.Key End If RegionList.SetFocus End Sub Private Sub cmbEdit_Click() On Error GoTo ErrTrap RegionList.SetFocus RegionList.StartLabelEdit Exit Sub ErrTrap: Exit Sub End Sub Private Sub cmbOK_Click() Dim rsTemp As Recordset Dim intX, intY As Integer Dim intRegionID As Integer Dim itemY As ListItem Dim bUpdates As Boolean Dim PerformedDelete As Boolean Dim rsTempPop As Recordset, rsTempDelta As Recordset Dim i As Integer, deltnum As Integer Dim deltasql As String, popsql As String PerformedDelete = False If bEditMode Then RegionList.SetFocus SendKeys "{ENTER}", True RegionList_AfterLabelEdit 1, RegionList.SelectedItem.Text 'bEditMode = False End If On Error GoTo SaveErr Me.MousePointer = 11 frmLoadRegion.Enabled = False bUpdates = False Set rsTemp = gsyspb.OpenRecordset("Region", dbOpenDynaset) 'Debug.Print ("editlist.count = " & EditList.Count) For intX = 1 To EditList.Count Select Case EditList.Action(intX) Case "D" 'delete gsyspb.Execute "Delete from Region Where RegionID =" & EditList.ID(intX) popsql = "Select * from DialUpPort where RegionID = " & EditList.ID(intX) Set rsTempPop = gsyspb.OpenRecordset(popsql, dbOpenDynaset) If Not (rsTempPop.BOF And rsTempPop.EOF) Then rsTempPop.MoveFirst Do Until rsTempPop.EOF rsTempPop.Edit rsTempPop!RegionID = 0 rsTempPop.Update If rsTempPop!status = 1 Then Set rsTempDelta = gsyspb.OpenRecordset("Select * from Delta order by DeltaNum", dbOpenDynaset) If rsTempDelta.RecordCount = 0 Then deltnum = 1 Else rsTempDelta.MoveLast deltnum = rsTempDelta!deltanum If deltnum > 6 Then deltnum = deltnum - 1 End If End If For i = 1 To deltnum deltasql = "Select * from delta where DeltaNum = " & i & _ " AND AccessNumberId = '" & rsTempPop!AccessNumberId & "' " & _ " order by DeltaNum" Set rsTempDelta = gsyspb.OpenRecordset(deltasql, dbOpenDynaset) If Not (rsTempDelta.BOF And rsTempDelta.EOF) Then rsTempDelta.Edit Else rsTempDelta.AddNew rsTempDelta!deltanum = i rsTempDelta!AccessNumberId = rsTempPop!AccessNumberId End If If rsTempPop!status = 1 Then rsTempDelta!CountryNumber = rsTempPop!CountryNumber rsTempDelta!AreaCode = rsTempPop!AreaCode rsTempDelta!AccessNumber = rsTempPop!AccessNumber rsTempDelta!MinimumSpeed = rsTempPop!MinimumSpeed rsTempDelta!MaximumSpeed = rsTempPop!MaximumSpeed rsTempDelta!RegionID = rsTempPop!RegionID rsTempDelta!CityName = rsTempPop!CityName rsTempDelta!ScriptId = rsTempPop!ScriptId rsTempDelta!Flags = rsTempPop!Flags rsTempDelta.Update End If Next i End If rsTempPop.MoveNext Loop End If LogRegionDelete EditList.Region(intX), EditList.Region(intX) & ";" & EditList.ID(intX) PerformedDelete = True bUpdates = True Case "U" 'update If EditList.Region(intX) <> "" Then gsyspb.Execute "Update Region set RegionDesc='" & EditList.Region(intX) & _ "' Where RegionID =" & EditList.ID(intX) LogRegionEdit EditList.OldRegion(intX), EditList.Region(intX) & ";" & EditList.ID(intX) bUpdates = True End If Case "A" 'add If EditList.Region(intX) <> "" Then With rsTemp .AddNew !RegionID = EditList.ID(intX) !RegionDesc = EditList.Region(intX) .Update End With LogRegionAdd EditList.Region(intX), EditList.Region(intX) & ";" & EditList.ID(intX) End If End Select If intX Mod 5 = 0 Then DoEvents Next If PerformedDelete Then If Not ReIndexRegions(gsyspb) Then GoTo SaveErr End If rsTemp.Close If bUpdates Then frmMain.FillPOPList frmLoadRegion.Enabled = True Me.MousePointer = 0 On Error GoTo 0 Unload Me Exit Sub SaveErr: frmLoadRegion.Enabled = True Me.MousePointer = 0 MsgBox LoadResString(6056) & Chr(13) & Chr(13) & Err.Description, vbExclamation Exit Sub 'GsysPb.Execute "Delete from Region", dbFailOnError 'Set rsTemp = GsysPb.OpenRecordset("Region", dbOpenDynaset) 'For intX = 1 To RegionList.ListItems.Count ' Set itemY = RegionList.ListItems(intX) ' With rsTemp ' .AddNew ' !regionID = Right(itemY.Key, Len(itemY.Key) - 4) ' !regiondesc = Left$(itemY.Text, 30) ' .Update ' End With ' If intX Mod 25 = 0 Then DoEvents 'Next 'rsTemp.Close 'Set rsTemp = Nothing 'check for deletes 'Set rsTemp = GsysPb.OpenRecordset("Region", dbOpenDynaset) 'If Not (rsTemp.BOF And rsTemp.EOF) Then ' rsTemp.MoveLast ' rsTemp.MoveFirst ' For intX = 1 To rsTemp.RecordCount ' intRegionID = rsTemp!regionID ' intY = 1 ' Do While intY <= RegionList.ListItems.Count ' Set itemY = RegionList.ListItems(intY) ' If Val(Right(itemY.Key, Len(itemY.Key) - 4)) = intRegionID Then ' Exit Do ' End If ' intY = intY + 1 ' Loop ' If intY > RegionList.ListItems.Count Then ' no find - didn't fall out of loop early 'clear region id ' GsysPb.Execute "Update DialUpPort set RegionID = 0 WHERE RegionID =" & intRegionID ' GsysPb.Execute "Update Delta set RegionID = 0 WHERE RegionID ='" & intRegionID & "'" ' End If ' rsTemp.MoveNext ' If intX Mod 25 = 0 Then DoEvents ' Next 'End If 'rsTemp.Close 'Set itemY = Nothing End Sub Private Sub cmbregsave_Click() Dim itmX As ListItem Dim strNewKey, strOldKey, strOldText, strNewRegion As String On Error GoTo ErrTrap If bEditMode Then RegionList.SetFocus SendKeys "{ENTER}", True bEditMode = False End If strNewRegion = LoadResString(2006) Set itmX = RegionList.FindItem(strNewRegion, lvwText) If Not itmX Is Nothing Then itmX.Selected = True Set RegionList.SelectedItem = RegionList.ListItems(itmX.Key) RegionList.SetFocus itmX.EnsureVisible Exit Sub Else strNewKey = "Key:" & intMaxRegionID + 1 'If RegionList.SelectedItem Is Nothing Then Set itmX = RegionList.ListItems.Add() With itmX .Text = strNewRegion .Key = strNewKey .Selected = True End With Set RegionList.SelectedItem = RegionList.ListItems(itmX.Key) RegionList.SetFocus itmX.EnsureVisible 'Else 'jump thru hoops to make listview work right. ' With RegionList.SelectedItem ' strOldText = .Text ' .Text = strNewRegion ' strOldKey = .Key ' .Key = strNewKey ' End With ' Set itmX = RegionList.ListItems.Add() ' With itmX ' .Text = strOldText ' .Key = strOldKey ' End With 'End If SaveEdit "A", intMaxRegionID + 1, "" ' save an empty region to key on later intMaxRegionID = intMaxRegionID + 1 End If Set RegionList.SelectedItem = RegionList.ListItems(itmX.Key) RegionList.SetFocus RegionList.StartLabelEdit ' The second StartLabelEdit causes this to work ??? RegionList.StartLabelEdit On Error GoTo 0 Exit Sub ErrTrap: Me.MousePointer = 0 Exit Sub End Sub Private Sub Form_Activate() Screen.MousePointer = 11 Me.Enabled = False FillRegionList Me.Enabled = True Screen.MousePointer = 0 If RegionList.ListItems.Count = 0 Then RegionList.TabStop = False End If End Sub Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) Dim ShiftDown ShiftDown = (Shift And vbShiftMask) > 0 If KeyCode = 222 And ShiftDown Then Beep KeyCode = 0 End If End Sub Private Sub Form_KeyPress(KeyAscii As Integer) CheckChar KeyAscii End Sub Private Sub Form_Load() On Error GoTo LoadErr bEditMode = False CenterForm Me, Screen EditList.Count = 0 Me.Enabled = False LoadRegionRes 'new Set dbDataRegion = OpenDatabase(gsCurrentPBPath) Set rsDataRegion = dbDataRegion.OpenRecordset("Select RegionDesc as Region, RegionID as ID from Region order by RegionDesc") Me.Enabled = True Screen.MousePointer = 0 FirstEntry = True Exit Sub LoadErr: Me.Enabled = True Screen.MousePointer = 0 Exit Sub End Sub Private Sub Form_Unload(Cancel As Integer) rsDataRegion.Close dbDataRegion.Close End Sub Private Sub loadReg_Click() Dim fileopen As String Dim maxindex As Integer Dim indexcount, intY As Integer Dim Count As Integer Dim itmX As ListItem Dim strTemp As String Dim bFlag As Boolean On Error GoTo ErrTrap maxindex = 200 ReDim Region(maxindex) As String commonregion.Filter = LoadResString(2007) commonregion.FilterIndex = 1 commonregion.Flags = cdlOFNHideReadOnly commonregion.ShowOpen fileopen = commonregion.FileName If fileopen = "" Then Exit Sub Open fileopen For Input Access Read As #1 If EOF(1) Then Close #1 Exit Sub End If Input #1, Count indexcount = 1 Do While indexcount <= Count And Not EOF(1) Input #1, Region(indexcount) Region(indexcount) = Left(Trim(Region(indexcount)), 30) If Region(indexcount) <> "" Then indexcount = indexcount + 1 End If Loop Close #1 Count = indexcount - 1 For indexcount = 1 To Count ' check for dups intY = 1 bFlag = False Do While intY <= RegionList.ListItems.Count If LCase(RegionList.ListItems(intY)) = LCase(Region(indexcount)) Then bFlag = True Exit Do End If intY = intY + 1 Loop ' add if not a dup If Not bFlag Then Set itmX = RegionList.ListItems.Add() With itmX .Text = Left(Region(indexcount), 30) strTemp = "Key:" & intMaxRegionID + 1 .Key = strTemp End With SaveEdit "A", intMaxRegionID + 1, Left(Region(indexcount), 30) intMaxRegionID = intMaxRegionID + 1 End If Next indexcount RegionList.Sorted = True Exit Sub ErrTrap: If Err.Number = 62 Or Err.Number = 3163 Then Exit Sub Else Exit Sub End If End Sub Private Sub RegionList_BeforeLabelEdit(Cancel As Integer) 'Debug.Print ("BeforeLabelEdit") bEditMode = True 'Debug.Print ("working on " & RegionList.SelectedItem.index) nNewOne = RegionList.SelectedItem.index End Sub ' This doesn't get called if no changes are made to the default text ' Private Sub RegionList_AfterLabelEdit(Cancel As Integer, NewString As String) 'Debug.Print ("AfterLabelEdit") Dim itmX As ListItem bEditMode = False If Trim(NewString) = "" Then Cancel = True RegionList.StartLabelEdit Exit Sub End If ' null indicates the user canceled the edit If Not IsNull(NewString) Then NewString = Left(Trim(NewString), 30) ' check for dups Set itmX = RegionList.FindItem(NewString, lvwText) If Not itmX Is Nothing Then If itmX.index <> nNewOne Then MsgBox LoadResString(6025), vbExclamation Cancel = True RegionList.StartLabelEdit Exit Sub End If End If 'Debug.Print (NewString) Set itmX = RegionList.SelectedItem 'Debug.Print (itmX.Key) SaveEdit "U", Right(itmX.Key, Len(itmX.Key) - 4), NewString, itmX RegionList.SortKey = 0 RegionList.Sorted = True End If End Sub Private Sub RegionList_ItemClick(ByVal Item As ComctlLib.ListItem) If bEditMode Then RegionList_AfterLabelEdit 1, RegionList.ListItems.Item(nNewOne).Text End If End Sub Private Sub RegionList_LostFocus() If RegionList.ListItems.Count > 0 Then RegionList.TabStop = True End If End Sub
<filename>basic/examples/a/for.bas 100 FOR x=1 TO 10 STEP 2 PRINT X NEXT X
Debug.Print Hex(&HF0F0 And &HFF00) 'F000 Debug.Print Hex(&HF0F0 Or &HFF00) 'FFF0 Debug.Print Hex(&HF0F0 Xor &HFF00) 'FF0 Debug.Print Hex(Not &HF0F0) 'F0F Debug.Print Hex(&HF0F0 Eqv &HFF00) 'F00F Debug.Print Hex(&HF0F0 Imp &HFF00) 'FF0F
<reponame>npocmaka/Windows-Server-2003 VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 'Windows Default End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Form_Load() Dim Class As SWbemObject Set Class = GetObject("winmgmts:").Get Class.Path_.Class = "Fred" 'Note that by commenting out the next line 'the array assignment below works! This is due to the IDispatch code 'for SWbemProperty handling the array assignment logic correctly, but 'the vtable code relies on VB interpreting the array assignment as a Put - 'however it interprets it as "Retrive the VARIANT corresponding to 'Property.Value, assign that to a temporary VB variable, and set the 'temporary variable. Dim Property As SWbemProperty Set Property = Class.Properties_.Add("p1", wbemCimtypeUint32, True) Property.Value = Array(1, 45, 23) 'Debug.Print Property(0) 'Debug.Print Property(1) Property.Value(2) = 3 'Debug.Print Property(2) End Sub
<reponame>LaudateCorpus1/RosettaCodeData 'pancake sort 'uses two auxiliary routines "printarray" and "flip" Public Sub printarray(A) For i = LBound(A) To UBound(A) Debug.Print A(i), Next Debug.Print End Sub Public Sub Flip(ByRef A, p1, p2, trace) 'flip first elements of A (p1 to p2) If trace Then Debug.Print "we'll flip the first "; p2 - p1 + 1; "elements of the array" Cut = Int((p2 - p1 + 1) / 2) For i = 0 To Cut - 1 'flip position i and (n - i + 1) temp = A(i) A(i) = A(p2 - i) A(p2 - i) = temp Next End Sub Public Sub pancakesort(ByRef A(), Optional trace As Boolean = False) 'sort A into ascending order using pancake sort lb = LBound(A) ub = UBound(A) Length = ub - lb + 1 If Length <= 1 Then 'no need to sort Exit Sub End If For i = ub To lb + 1 Step -1 'find position of max. element in subarray A(lowerbound to i) P = lb Maximum = A(P) For j = lb + 1 To i If A(j) > Maximum Then P = j Maximum = A(j) End If Next j 'check if maximum is already at end - then we don't need to flip If P < i Then 'flip the first part of the array up to the maximum so it is at the head - skip if it is already there If P > 1 Then Flip A, lb, P, trace If trace Then printarray A End If 'now flip again so that it is in its final position Flip A, lb, i, trace If trace Then printarray A End If Next i End Sub 'test routine Public Sub TestPancake(Optional trace As Boolean = False) Dim A() A = Array(5, 7, 8, 3, 1, 10, 9, 23, 50, 0) Debug.Print "Initial array:" printarray A pancakesort A, trace Debug.Print "Final array:" printarray A End Sub
Option Explicit Sub Main() Dim T# T = Timer Debug.Print SumMult3and5VBScript(100000000) & " " & Format(Timer - T, "0.000 sec.") T = Timer Debug.Print SumMult3and5(100000000) & " " & Format(Timer - T, "0.000 sec.") T = Timer Debug.Print SumMult3and5BETTER(100000000) & " " & Format(Timer - T, "0.000 sec.") Debug.Print "-------------------------" Debug.Print SumMult3and5BETTER(1000) End Sub
on error resume next 'First pass - on mutable object WScript.Echo "************************" WScript.Echo "PASS 1 - SWbemObjectPath" WScript.Echo "************************" WScript.Echo "" Set Path = CreateObject("WbemScripting.SWbemObjectPath") WScript.Echo "Expect """"" WScript.Echo """" & Path.DisplayName & """" WScript.Echo "" Path.DisplayName = "winmgmts:{impersonationlevel=impersonate,authenticationLevel=pkt}!root/cimv2:Win32_Wibble.Name=10,Zip=7" WScript.Echo "Initial Value" WScript.Echo Path.DisplayName WScript.Echo "" Path.DisplayName = "winmgmts:{" WScript.Echo "Single brace" WScript.Echo Path.DisplayName WScript.Echo "" if err <> 0 then WScript.Echo "Got expected error: ", Err.Description, Err.Source, Err.Number WScript.Echo "" err.clear end if Path.DisplayName = "winmgmts:{impersonationLevel=impersonate}}!root/cimv2:Win32_Wibble.Name=10,Zip=7" WScript.Echo "Unbalanced braces" WScript.Echo Path.DisplayName WScript.Echo "" if err <> 0 then WScript.Echo "Got expected error: ", Err.Description, Err.Source, Err.Number WScript.Echo "" err.clear end if Path.DisplayName = "winmgmts:{authenticationLevel=impersonate}!root/cimv2:Win32_Wibble.Name=10,Zip=7" WScript.Echo "Inappropriate authentication level" WScript.Echo Path.DisplayName WScript.Echo "" if err <> 0 then WScript.Echo "Got expected error: ", Err.Description, Err.Source, Err.Number WScript.Echo "" err.clear end if Path.DisplayName = "winmgmts:{impersonationLevel=impersonate,impersonationLevel=identify}!root/cimv2:Win32_Wibble.Name=10,Zip=7" WScript.Echo "Attempt to set impersonation level twice" WScript.Echo Path.DisplayName WScript.Echo "" if err <> 0 then WScript.Echo "Got expected error: ", Err.Description, Err.Source, Err.Number WScript.Echo "" err.clear end if Path.DisplayName = "winmgmts:{authenticationLevel=default,authenticationLevel=pktPrivacy}!root/cimv2:Win32_Wibble.Name=10,Zip=7" WScript.Echo "Attempt to set authentication level twice" WScript.Echo Path.DisplayName WScript.Echo "" if err <> 0 then WScript.Echo "Got expected error: ", Err.Description, Err.Source, Err.Number WScript.Echo "" err.clear end if Path.DisplayName = "winmgmts:{authenticationLevel=none,}!" WScript.Echo "Trailing comma" WScript.Echo Path.DisplayName WScript.Echo "" if err <> 0 then WScript.Echo "Got expected error: ", Err.Description, Err.Source, Err.Number WScript.Echo "" err.clear end if Path.DisplayName = "winmgmts:{authenticationLevel=call,impersonationLevel=identify,}" WScript.Echo "Trailing comma (2)" WScript.Echo Path.DisplayName WScript.Echo "" if err <> 0 then WScript.Echo "Got expected error: ", Err.Description, Err.Source, Err.Number WScript.Echo "" err.clear end if Path.DisplayName = "winmgmts:{,authenticationLevel=pkt,impersonationLevel=delegate}!" WScript.Echo "Leading comma" WScript.Echo Path.DisplayName WScript.Echo "" if err <> 0 then WScript.Echo "Got expected error: ", Err.Description, Err.Source, Err.Number WScript.Echo "" err.clear end if Path.DisplayName = "winmgmts:authenticationLevel=pktIntegrity,impersonationLevel=identify}" WScript.Echo "Missing {" WScript.Echo Path.DisplayName WScript.Echo "" if err <> 0 then WScript.Echo "Got expected error: ", Err.Description, Err.Source, Err.Number WScript.Echo "" err.clear end if Path.DisplayName = "winmgmts:{authenticationLevel=pktPrivacy,impersonationLevel=identify!root/default" WScript.Echo "Missing }" WScript.Echo Path.DisplayName WScript.Echo "" if err <> 0 then WScript.Echo "Got expected error: ", Err.Description, Err.Source, Err.Number WScript.Echo "" err.clear end if Path.DisplayName = "winmgmts:{authenticationLevel=pktPrivacy,impersonationLevel=identify}root/default:__Cimomidentification=@" WScript.Echo "Missing !" WScript.Echo Path.DisplayName WScript.Echo "" if err <> 0 then WScript.Echo "Got expected error: ", Err.Description, Err.Source, Err.Number WScript.Echo "" err.clear end if
Function MaskL(k As Integer) As Long If k < 1 Then MaskL = 0 ElseIf k > 31 Then MaskL = -1 Else MaskL = (-1) Xor (2 ^ (32 - k) - 1) End If End Function Function MaskR(k As Integer) As Long If k < 1 Then MaskR = 0 ElseIf k > 31 Then MaskR = -1 Else MaskR = 2 ^ k - 1 End If End Function Function Bit(k As Integer) As Long If k < 0 Or k > 31 Then Bit = 0 ElseIf k = 31 Then Bit = MaskL(1) Else Bit = 2 ^ k End If End Function Function ShiftL(n As Long, k As Integer) As Long If k = 0 Then ShiftL = n ElseIf k > 31 Then ShiftL = 0 ElseIf k < 0 Then ShiftL = ShiftR(n, -k) Else ShiftL = (n And MaskR(31 - k)) * 2 ^ k If (n And Bit(31 - k)) <> 0 Then ShiftL = ShiftL Or MaskL(1) End If End Function Function ShiftR(n As Long, k As Integer) As Long If k = 0 Then ShiftR = n ElseIf k > 31 Then ShiftR = 0 ElseIf k < 0 Then ShiftR = ShiftL(n, -k) Else ShiftR = (n And MaskR(31)) \ 2 ^ k If (n And MaskL(1)) <> 0 Then ShiftR = ShiftR Or Bit(31 - k) End If End Function Function RotateL(n As Long, k As Integer) As Long k = (32768 + k) Mod 32 If k = 0 Then RotateL = n Else RotateL = ShiftL(n, k) Or ShiftR(n, 32 - k) End If End Function Function RotateR(n As Long, k As Integer) As Long k = (32768 + k) Mod 32 If k = 0 Then RotateR = n Else RotateR = ShiftR(n, k) Or ShiftL(n, 32 - k) End If End Function Function ClearBit(n As Long, k As Integer) As Long ClearBit = n And Not Bit(k) End Function Function SetBit(n As Long, k As Integer) As Long SetBit = n Or Bit(k) End Function Function SwitchBit(n As Long, k As Integer) As Long SwitchBit = n Xor Bit(k) End Function Function TestBit(n As Long, k As Integer) As Boolean TestBit = (n And Bit(k)) <> 0 End Function
<reponame>LaudateCorpus1/RosettaCodeData Option Base 1 Private Function insertion_sort(s As Variant) As Variant Dim temp As Variant Dim j As Integer For i = 2 To UBound(s) temp = s(i) j = i - 1 Do While s(j) > temp s(j + 1) = s(j) j = j - 1 If j = 0 Then Exit Do Loop s(j + 1) = temp Next i insertion_sort = s End Function Public Sub main() s = [{4, 15, "delta", 2, -31, 0, "alpha", 19, "gamma", 2, 13, "beta", 782, 1}] Debug.Print "Before: ", Join(s, ", ") Debug.Print "After: ", Join(insertion_sort(s), "' ") End Sub
i=0 On Error GoTo overflow i = 2147483647 + 1 ... overflow: Debug.Print "Error: " & Err.Description '-> Error: Overflow
<gh_stars>1-10 Function horners_rule(coefficients,x) accumulator = 0 For i = UBound(coefficients) To 0 Step -1 accumulator = (accumulator * x) + coefficients(i) Next horners_rule = accumulator End Function WScript.StdOut.WriteLine horners_rule(Array(-19,7,-4,6),3)
<reponame>mullikine/RosettaCodeData Sub Main() Dim d As Double ' 8 Bytes, type specifier = # Dim s As Single ' 4 Bytes, type specifier = ! d = -12.3456 d = 1000# d = 0.00001 d = 67# d = 8.9 d = 0.33 d = 0# d = 2# * 10 ^ 3 d = 2E+50 d = 2E-50 s = -12.3456! s = 1000! s = 0.00001! s = 67! s = 8.9! s = 0.33! s = 0! s = 2! * 10 ^ 3 End Sub
function looksay( n ) dim i dim accum dim res dim c res = vbnullstring do if n = vbnullstring then exit do accum = 0 c = left( n,1 ) do while left( n, 1 ) = c accum = accum + 1 n = mid(n,2) loop if accum > 0 then res = res & accum & c end if loop looksay = res end function
CreateObject("Scripting.FileSystemObject").OpenTextFile("output.txt",2,-2).Write CreateObject("Scripting.FileSystemObject").OpenTextFile("input.txt", 1, -2).ReadAll
Sub Main() Debug.Assert LuhnCheckPassed("49927398716") Debug.Assert Not LuhnCheckPassed("49927398717") Debug.Assert Not LuhnCheckPassed("1234567812345678") Debug.Assert LuhnCheckPassed("1234567812345670") End Sub
<filename>net/unimodem/tools/src/startup.frm VERSION 5.00 Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.2#0"; "COMCTL32.OCX" Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX" Begin VB.Form frmStart Caption = "Inf Devil" ClientHeight = 7980 ClientLeft = 165 ClientTop = 795 ClientWidth = 7635 LinkTopic = "Form1" ScaleHeight = 7980 ScaleWidth = 7635 StartUpPosition = 3 'Windows Default Begin VB.CommandButton cmdGo Caption = "&Go!" Default = -1 'True BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Left = 5760 TabIndex = 15 Top = 2640 Width = 855 End Begin VB.CheckBox chkFax Caption = "Check &Fax" Height = 255 Left = 5760 TabIndex = 14 Top = 2280 Value = 1 'Checked Width = 1815 End Begin VB.CheckBox chkVoice Caption = "Check V&oice" Height = 255 Left = 5760 TabIndex = 13 Top = 1920 Value = 1 'Checked Width = 1815 End Begin VB.CheckBox chkData Caption = "Check &Data" Height = 255 Left = 5760 TabIndex = 12 Top = 1560 Value = 1 'Checked Width = 1815 End Begin ComctlLib.ListView ListView1 Height = 4215 Left = 120 TabIndex = 11 Top = 3240 Width = 7455 _ExtentX = 13150 _ExtentY = 7435 View = 3 LabelWrap = -1 'True HideSelection = -1 'True _Version = 327682 ForeColor = -2147483640 BackColor = -2147483643 BorderStyle = 1 Appearance = 1 NumItems = 2 BeginProperty ColumnHeader(1) {0713E8C7-850A-101B-AFC0-4210102A8DA7} Key = "clmCommand" Object.Tag = "" Text = "Command" Object.Width = 1764 EndProperty BeginProperty ColumnHeader(2) {0713E8C7-850A-101B-AFC0-4210102A8DA7} SubItemIndex = 1 Key = "clmResponse" Object.Tag = "" Text = "Response" Object.Width = 9878 EndProperty End Begin VB.OptionButton OptionPort Caption = "Com &8" Height = 300 Index = 7 Left = 6720 TabIndex = 10 Top = 1200 Width = 900 End Begin VB.OptionButton OptionPort Caption = "Com &7" Height = 300 Index = 6 Left = 6720 TabIndex = 9 Top = 840 Width = 900 End Begin VB.OptionButton OptionPort Caption = "Com &6" Height = 300 Index = 5 Left = 6720 TabIndex = 8 Top = 480 Width = 900 End Begin VB.OptionButton OptionPort Caption = "Com &5" Height = 300 Index = 4 Left = 6720 TabIndex = 7 Top = 120 Width = 900 End Begin VB.OptionButton OptionPort Caption = "Com &4" Height = 300 Index = 3 Left = 5760 TabIndex = 6 Top = 1200 Width = 900 End Begin VB.OptionButton OptionPort Caption = "Com &3" Height = 300 Index = 2 Left = 5760 TabIndex = 5 Top = 840 Width = 900 End Begin VB.OptionButton OptionPort Caption = "Com &2" Height = 300 Index = 1 Left = 5760 TabIndex = 4 Top = 480 Width = 900 End Begin VB.OptionButton OptionPort Caption = "Com &1" Height = 300 Index = 0 Left = 5760 TabIndex = 3 Top = 120 Width = 900 End Begin VB.Timer Timer1 Interval = 1000 Left = 3480 Top = 7200 End Begin MSCommLib.MSComm MSComm1 Left = 3960 Top = 7080 _ExtentX = 1005 _ExtentY = 1005 _Version = 327681 CommPort = 3 DTREnable = -1 'True End Begin VB.CommandButton cmdExit Cancel = -1 'True Caption = "E&xit" BeginProperty Font Name = "<NAME> Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Left = 6720 TabIndex = 2 Top = 2640 Visible = 0 'False Width = 855 End Begin ComctlLib.StatusBar StatusBar1 Align = 2 'Align Bottom Height = 375 Left = 0 TabIndex = 1 Top = 7605 Width = 7635 _ExtentX = 13467 _ExtentY = 661 SimpleText = "" _Version = 327682 BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7} NumPanels = 2 BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7} AutoSize = 1 Object.Width = 11615 TextSave = "" Key = "" Object.Tag = "" EndProperty BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7} Style = 5 AutoSize = 2 Object.Width = 1402 MinWidth = 1411 TextSave = "12:44 PM" Key = "" Object.Tag = "" EndProperty EndProperty End Begin VB.CommandButton cmdShowIniReader Caption = "Edit Command File" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Left = 4560 TabIndex = 0 Top = 7080 Visible = 0 'False Width = 1335 End Begin VB.Menu mnuFile Caption = "&File" Begin VB.Menu mnuFileExit Caption = "&Exit" End End Begin VB.Menu mnuEdit Caption = "&Edit" Begin VB.Menu mnuEditCommand Caption = "&Command File" End End Begin VB.Menu mnuView Caption = "&View" End Begin VB.Menu mnuHelp Caption = "&Help" End End Attribute VB_Name = "frmStart" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Dim Command() As String Dim CP As Integer Public FileName$ Const INIFILE = "Unicompiled.ini" Private Sub cmdExit_Click() Unload Me End Sub Private Sub cmdGo_Click() StatusBar1.Panels(1).Text = "Working" cmdGo.Enabled = False GetPort StatusBar1.Panels(1).Text = "Finished" cmdGo.Enabled = True End Sub Private Sub cmdShowIniReader_Click() frmVB5INI.Show vbModal, Me End Sub Private Sub Form_Load() Dim Instring As String ' Buffer to hold input string ' This sample expects to see the INI file in the application ' directory. At design time, the current directory is VB, so ' we add the app.path to make sure we choose the right place. ' The \ handling deals with the unlikely event that the INI file ' is in the root directory. ' FileName$ = App.Path If Right$(FileName$, 1) <> "\" Then FileName$ = FileName$ & "\" FileName$ = FileName$ & INIFILE Timer1.Enabled = False Dim TextLine As String Dim First As String Dim x As Integer x = 0 Open "UQuery1.ini" For Input As #1 ' Open input file. Open "Unicompiled.ini" For Output As #2 ' Open output file. Do While Not EOF(1) ' Loop until end of file. Line Input #1, TextLine ' Read line into variable. First = Mid(TextLine, 1, 1) Select Case First Case "'" Case "[" Case "" Case Else x = x + 1 TextLine = "Key" & x & " = " & TextLine End Select Print #2, TextLine ' Write line to file. 'Debug.Print TextLine ' Print to Debug window. Loop Close #1 ' Close file. Close #2 ' Close file. End Sub Private Sub mnuEditCommand_Click() cmdShowIniReader_Click End Sub Private Sub mnuFileExit_Click() cmdExit_Click End Sub Private Sub OptionPort_Click(Index As Integer) cmdGo.Caption = "Go!" StatusBar1.Panels(1).Text = "Ready" cmdGo.Enabled = True CP = Index + 1 ' Select port. MSComm1.CommPort = CP If MSComm1.PortOpen = True Then MSComm1.PortOpen = False End If End Sub Private Function GetPort() MSComm1.CommPort = CP ' Use selected port. MSComm1.Settings = "9600,N,8,1" ' 9600 baud, no parity, 8 data, and 1 stop bit. MSComm1.InputLen = 0 ' Tell the control to read entire buffer when Input is used. MSComm1.PortOpen = True ' Open the port. GetCommand MSComm1.PortOpen = False ' Close the serial port. End Function Private Function GetCommand() Dim characters Dim itmX As ListItem Dim KeyList$ Dim KeyValue$ KeyList$ = String$(2048, 0) ' Retrieve the list of keys in the section ' Note that characters is always a long here - in 16 bit mode ' VB will convert the integer result of the API function into ' a long - no problem. characters = GetPrivateProfileStringKeys("UnimodemID.Scan", 0, "", KeyList$, 2047, FileName$) ReDim Command(characters) Dim x As Integer x = -1 ' Load sections into the list box Dim NullOffset% Do x = x + 1 NullOffset% = InStr(KeyList$, Chr$(0)) If NullOffset% > 1 Then 'Set itmX = ListView1.ListItems.Add(, , Mid$(KeyList$, 1, NullOffset% - 1)) KeyValue$ = VBGetPrivateProfileString("UnimodemID.Scan", Mid$(KeyList$, 1, NullOffset% - 1), FileName$) 'itmX.SubItems(1) = KeyValue$ ' Add the response to the list Command(x) = KeyValue$ Set itmX = ListView1.ListItems.Add(, , KeyValue$) KeyList$ = Mid$(KeyList$, NullOffset% + 1) End If Loop While NullOffset% > 1 End Function Private Function Getline() Dim Instring As String ' Buffer to hold input string Dim itmX As ListItem Dim TextLine Open "TESTFILE.txt" For Input As #1 ' Open file. Do While Not EOF(1) ' Loop until end of file. Line Input #1, TextLine ' Read line into variable. Interval = False MSComm1.Output = TextLine + Chr$(13) ' Send the command to the modem. Do DoEvents Loop Until Interval = True ' Wait for data to come back to the serial port. Instring = MSComm1.Input ' Read the response data in the serial port. Set itmX = ListView1.ListItems.Add(, , TextLine) ' Add the command to the list itmX.SubItems(1) = Instring ' Add the response to the list Loop Close #1 ' Close file. End Function
MsgBox "Fuck You Github!"
' Last letter-first letter - VBScript - 11/03/2019 names = array( _ "audino", "bagon", "baltoy", "banette", _ "bidoof", "braviary", "bronzor", "carracosta", "charmeleon", _ "cresselia", "croagunk", "darmanitan", "deino", "emboar", _ "emolga", "exeggcute", "gabite", "girafarig", "gulpin", _ "haxorus", "heatmor", "heatran", "ivysaur", "jellicent", _ "jumpluff", "kangaskhan", "kricketune", "landorus", "ledyba", _ "loudred", "lumineon", "lunatone", "machamp", "magnezone", _ "mamoswine", "nosepass", "petilil", "pidgeotto", "pikachu", _ "pinsir", "poliwrath", "poochyena", "porygon2", "porygonz", _ "registeel", "relicanth", "remoraid", "rufflet", "sableye", _ "scolipede", "scrafty", "seaking", "sealeo", "silcoon", _ "simisear", "snivy", "snorlax", "spoink", "starly", "tirtouga", _ "trapinch", "treecko", "tyrogue", "vigoroth", "vulpix", _ "wailord", "wartortle", "whismur", "wingull", "yamask") maxPathLength = 0 maxPathLengthCount = 0 maxPathExample = "" t1=timer For i = 0 To ubound(names) 'swap names(0), names(i) temp=names(0): names(0)=names(i): names(i)=temp Call lastfirst(names, 1) 'swap names(0), names(i) temp=names(0): names(0)=names(i): names(i)=temp Next 'i buf = buf & "Maximum length = " & maxPathLength & vbCrLf buf = buf & "Number of solutions with that length = " & maxPathLengthCount & vbCrLf buf = buf & "One such solution: " & vbCrLf & maxPathExample & vbCrLf t2=timer MsgBox buf,,"Last letter-first letter - " & Int(t2-t1) & " sec" Sub lastfirst(names, offset) dim i, l If offset > maxPathLength Then maxPathLength = offset maxPathLengthCount = 1 ElseIf offset = maxPathLength Then maxPathLengthCount = maxPathLengthCount + 1 maxPathExample = "" For i = 0 To offset-1 maxPathExample = maxPathExample & names(i) & vbCrLf Next 'i End If l = Right(names(offset - 1),1) For i = offset To ubound(names) If Left(names(i),1) = l Then 'swap names(i), names(offset) temp=names(offset): names(offset)=names(i): names(i)=temp Call lastfirst(names, offset+1) 'swap names(i), names(offset) temp=names(offset): names(offset)=names(i): names(i)=temp End If Next 'i End Sub 'lastfirst
Dim objHCUpdate Dim objArgs set objHCUpdate = wscript.CreateObject("hcu.PCHUpdate") set objArgs = Wscript.Arguments objHCUpdate.UpdatePkg objArgs(0), false
Function binary_search(arr,value,lo,hi) If hi < lo Then binary_search = 0 Else middle=Int((hi+lo)/2) If value < arr(middle) Then binary_search = binary_search(arr,value,lo,middle-1) ElseIf value > arr(middle) Then binary_search = binary_search(arr,value,middle+1,hi) Else binary_search = middle Exit Function End If End If End Function 'Tesing the function. num_range = Array(2,3,5,6,8,10,11,15,19,20) n = CInt(WScript.Arguments(0)) idx = binary_search(num_range,n,LBound(num_range),UBound(num_range)) If idx > 0 Then WScript.StdOut.Write n & " found at index " & idx WScript.StdOut.WriteLine Else WScript.StdOut.Write n & " not found" WScript.StdOut.WriteLine End If
<filename>admin/wmi/wbem/scripting/test/vb/smserr/form1.frm VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 'Windows Default End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Private Sub Form_Load() Dim l As New SWbemLocator Dim s As SWbemServices Dim i As SWbemObject Set s = l.ConnectServer("wessms1", "root\sms\site_wn1", "smsadmin", "Elvis1") 'Stop On Error Resume Next Set i = s.Get("nonexistantobject") If Err.Number <> 0 Then On Error Resume Next Dim e As SWbemLastError Set e = CreateObject("WbemScripting.SWbemLastError") Debug.Print e.GetObjectText_ End If End Sub
VERSION 5.00 Begin VB.Form ConnectDialog Caption = "Connect To A Fax Server" ClientHeight = 1815 ClientLeft = 60 ClientTop = 345 ClientWidth = 6780 BeginProperty Font Name = "<NAME>" Size = 12 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Icon = "connect.frx":0000 LinkTopic = "Form1" ScaleHeight = 1815 ScaleWidth = 6780 StartUpPosition = 1 'CenterOwner Begin VB.CommandButton CancelButton Caption = "Cancel" Height = 495 Left = 4283 TabIndex = 3 Top = 1200 Width = 1455 End Begin VB.CommandButton OkButton Caption = "Ok" Default = -1 'True Height = 495 Left = 1080 TabIndex = 2 Top = 1200 Width = 1455 End Begin VB.TextBox ServerName BackColor = &H8000000F& Height = 495 Left = 2400 TabIndex = 1 Top = 120 Width = 4215 End Begin VB.Label Label1 Caption = "Fax Server Name:" Height = 375 Left = 120 TabIndex = 0 Top = 240 Width = 2175 End End Attribute VB_Name = "ConnectDialog" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub CancelButton_Click() Unload ConnectDialog End Sub Private Sub Form_Load() ServerName.Text = GetSetting("Fax", "FaxTest", "ServerName", "") ServerName.SelStart = 0 ServerName.SelLength = Len(ServerName.Text) End Sub Private Sub Form_Unload(Cancel As Integer) SaveSetting "Fax", "FaxTest", "Servername", ServerName.Text End Sub Private Sub OkButton_Click() On Error Resume Next If ServerName.Text = "" Then msg = "You must specify a fax server name" MsgBox msg, , "Error" ServerName.SetFocus Exit Sub End If ServerName.Text = LCase(ServerName.Text) Err.Clear Fax.Connect (ServerName.Text) If Err.Number = 0 Then Connected = True Unload ConnectDialog Exit Sub Else msg = "The fax server you specified is not available" MsgBox msg, , "Error" Err.Clear End If ServerName.SetFocus End Sub
<gh_stars>1-10 dim i, j j = 0 do for i = 1 to 100 while j < i if i = 3 then wscript.quit end if wend next loop
<filename>Task/Averages-Root-mean-square/VBA/averages-root-mean-square-2.vba<gh_stars>1-10 Function rms(iLow As Integer, iHigh As Integer) Dim i As Integer If iLow > iHigh Then i = iLow iLow = iHigh iHigh = i End If For i = iLow To iHigh rms = rms + i ^ 2 Next i rms = Sqr(rms / (iHigh - iLow + 1)) End Function Sub foo() Debug.Print rms(1, 10) End Sub
Function sum_of_squares(arr) If UBound(arr) = -1 Then sum_of_squares = 0 End If For i = 0 To UBound(arr) sum_of_squares = sum_of_squares + (arr(i)^2) Next End Function WScript.StdOut.WriteLine sum_of_squares(Array(1,2,3,4,5)) WScript.StdOut.WriteLine sum_of_squares(Array())
' This is a VBA comment
<filename>base/ntsetup/opktools/winpeoc/imgbld/buildado.vbs OPTION EXPLICIT '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '-----Windows Script Host script to generate components needed to run ADO '-----under Windows PE. '-----Copyright 2001, Microsoft Corporation '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '-----DIM, DEFINE VARIABLES, SET SOME GLOBAL OBJECTS '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' DIM strCmdArg, strCmdSwitch, arg, strCmdArray, CDDriveCollection, CDDrive, CDSource, FSO, Folder, HDDColl DIM HDD, FirstHDD, strAppend, WSHShell, strDesktop, strOptDest, strDestFolder DIM FILE, strCMDExpand, strCMDMid, strJobTitle, strNeedCD, iAmPlatform, iArchDir DIM iAmQuiet,iHaveSource, iHaveDest, iWillBrowse, WshSysEnv, strOSVer, strWantToView, strFolderName, intOneMore DIM strCMDado, strCMDmsadc, strCMDOle_db, strIDir, strSysDir Const ForAppending = 8 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '-----OFFER/TAKE CMDLINE PARAMETERS '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' If WScript.Arguments.Count <> 0 Then For each arg in WScript.Arguments strCmdArg = (arg) strCmdArray = Split(strCmdArg, ":", 2, 1) IF lcase(strCmdArray(0)) = "/s" or lcase(strCmdArray(0)) = "-s" THEN iHaveSource = 1 CDSource = TRIM(strCmdArray(1)) END IF IF lcase(strCmdArray(0)) = "/d" or lcase(strCmdArray(0)) = "-d" THEN iHaveDest = 1 strOptDest = TRIM(strCmdArray(1)) END IF IF lcase(strCmdArray(0)) = "/?" OR lcase(strCmdArray(0)) = "-?" THEN MsgBox "The following command-line arguments are accepted by this script:"&vbCRLF&vbCRLF&_ """/s:filepath"" - alternate source location other than the CD-ROM drive."&vbCRLF&vbCRLF&"Examples:"&vbCRLF&_ "/S:C:\"&vbCRLF&_ "-s:Z:\"&vbCRLF&_ "or"&vbCRLF&_ "-S:\\Myserver\Myshare"&vbCRLF&vbCRLF&_ "The script will still attempt to verify the presence of Windows XP files."&vbCrLF&vbCrLF&_ "/D - Destination. Opposite of CD - specifies build destination. Otherwise placed on desktop."&vbCRLF&vbCRLF&_ "/64 - build for Itanium. Generates scripts for Windows on the Itanium Processor Family."&vbCRLF&vbCRLF&_ "/Q - run without any dialog. This will not confirm success, will notify on failure."&vbCRLF&vbCRLF&_ "/E - explore completed files. Navigate to the created files when completed.", vbInformation, "Command-line arguments" WScript.Quit END IF IF lcase(strCmdArray(0)) = "/64" OR lcase(strCmdArray(0)) = "-64" THEN iAmPlatform = "Itanium" END IF IF lcase(strCmdArray(0)) = "/q" OR lcase(strCmdArray(0)) = "-q" THEN iAmQuiet = 1 END IF IF lcase(strCmdArray(0)) = "/e" OR lcase(strCmdArray(0)) = "-e" THEN iWillBrowse = 1 END IF Next ELSE iHaveSource = 0 END IF IF strOptDest = "" THEN iHaveDest = 0 ELSEIF INSTR(UCASE(strOptDest), "I386\") <> 0 OR INSTR(UCASE(strOptDest), "IA64\") <> 0 OR INSTR(UCASE(strOptDest), "SYSTEM32") <> 0 THEN MsgBox "The destination path needs to be the root of your newly created WinPE install - remove any extraneous path information, such as ""I386"" or ""System32""", vbCritical, "Destination Path Incorrect" WScript.Quit END IF IF iAmQuiet <> 1 THEN iAmQuiet = 0 END IF IF iAmPlatform <> "Itanium" THEN iAmPlatform = "x86" END IF IF Right(strOptDest, 1) = "\" THEN strOptDest = Left(strOptDest, LEN(strOptDest)-1) END IF IF Right(CDSource, 1) = "\" THEN CDSource = Left(CDSource, LEN(CDSource)-1) END IF IF iAmPlatform = "Itanium" THEN iArchDir = "ia64" ELSEIF iAmPlatform = "x86" THEN iArchDir = "i386" END IF strJobTitle = "ADO Component Generation" SET WshShell = WScript.CreateObject("WScript.Shell") SET WshSysEnv = WshShell.Environment("SYSTEM") SET FSO = CreateObject("Scripting.FileSystemObject") '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '-----ERROR OUT IF NOT RUNNING ON Windows 2000 OR HIGHER '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' strOSVer = WshSysEnv("OS") IF strOSVer <> "Windows_NT" THEN MsgBox "This script must be run on Windows 2000 or Windows XP", vbCritical, "Incorrect Windows Version" WScript.Quit END IF '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '-----GENERATE COLLECTION OF CD-ROM DRIVES VIA WMI. PICK FIRST AVAILABLE '-----ERROR OUT IF NO DRIVES FOUND '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' IF iHaveSource = 0 THEN SET CDDriveCollection = GetObject("winmgmts:").ExecQuery("SELECT * FROM Win32_CDROMDrive") IF CDDriveCollection.Count <= 0 THEN MsgBox "No CD-ROM drives found. Exiting Script.", vbCritical, "No CD-ROM drive found" WScript.Quit END IF FOR EACH CDDrive IN CDDriveCollection CDSource = CDDrive.Drive(0) EXIT FOR NEXT END IF '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '-----PROMPT FOR WINDOWS CD - QUIT IF CANCELLED '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' IF iAmQuiet = 0 THEN strNeedCD = MsgBox("This script will place a folder on your desktop containing all necessary files needed to "&_ "install ADO (ActiveX Data Objects) support under Windows PE."&vbCrLF&vbCrLF&"Please ensure that your "&_ "Windows XP Professional CD or Windows XP Professional binaries are available now on: "&vbCrLF&CDSource&vbCrLF&vbCrLF&"This script is only designed to be used with Windows PE/Windows XP RC1 "&_ "or newer.", 65, strJobTitle) END IF IF strNeedCD = 2 THEN WScript.Quit END IF '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '-----TEST VIA WMI TO INSURE MEDIA IS PRESENT AND READABLE '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' IF iHaveSource = 0 THEN TestForMedia() END IF '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '-----TESTS FOR EXISTANCE OF SEVERAL KEY FILES, AND A FILE COUNT IN I386 or IA64 TO INSURE '-----WINDOWS XP PRO MEDIA '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Validate(iArchDir) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '-----FIND THE USER'S DESKTOP. PUT NEW FOLDER THERE. APPEND TIMESTAMP IF THE FOLDER '-----ALREADY EXISTS. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' strDesktop = WshShell.SpecialFolders("Desktop") strFolderName = "ADO Build Files ("&iArchDir&")" IF iHaveDest = 0 THEN strDestFolder = strDesktop&"\"&strFolderName IF FSO.FolderExists(strDestFolder) THEN GetUnique() strDestFolder = strDestFolder&strAppend strFolderName = strFolderName&strAppend END IF FSO.CreateFolder(strDestFolder) ELSE strDestFolder = strOptDest IF NOT FSO.FolderExists(strDestFolder) THEN FSO.CreateFolder(strDestFolder) END IF END IF IF iHaveDest = 1 THEN strIDir = strDestFolder&"\"&iArchDir strSysDir = strDestFolder&"\"&iArchDir&"\System32" FSO.CreateFolder(strDestFolder&"\Program Files") FSO.CreateFolder(strDestFolder&"\Program Files\Common Files") FSO.CreateFolder(strDestFolder&"\Program Files\Common Files\System") FSO.CreateFolder(strDestFolder&"\Program Files\Common Files\System\ado") FSO.CreateFolder(strDestFolder&"\Program Files\Common Files\System\msadc") FSO.CreateFolder(strDestFolder&"\Program Files\Common Files\System\Ole db") FSO.CreateFolder(strIDir&"\Registration") strCMDado = """ """&strDestFolder&"\Program Files\Common Files\System\ado\" strCMDmsadc = """ """&strDestFolder&"\Program Files\Common Files\System\msadc\" strCMDOle_db = """ """&strDestFolder&"\Program Files\Common Files\System\Ole db\" strDestFolder = strSysDir IF FSO.FileExists(strDestFolder&"\autoexec.cmd") THEN SET FILE = FSO.OpenTextFile(strDestFolder&"\autoexec.cmd", ForAppending, true) FILE.WriteLine("call ADO.bat") FILE.Close() END IF ELSE FSO.CreateFolder(strDestFolder&"\Program Files") FSO.CreateFolder(strDestFolder&"\Program Files\Common Files") FSO.CreateFolder(strDestFolder&"\Program Files\Common Files\System") FSO.CreateFolder(strDestFolder&"\Program Files\Common Files\System\ado") FSO.CreateFolder(strDestFolder&"\Program Files\Common Files\System\msadc") FSO.CreateFolder(strDestFolder&"\Program Files\Common Files\System\Ole db") FSO.CreateFolder(strDestFolder&"\Registration") strCMDado = """ """&strDestFolder&"\Program Files\Common Files\System\ado\" strCMDmsadc = """ """&strDestFolder&"\Program Files\Common Files\System\msadc\" strCMDOle_db = """ """&strDestFolder&"\Program Files\Common Files\System\Ole db\" END IF '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '-----SET COMMON VARIABLES SO THE STRINGS AREN'T SO LARGE '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' strCMDExpand = "EXPAND """&CDSource&"\"&iArchDir&"\" strCMDMid = """ """&strDestFolder&"\" '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '-----SHELL OUT THE EXPANSION OF core ADO Files. (EXE, TLB, DLL, OCX) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' WshShell.Run strCMDExpand&"msado20.tl_"&strCMDado&"msado20.tlb""", 0, FALSE WshShell.Run strCMDExpand&"msado21.tl_"&strCMDado&"msado21.tlb""", 0, FALSE WshShell.Run strCMDExpand&"msado25.tl_"&strCMDado&"msado25.tlb""", 0, FALSE WshShell.Run strCMDExpand&"msjro.dl_"&strCMDado&"msjro.dll""", 0, FALSE WshShell.Run strCMDExpand&"msado26.tl_"&strCMDado&"msado26.tlb""", 0, FALSE WshShell.Run strCMDExpand&"msader15.dl_"&strCMDado&"msader15.dll""", 0, FALSE WshShell.Run strCMDExpand&"msado15.dl_"&strCMDado&"msado15.dll""", 0, FALSE WshShell.Run strCMDExpand&"msadomd.dl_"&strCMDado&"msadomd.dll""", 0, FALSE WshShell.Run strCMDExpand&"msador15.dl_"&strCMDado&"msador15.dll""", 0, FALSE WshShell.Run strCMDExpand&"msadoX.dl_"&strCMDado&"msadoX.dll""", 0, FALSE WshShell.Run strCMDExpand&"msadrh15.dl_"&strCMDado&"msadrh15.dll""", 0, FALSE WshShell.Run strCMDExpand&"msadce.dl_"&strCMDmsadc&"msadce.dll""", 0, FALSE WshShell.Run strCMDExpand&"msadcer.dl_"&strCMDmsadc&"msadcer.dll""", 0, FALSE WshShell.Run strCMDExpand&"msadcf.dl_"&strCMDmsadc&"msadcf.dll""", 0, FALSE WshShell.Run strCMDExpand&"msadcfr.dl_"&strCMDmsadc&"msadcfr.dll""", 0, FALSE WshShell.Run strCMDExpand&"msadco.dl_"&strCMDmsadc&"msadco.dll""", 0, FALSE WshShell.Run strCMDExpand&"msadcor.dl_"&strCMDmsadc&"msadcor.dll""", 0, FALSE WshShell.Run strCMDExpand&"msadcs.dl_"&strCMDmsadc&"msadcs.dll""", 0, FALSE WshShell.Run strCMDExpand&"msadds.dl_"&strCMDmsadc&"msadds.dll""", 0, FALSE WshShell.Run strCMDExpand&"msaddsr.dl_"&strCMDmsadc&"msaddsr.dll""", 0, FALSE WshShell.Run strCMDExpand&"msdarem.dl_"&strCMDmsadc&"msdarem.dll""", 0, FALSE WshShell.Run strCMDExpand&"msdaremr.dl_"&strCMDmsadc&"msdaremr.dll""", 0, FALSE WshShell.Run strCMDExpand&"msdfmap.dl_"&strCMDmsadc&"msdfmap.dll""", 0, FALSE WshShell.Run strCMDExpand&"sqloledb.rl_"&strCMDOle_db&"sqloledb.rll""", 0, FALSE WshShell.Run strCMDExpand&"sqlxmlx.rl_"&strCMDOle_db&"sqlxmlx.rll""", 0, FALSE WshShell.Run strCMDExpand&"msdadc.dl_"&strCMDOle_db&"msdadc.dll""", 0, FALSE WshShell.Run strCMDExpand&"msdaenum.dl_"&strCMDOle_db&"msdaenum.dll""", 0, FALSE WshShell.Run strCMDExpand&"msdaer.dl_"&strCMDOle_db&"msdaer.dll""", 0, FALSE WshShell.Run strCMDExpand&"msdaora.dl_"&strCMDOle_db&"msdaora.dll""", 0, FALSE WshShell.Run strCMDExpand&"msdaorar.dl_"&strCMDOle_db&"msdaorar.dll""", 0, FALSE WshShell.Run strCMDExpand&"msdaosp.dl_"&strCMDOle_db&"msdaosp.dll""", 0, FALSE WshShell.Run strCMDExpand&"msdasc.dl_"&strCMDOle_db&"msdasc.dll""", 0, FALSE WshShell.Run strCMDExpand&"msdasql.dl_"&strCMDOle_db&"msdasql.dll""", 0, FALSE WshShell.Run strCMDExpand&"msdasqlr.dl_"&strCMDOle_db&"msdasqlr.dll""", 0, FALSE WshShell.Run strCMDExpand&"msdatl3.dl_"&strCMDOle_db&"msdatl3.dll""", 0, FALSE WshShell.Run strCMDExpand&"msdatt.dl_"&strCMDOle_db&"msdatt.dll""", 0, FALSE WshShell.Run strCMDExpand&"msdaurl.dl_"&strCMDOle_db&"msdaurl.dll""", 0, FALSE WshShell.Run strCMDExpand&"msxactps.dl_"&strCMDOle_db&"msxactps.dll""", 0, FALSE WshShell.Run strCMDExpand&"oledb32.dl_"&strCMDOle_db&"oledb32.dll""", 0, FALSE WshShell.Run strCMDExpand&"oledb32r.dl_"&strCMDOle_db&"oledb32r.dll""", 0, FALSE WshShell.Run strCMDExpand&"sqloledb.dl_"&strCMDOle_db&"sqloledb.dll""", 0, FALSE WshShell.Run strCMDExpand&"sqlxmlx.dl_"&strCMDOle_db&"sqlxmlx.dll""", 0, FALSE WshShell.Run strCMDExpand&"msdatsrc.tl_"&strCMDMid&"msdatsrc.tlb""", 0, FALSE WshShell.Run strCMDExpand&"cliconfg.ex_"&strCMDMid&"cliconfg.exe""", 0, FALSE WshShell.Run strCMDExpand&"cliconfg.rl_"&strCMDMid&"cliconfg.rll""", 0, FALSE WshShell.Run strCMDExpand&"sqlsrv32.rl_"&strCMDMid&"sqlsrv32.rll""", 0, FALSE WshShell.Run strCMDExpand&"cliconfg.dl_"&strCMDMid&"cliconfg.dll""", 0, FALSE WshShell.Run strCMDExpand&"dbmsadsn.dl_"&strCMDMid&"dbmsadsn.dll""", 0, FALSE WshShell.Run strCMDExpand&"dbmsrpcn.dl_"&strCMDMid&"dbmsrpcn.dll""", 0, FALSE WshShell.Run strCMDExpand&"dbnetlib.dl_"&strCMDMid&"dbnetlib.dll""", 0, FALSE WshShell.Run strCMDExpand&"dbnmpntw.dl_"&strCMDMid&"dbnmpntw.dll""", 0, FALSE WshShell.Run strCMDExpand&"ds32gt.dl_"&strCMDMid&"ds32gt.dll""", 0, FALSE WshShell.Run strCMDExpand&"mscpx32r.dl_"&strCMDMid&"mscpx32r.dll""", 0, FALSE WshShell.Run strCMDExpand&"mscpxl32.dl_"&strCMDMid&"mscpxl32.dll""", 0, FALSE WshShell.Run strCMDExpand&"msdart.dl_"&strCMDMid&"msdart.dll""", 0, FALSE WshShell.Run strCMDExpand&"msorc32r.dl_"&strCMDMid&"msorc32r.dll""", 0, FALSE WshShell.Run strCMDExpand&"msorcl32.dl_"&strCMDMid&"msorcl32.dll""", 0, FALSE WshShell.Run strCMDExpand&"odbcbcp.dl_"&strCMDMid&"odbcbcp.dll""", 0, FALSE WshShell.Run strCMDExpand&"sqlsrv32.dl_"&strCMDMid&"sqlsrv32.dll""", 0, FALSE WshShell.Run strCMDExpand&"sqlunirl.dl_"&strCMDMid&"sqlunirl.dll""", 0, FALSE WshShell.Run strCMDExpand&"12520437.cp_"&strCMDMid&"12520437.cpx""", 0, FALSE WshShell.Run strCMDExpand&"12520850.cp_"&strCMDMid&"12520850.cpx""", 0, FALSE WshShell.Run strCMDExpand&"ds16gt.dl_"&strCMDMid&"ds16gt.dll""", 0, FALSE WshShell.Run strCMDExpand&"instcat.sq_"&strCMDMid&"instcat.sql""", 0, FALSE WshShell.Run strCMDExpand&"expsrv.dl_"&strCMDMid&"expsrv.dll""", 0, FALSE WshShell.Run strCMDExpand&"vbajet32.dl_"&strCMDMid&"vbajet32.dll""", 0, FALSE WshShell.Run strCMDExpand&"CLBCATQ.DL_"&strCMDMid&"CLBCATQ.DLL""", 0, FALSE WshShell.Run strCMDExpand&"colbact.DL_"&strCMDMid&"colbact.DLL""", 0, FALSE WshShell.Run strCMDExpand&"COMRes.dl_"&strCMDMid&"COMRes.dll""", 0, FALSE WshShell.Run strCMDExpand&"comsvcs.dl_"&strCMDMid&"comsvcs.dll""", 0, FALSE WshShell.Run strCMDExpand&"DBmsLPCn.dl_"&strCMDMid&"DBmsLPCn.dll""", 0, FALSE WshShell.Run strCMDExpand&"MSCTF.dl_"&strCMDMid&"MSCTF.dll""", 0, FALSE WshShell.Run strCMDExpand&"mslbui.dl_"&strCMDMid&"mslbui.dll""", 0, FALSE WshShell.Run strCMDExpand&"MTXCLU.DL_"&strCMDMid&"MTXCLU.DLL""", 0, FALSE WshShell.Run strCMDExpand&"RESUTILS.DL_"&strCMDMid&"RESUTILS.DLL""", 0, FALSE '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '-----CREATE THE SAMPLE ADO/WSH SCRIPT . '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' SET FILE = fso.CreateTextFile(strDestFolder&"\testado.vbs", True) FILE.WriteLine ("set objDBConnection = Wscript.CreateObject(""ADODB.Connection"")") FILE.WriteLine ("set RS = Wscript.CreateObject(""ADODB.Recordset"")") FILE.WriteLine ("") FILE.WriteLine ("SERVER = InputBox(""Enter the name of the SQL Server (SQL 7.0 or SQL 2000) you wish to connect to""&vbcrlf&vbcrlf&""This SQL Server must have the Northwind sample database installed."", ""Connect to SQL Server..."")") FILE.WriteLine ("IF LEN(TRIM(SERVER)) = 0 THEN") FILE.WriteLine (" MsgBox ""You did not enter the name of a machine to query. Exiting script."", vbCritical, ""No machine requested.""") FILE.WriteLine (" WScript.Quit") FILE.WriteLine ("END IF") FILE.WriteLine ("") FILE.WriteLine ("USERNAME = InputBox(""Enter the name of the SQL Server username to query with"", ""Enter SQL username..."")") FILE.WriteLine ("IF LEN(TRIM(USERNAME)) = 0 THEN") FILE.WriteLine (" MsgBox ""You did not enter the SQL Server username to query with. Exiting script."", vbCritical, ""No username specified.""") FILE.WriteLine (" WScript.Quit") FILE.WriteLine ("END IF") FILE.WriteLine ("") FILE.WriteLine ("PWD = InputBox(""Enter the password of the SQL Server you wish to connect to""&vbcrlf&vbcrlf&""Leave blank if no password is needed."", ""Enter SQL password..."")") FILE.WriteLine ("") FILE.WriteLine ("") FILE.WriteLine ("SQLQuery1 =""SELECT Employees.FirstName AS FirstName, Employees.City AS City FROM Employees WHERE Employees.Lastname = 'Suyama'""") FILE.WriteLine ("objDBConnection.open ""Provider=SQLOLEDB;Data Source=""&SERVER&"";Initial Catalog=Northwind;User ID=""&USERNAME&"";Password=""<PASSWORD>&"";""") FILE.WriteLine ("") FILE.WriteLine ("Set GetRS = objDBConnection.Execute(SQLQuery1)") FILE.WriteLine ("") FILE.WriteLine ("IF GetRS.EOF THEN") FILE.WriteLine (" MsgBox ""No employees were found with the last name you searched on!""") FILE.WriteLine ("ELSE") FILE.WriteLine (" Do While Not GetRS.EOF") FILE.WriteLine (" MsgBox ""There is an employee in ""&GetRS(""City"")&"" named ""&GetRS(""FirstName"")&"" with the last name you searched on.""") FILE.WriteLine (" GetRS.MoveNext") FILE.WriteLine (" Loop") FILE.WriteLine ("END IF") FILE.Close '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '-----CREATE the BATS THAT WILL INSTALL THE ADO ENVIRONMENT. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' SET FILE = fso.CreateTextFile(strDestFolder&"\ADO.bat", True) FILE.WriteLine ("@ECHO OFF") FILE.WriteLine ("START ""Installing ADO"" /MIN ADO2.bat") FILE.Close SET FILE = fso.CreateTextFile(strDestFolder&"\ADO2.bat", True) FILE.WriteLine ("") FILE.WriteLine ("REM - INSTALL ADO COMPONENTS") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\msadc\msadce.dll"" /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\msadc\msadcf.dll"" /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\msadc\msadco.dll"" /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\msadc\msadds.dll"" /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\ado\msado15.dll"" /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\ado\msadomd.dll"" /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\ado\msador15.dll"" /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\ado\msadoX.dll"" /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\ado\msadrh15.dll"" /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\msdadc.dll"" /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\msdaenum.dll"" /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\msdaer.dll"" /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\msdaora.dll"" /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\msdaosp.dll"" /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\msadc\msdarem.dll"" /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\msdasc.dll"" /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\msdasql.dll"" /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\msdatt.dll"" /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\msdaurl.dll"" /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\msadc\msdfmap.dll"" /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\ado\msjro.dll"" /S") FILE.WriteLine ("regsvr32 %SystemRoot%\System32\msorcl32.dll /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\msxactps.dll"" /S") FILE.WriteLine ("regsvr32 %SystemRoot%\System32\odbcconf.dll /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\oledb32.dll"" /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\oledb32r.dll"" /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\sqloledb.dll"" /S") FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\sqlxmlx.dll"" /S") FILE.WriteLine ("regsvr32 %SystemRoot%\System32\CLBCATQ.DLL /S") FILE.WriteLine ("regsvr32 %SystemRoot%\system32\colbact.DLL /S") FILE.WriteLine ("regsvr32 %SystemRoot%\system32\comsvcs.dll /S") FILE.WriteLine ("regsvr32 %SystemRoot%\System32\MSCTF.dll /S") FILE.WriteLine ("regsvr32 %SystemRoot%\System32\mslbui.dll /S") FILE.WriteLine ("regsvr32 %SystemRoot%\system32\ole32.dll /S") FILE.WriteLine ("EXIT") FILE.Close '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '-----FILES READY - ASK IF THE USER WANTS TO EXPLORE TO THEM. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' IF iAmQuiet = 0 THEN strWantToView = MsgBox("This script has successfully retrieved all necessary files needed to "&_ "install ADO on Windows PE. The files have been placed on your desktop in a directory named """&strFolderName&"""."&vbCrLF&vbCrLF&_ "In order to install the ADO components within Windows PE, place the contents of this folder (not the folder itself) into the I386\System32 or IA64\System32 directory "&_ "of your Windows PE CD, Hard drive install, or RIS Server installation, and modify your startnet.cmd to run the file ""ADO.bat"" (without quotes)."&vbCrLF&vbCrLF&_ "A sample script named test.vbs that you can use to verify installation has been provided as well. You can remove this for your production version of Windows PE."&vbCrLF&vbCrLF&_ "Would you like to open this folder now?", 36, strJobTitle) END IF IF strWantToView = 6 OR iWillBrowse = 1 THEN WshShell.Run("Explorer "&strDestFolder) END IF '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '-----WMI TEST OF CD LOADED AND CD READ INTEGRITY. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' SUB TestForMedia() IF CDDrive.MediaLoaded(0) = FALSE THEN MsgBox "Please place the Windows XP Professional CD in drive "&CDSource&" before continuing.", vbCritical, "No CD in drive "&CDSource&"" WScript.Quit ELSE IF CDDrive.DriveIntegrity(0) = FALSE THEN MsgBox "Could not read files from the CD in drive "&CDSource&".", vbCritical, "CD in drive "&CDSource&" is unreadable." WScript.Quit END IF END IF END SUB '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '-----FSO TEST TO SEE IF THE CMDLINE PROVIDED FOLDER EXISTS. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' FUNCTION TestForFolder(a) IF NOT FSO.FolderExists(a) THEN FailOut() END IF END FUNCTION SUB Validate(a) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '-----TEST FOR THE EXISTANCE OF A FOLDER OR FILE, OR THE NONEXISTANCE OF A FILE. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' TestForFolder(CDSource&"\"&a&"") TestForFolder(CDSource&"\DOCS") TestForFolder(CDSource&"\SUPPORT") TestForFolder(CDSource&"\VALUEADD") TestForFile(CDSource&"\"&a&"\System32\smss.exe") TestForFile(CDSource&"\"&a&"\System32\ntdll.dll") TestForFile(CDSource&"\"&a&"\winnt32.exe") TestForFile(CDSource&"\setup.exe") TestForANDFile CDSource&"\WIN51.B2", CDSource&"\WIN51.RC1", CDSource&"\WIN51.RC1" TestForANDFile CDSource&"\WIN51IP.B2", CDSource&"\WIN51IP.RC1", CDSource&"\WIN51MP.RC1" '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '-----TEST TO INSURE THAT THEY AREN'T TRYING TO INSTALL FROM Windows PE CD ITSELF '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Set Folder = FSO.GetFolder(CDSource&"\"&a&"\System32") IF Folder.Files.Count > 10 THEN FailOut() END IF END SUB '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '-----TEST FOR THE EXISTANCE OF A FOLDER OR FILE, OR THE NONEXISTANCE OF A FILE. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' FUNCTION TestForFolder(a) IF NOT FSO.FolderExists(a) THEN FailOut() END IF END FUNCTION FUNCTION TestForFile(a) IF NOT FSO.FileExists(a) THEN FailOut() END IF END FUNCTION FUNCTION TestForANDFile(a,b,c) IF NOT FSO.FileExists(a) AND NOT FSO.FileExists(b) AND NOT FSO.FileExists(c) THEN FailOut() END IF END FUNCTION FUNCTION TestNoFile(a) IF FSO.FileExists(a) THEN FailOut() END IF END FUNCTION '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '-----GENERIC ERROR IF WE FAIL MEDIA RECOGNITION. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' SUB FailOut() MsgBox"The CD in drive "&CDSource&" does not appear to be a valid Windows XP Professional CD.", vbCritical, "Invalid CD in Drive "&CDSource WScript.Quit END SUB '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '-----ADD DATE, AND ADD ZEROS SO WE DON'T HAVE A GIBBERISH TIMESTAMP ON UNIQUE FOLDERNAME. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' SUB GetUnique() strAppend=FixUp(Hour(Now()))&FixUp(Minute(Now()))&FixUp(Second(Now())) IF Len(strAppend) = 5 THEN strAppend = strAppend&"0" ELSEIF Len(strAppend) = 4 THEN strAppend = strAppend&"00" END IF END SUB FUNCTION FixUp(a) If Len(a) = 1 THEN FixUp = 0&a ELSE Fixup = a END IF END FUNCTION FUNCTION CleanLocation(a) CleanLocation = REPLACE(a, """", "") END FUNCTION
<filename>Task/Binary-strings/VBA/binary-strings-8.vba Sub ExtractFromString() Dim A$, B As String A = "<NAME>" B = Mid(A, 3, 8) Debug.Print B 'return : llo worl End Sub
<gh_stars>10-100 '*************************************************************************** 'This script tests the manipulation of property values, in the case that the 'property is a not an array type '*************************************************************************** Set Service = GetObject("winmgmts:root/default") On Error Resume Next Set aClass = Service.Get() aClass.Path_.Class = "SIMPLEPROPTEST00" Set Property = aClass.Properties_.Add ("p1", 3) Property.Value = 12567 WScript.Echo "The initial value of p1 is [12567]:", aClass.Properties_("p1") '**************************************** 'First pass of tests works on non-dot API '**************************************** WScript.Echo "" WScript.Echo "PASS 1 - Use Non-Dot Notation" WScript.Echo "" 'Verify we can report the value of an element of the property value v = aClass.Properties_("p1") WScript.Echo "By indirection p1 has value [12567]:",v 'Verify we can report the value directly WScript.Echo "By direct access p1 has value [12567]:", aClass.Properties_("p1") 'Verify we can set the value of a single property value element aClass.Properties_("p1") = 234 WScript.Echo "After direct assignment p1 has value [234]:", aClass.Properties_("p1") '**************************************** 'Second pass of tests works on dot API '**************************************** WScript.Echo "" WScript.Echo "PASS 2 - Use Dot Notation" WScript.Echo "" 'Verify we can report the value of a property using the "dot" notation WScript.Echo "By direct access p1 has value [234]:", aClass.p1 'Verify we can report the value of a property using the "dot" notation v = aClass.p1 WScript.Echo "By indirect access p1 has value [234]:", v 'Verify we can set the value using dot notation aClass.p1 = -1 WScript.Echo "By direct access via the dot notation p1 has been set to [-1]:", aClass.p1 aClass.Put_ () if Err <> 0 Then WScript.Echo Err.Description Err.Clear End if
Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long Dim fullpath As String * 260, appname As String, namelen As Long namelen = GetModuleFileName (0, fullpath, 260) fullpath = Left$(fullpath, namelen) If InStr(fullpath, "\") Then appname = Mid$(fullpath, InStrRev(fullpath, "\") + 1) Else appname = fullpath End If
Function CountFactors(n) If n = 1 Then CountFactors = 1 Else arrP = Split(ListPrimes(n)," ") Set arrList = CreateObject("System.Collections.ArrayList") divnum = n Do Until divnum = 1 'The -1 is to account for the null element of arrP For i = 0 To UBound(arrP)-1 If divnum = 1 Then Exit For ElseIf divnum Mod arrP(i) = 0 Then divnum = divnum/arrP(i) arrList.Add arrP(i) End If Next Loop arrList.Sort For i = 0 To arrList.Count - 1 If i = arrList.Count - 1 Then CountFactors = CountFactors & arrList(i) Else CountFactors = CountFactors & arrList(i) & " * " End If Next End If End Function Function IsPrime(n) If n = 2 Then IsPrime = True ElseIf n <= 1 Or n Mod 2 = 0 Then IsPrime = False Else IsPrime = True For i = 3 To Int(Sqr(n)) Step 2 If n Mod i = 0 Then IsPrime = False Exit For End If Next End If End Function Function ListPrimes(n) ListPrimes = "" For i = 1 To n If IsPrime(i) Then ListPrimes = ListPrimes & i & " " End If Next End Function 'Testing the fucntions. WScript.StdOut.Write "2 = " & CountFactors(2) WScript.StdOut.WriteLine WScript.StdOut.Write "2144 = " & CountFactors(2144) WScript.StdOut.WriteLine
<reponame>npocmaka/Windows-Server-2003<filename>admin/cmdline/scripts/pagefile.vbs '****************************************************************************** '* '* Copyright (c) Microsoft Corporation. All rights reserved. '* '* Module Name: PAGEFILECONFIG.vbs '* '* Abstract: Enables an administrator to display and configure '* a systems Virtual Memory paging file settings. '* '* '****************************************************************************** OPTION EXPLICIT ON ERROR RESUME NEXT Err.Clear '****************************************************************************** ' Start of Localization Content '****************************************************************************** ' Valid volume pattern [ a,b drives are invalid ] CONST L_VolumePatternFormat_Text = "^([b-zB-Z]:|\*)$" ' constants for showresults CONST L_Na_Text = "N/A" CONST L_MachineName_Text = "System Name" CONST L_User_Text = "User" CONST L_Password_Text = "Password" CONST L_Intsize_Text = "Initial Size" CONST L_Maxsize_Text = "Maximum Size" CONST L_Volume_Text = "Volume Name" CONST L_Format_Text = "Format" ' the column headers used in the output display CONST L_ColHeaderHostname_Text = "Host Name" CONST L_ColHeaderDrive_Text = "Drive/Volume" CONST L_ColHeaderVolumeLabel_Text = "Volume Label" CONST L_ColHeaderFileName_Text = "Location\File Name" CONST L_ColHeaderInitialSize_Text = "Initial Size" CONST L_ColHeaderMaximumSize_Text = "Maximum Size" CONST L_ColHeaderCurrentSize_Text = "Current Size" CONST L_ColHeaderPageFileStatus_Text = "Page File Mode" CONST L_ColHeaderFreeSpace_Text = "Total Free Space" CONST L_ColHeaderTotalMinimumSize_Text = "Total (All Drives): Minimum Size" CONST L_ColHeaderTotalRecommendedSize_Text = "Total (All Drives): Recommended Size" CONST L_ColHeaderTotalSize_Text = "Total (All Drives): Currently Allocated" ' Maximum Column Header Lengths used to display various fields. ' Localization team can adjust these columns to fit the localized strings. ' constants for data lengths for ShowResults (15,13,13,19,20,20,20,22) CONST L_CONST_HOSTNAME_Length_Text = 15 CONST L_CONST_DRIVENAME_Length_Text = 19 CONST L_CONST_VOLLABEL_Length_Text = 17 CONST L_CONST_PAGEFILENAME_Length_Text = 19 CONST L_CONST_INTSIZE_Length_Text = 20 CONST L_CONST_MAXSIZE_Length_Text = 20 CONST L_CONST_CURRENTSIZE_Length_Text = 20 CONST L_CONST_FREESPACE_Length_Text = 22 CONST L_ColHeaderPageFileStatusLength_Text = 20 ' constants for data lengths for ShowResults (15,33,37,40) CONST L_CONST_TOTALMINSIZE_Length_Text = 33 CONST L_CONST_TOTALRECSIZE_Length_Text = 37 CONST L_CONST_TOTALSIZE_Length_Text = 40 ' user reply for the warning messages CONST L_UserReplyYes_Text = "y" CONST L_UserReplyNo_Text = "n" 'Constants for indication of page file status CONST L_CONST_System_Managed_Text = "System Managed" CONST L_Custom_Text = "Custom" ' constants for CScript usage CONST L_UseCscript1_ErrorMessage = "This script should be executed from the command prompt using CSCRIPT.EXE." CONST L_UseCscript2_ErrorMessage = "For example: CSCRIPT %windir%\System32\PAGEFILECONFIG.vbs <arguments>" CONST L_UseCscript3_ErrorMessage = "To set CScript as the default application to run .vbs files, run the following:" CONST L_UseCscript4_ErrorMessage = " CSCRIPT //H:CSCRIPT //S" CONST L_UseCscript5_ErrorMessage = "You can then run ""%windir%\System32\PAGEFILECONFIG.vbs <arguments>"" without preceding the script with CSCRIPT." ' common constants for showing help for all the options CONST L_UsageDescription_Text = "Description:" CONST L_UsageParamList_Text = "Parameter List:" CONST L_UsageExamples_Text = "Examples:" CONST L_UsageMachineName_Text = " /S system Specifies the remote system to connect to." CONST L_UsageUserNameLine1_Text = " /U [domain\]user Specifies the user context under which" CONST L_UsageUserNameLine2_Text = " the command should execute." CONST L_UsagePasswordLine1_Text = " /P password Specifies the password for the given" CONST L_UsagePasswordLine2_Text = " user context." ' constants for showing help CONST L_ShowUsageLine02_Text = "PAGEFILECONFIG.vbs /parameter [arguments]" CONST L_ShowUsageLine05_Text = " Enables an administrator to display and configure a system's " CONST L_ShowUsageLine06_Text = " paging file Virtual Memory settings." CONST L_ShowUsageLine08_Text = "Parameter List:" CONST L_ShowUsageLine09_Text = " /Change Changes a system's existing paging file" CONST L_ShowUsageLine10_Text = " Virtual Memory settings." CONST L_ShowUsageLine12_Text = " /Create Creates/Adds an additional ""Paging File"" to a system." CONST L_ShowUsageLine14_Text = " /Delete Deletes a ""Paging File"" from a system." CONST L_ShowUsageLine16_Text = " /Query Displays a system's paging file" CONST L_ShowUsageLine17_Text = " Virtual Memory settings." CONST L_ShowUsageLine19_Text = "Examples:" CONST L_ShowUsageLine20_Text = " PAGEFILECONFIG.vbs" CONST L_ShowUsageLine21_Text = " PAGEFILECONFIG.vbs /?" CONST L_ShowUsageLine22_Text = " PAGEFILECONFIG.vbs /Change /?" CONST L_ShowUsageLine23_Text = " PAGEFILECONFIG.vbs /Create /?" CONST L_ShowUsageLine24_Text = " PAGEFILECONFIG.vbs /Delete /?" CONST L_ShowUsageLine25_Text = " PAGEFILECONFIG.vbs /Query /?" ' constants for showing help for /Change option CONST L_ShowChangeUsageLine02_Text = "PAGEFILECONFIG.vbs /Change [/S system [/U username [/P password]]]" CONST L_ShowChangeUsageLine03_Text = " { { [/I initialsize] [/M maximumsize] } | { /SYS } }" CONST L_ShowChangeUsageLine04_Text = " /VO volume1 [/VO volume2 [... [/VO volumeN]]]" CONST L_ShowChangeUsageLine07_Text = " Changes an existing paging file's Virtual Memory Settings." CONST L_ShowChangeUsageLine18_Text = " /I initialsize Specifies the new initial size (in MB)" CONST L_ShowChangeUsageLine19_Text = " to use for the paging file specified." CONST L_ShowChangeUsageLine21_Text = " /M maximumsize Specifies the new maximum size (in MB)" CONST L_ShowChangeUsageLine22_Text = " to use for the paging file specified." CONST L_ShowChangeUsageLine24_Text = " /SYS systemmanaged Specifies that the page file has to " CONST L_ShowChangeUsageLine25_Text = " be managed by the system." CONST L_ShowChangeUsageLine27_Text = " /VO volumeletter Specifies the local drive who's paging" CONST L_ShowChangeUsageLine28_Text = " file settings need to be changed. Specify" CONST L_ShowChangeUsageLine29_Text = " '*' to select all the local drives." CONST L_ShowChangeUsageLine30_Text = " Example: ""C:"" or ""*""" CONST L_ShowChangeUsageLine33_Text = " PAGEFILECONFIG.vbs /Change /?" CONST L_ShowChangeUsageLine34_Text = " PAGEFILECONFIG.vbs /Change /M 400 /VO c:" CONST L_ShowChangeUsageLine35_text = " PAGEFILECONFIG.vbs /Change /VO c: /SYS" CONST L_ShowChangeUsageLine36_Text = " PAGEFILECONFIG.vbs /Change /S system /U user /M 400 /VO c:" CONST L_ShowChangeUsageLine37_Text = " PAGEFILECONFIG.vbs /Change /S system /U user /I 20 /VO *" CONST L_ShowChangeUsageLine38_Text = " PAGEFILECONFIG.vbs /Change /S system /U user /P password /I 200" CONST L_ShowChangeUsageLine39_Text = " /M 500 /VO c: /VO d:" ' constants for showing help for /Create option CONST L_ShowCreateUsageLine02_Text = "PAGEFILECONFIG.vbs /Create [/S system [/U username [/P password]]]" CONST L_ShowCreateUsageLine03_Text = " { {/I initialsize /M maximumsize} | { /SYS } }" CONST L_ShowCreateUsageLine04_Text = " /VO volume1 [/VO volume2 [... [/VO volumeN]]]" CONST L_ShowCreateUsageLine07_Text = " Creates/Adds an additional ""Paging File"" to a system." CONST L_ShowCreateUsageLine18_Text = " /I initialsize Specifies the initial size (in MB) to use" CONST L_ShowCreateUsageLine19_Text = " for the paging file being created." CONST L_ShowCreateUsageLine21_Text = " /M maximumsize Specifies the maximum size (in MB) to use" CONST L_ShowCreateUsageLine22_Text = " for the paging file being created." CONST L_ShowCreateUsageLine24_Text = " /SYS systemmanaged Specifies that the page file has to " CONST L_ShowCreateUsageLine25_Text = " be managed by the system." CONST L_ShowCreateUsageLine27_Text = " /VO volumeletter Specifies the local drive on which the" CONST L_ShowCreateUsageLine28_Text = " paging file has to be created. Specify '*'" CONST L_ShowCreateUsageLine29_Text = " to select all the local drives." CONST L_ShowCreateUsageLine30_Text = " Example: ""C:"" or ""*""" CONST L_ShowCreateUsageLine33_Text = " PAGEFILECONFIG.vbs /Create /?" CONST L_ShowCreateUsageLine34_Text = " PAGEFILECONFIG.vbs /Create /I 140 /M 300 /VO d:" CONST L_ShowCreateUsageLine35_Text = " PAGEFILECONFIG.VBS /Create /VO c: /SYS" CONST L_ShowCreateUsageLine36_Text = " PAGEFILECONFIG.vbs /Create /S system /U user /I 150 /M 300 /VO d:" CONST L_ShowCreateUsageLine37_Text = " PAGEFILECONFIG.vbs /Create /S system /U user /I 50 /M 200 /VO *" CONST L_ShowCreateUsageLine38_Text = " PAGEFILECONFIG.vbs /Create /S system /U user /P password /I 100" CONST L_ShowCreateUsageLine39_Text = " /M 600 /VO d: /VO e: /VO f:" ' constants for showing help for /Delete option CONST L_ShowDeleteUsageLine02_Text = "PAGEFILECONFIG.vbs /Delete [/S system [/U username [/P password]]]" CONST L_ShowDeleteUsageLine03_Text = " /VO volume1 [/VO volume2 [... [/VO volumeN]]]" CONST L_ShowDeleteUsageLine06_Text = " Deletes paging file(s) from a system." CONST L_ShowDeleteUsageLine17_Text = " /VO volumeletter Specifies the local drive who's paging" CONST L_ShowDeleteUsageLine18_Text = " file has to be deleted." CONST L_ShowDeleteUsageLine19_Text = " Example: ""C:""" CONST L_ShowDeleteUsageLine22_Text = " PAGEFILECONFIG.vbs /Delete /?" CONST L_ShowDeleteUsageLine23_Text = " PAGEFILECONFIG.vbs /Delete /VO d:" CONST L_ShowDeleteUsageLine24_Text = " PAGEFILECONFIG.vbs /Delete /S system /U user /VO d: /VO e:" CONST L_ShowDeleteUsageLine25_Text = " PAGEFILECONFIG.vbs /Delete /S system /U user /P password /VO d:" ' constants for showing help for /Query option CONST L_ShowQueryUsageLine02_Text = "PAGEFILECONFIG.vbs /Query [/S system [/U username [/P password]]]" CONST L_ShowQueryUsageLine03_Text = " [/FO format] [/NH]" CONST L_ShowQueryUsageLine06_Text = " Displays a system's paging file Virtual Memory settings." CONST L_ShowQueryUsageLine17_Text = " /FO format Specifies the format in which the output" CONST L_ShowQueryUsageLine18_Text = " is to be displayed." CONST L_ShowQueryUsageLine19_Text = " Valid values: ""TABLE"", ""LIST"", ""CSV""." CONST L_ShowQueryUsageLine21_Text = " /NH Specifies that the ""Column Header"" should" CONST L_ShowQueryUsageLine22_Text = " not be displayed in the output." CONST L_ShowQueryUsageLine25_Text = " PAGEFILECONFIG.vbs" CONST L_ShowQueryUsageLine26_Text = " PAGEFILECONFIG.vbs /Query" CONST L_ShowQueryUsageLine27_Text = " PAGEFILECONFIG.vbs /Query /?" CONST L_ShowQueryUsageLine28_Text = " PAGEFILECONFIG.vbs /Query /FO table" CONST L_ShowQueryUsageLine29_Text = " PAGEFILECONFIG.vbs /Query /FO csv /NH" CONST L_ShowQueryUsageLine30_Text = " PAGEFILECONFIG.vbs /Query /S system /U user" CONST L_ShowQueryUsageLine31_Text = " PAGEFILECONFIG.vbs /Query /S system /U user /P password /FO LIST" ' constants for error messages CONST L_UnableToInclude_ErrorMessage = "ERROR: Unable to include the common module ""CmdLib.Wsc""." CONST L_InvalidHelpUsage_ErrorMessage = "ERROR: Invalid Help Usage. Use only /? for help." CONST L_InvalidParameter_ErrorMessage = "ERROR: Invalid argument/Option - '%1'." CONST L_InvalidInput_ErrorMessage = "ERROR: Invalid input. Please check the input values." CONST L_InvalidCredentials_ErrorMessage = "ERROR: Invalid credentials. Verify the machine, user and password given." CONST L_InvalidVolumeName_ErrorMessage = "ERROR: Invalid volume '%1' specified." CONST L_InvalidUserReply_ErrorMessage = "ERROR: Invalid choice. Enter a valid choice." CONST L_FailCreateObject_ErrorMessage = "ERROR: Unable to create object." CONST L_UnableToRetrieveInfo_ErrorMessage = "ERROR: Unable to retrieve information." CONST L_CannotCreate_ErrorMessage = "ERROR: Paging file for the specified volume '%1' cannot be created." CONST L_InvalidPhysicalDrive_ErrorMessage = "ERROR: Volume '%1' is not a valid physical drive." CONST L_UpdateFailed_ErrorMessage = "ERROR: Paging file update failed." CONST L_InvalidInitSizeValue_ErrorMessage = "ERROR: Enter a numeric value for the initial paging file size." CONST L_InvalidMaxSizeValue_ErrorMessage = "ERROR: Enter a numeric value for the maximum paging file size." CONST L_CONST_Systemmanaged_Earlier_Text = "ERROR: The page file on drive %1 is system managed. Both initial and maximum size must be specified." ' constant for hint message to show remote connectivity failure CONST L_HintCheckConnection_Message = "ERROR: Please check the system name, credentials and WMI (WBEM) service." ' constants for info. messages CONST L_PageFileDoesNotExist_ErrorMessage = "ERROR: No paging file exists on volume '%1'" CONST L_NoPageFiles_Message = "ERROR: No paging file(s) available." ' constants for Syntax Error Messages CONST L_InvalidSyntax_ErrorMessage = "ERROR: Invalid Syntax." CONST L_InvalidServerName_ErrorMessage = "ERROR: Invalid Syntax. System name cannot be empty." CONST L_InvalidUserName_ErrorMessage = "ERROR: Invalid Syntax. User name cannot be empty." CONST L_NoHeaderNotAllowed_ErrorMessage = "ERROR: /NH option is allowed only for ""TABLE"" and ""CSV"" formats." CONST L_TypeUsage_Message = "Type ""%1 /?"" for usage." CONST L_TypeCreateUsage_Message = "Type ""%1 /Create /?"" for usage." CONST L_TypeChangeUsage_Message = "Type ""%1 /Change /?"" for usage." CONST L_TypeDeleteUsage_Message = "Type ""%1 /Delete /?"" for usage." CONST L_TypeQueryUsage_Message = "Type ""%1 /Query /?"" for usage." ' constants for missing mandatory option messages CONST L_VolumeNameNotSpecified_ErrorMessage = "Mandatory option '/VO' is missing." CONST L_InitialSizeNotSpecified_ErrorMessage = "Either '/SYS' or both '/I' and '/M' are mandatory with Create option." CONST L_MaximumSizeNotSpecified_ErrorMessage = "Mandatory option '/M' is missing." CONST L_NoneoftheSizeSpecified_ErrorMessage = "Either '/SYS' or one of '/I' and '/M' are mandatory with Change option." CONST L_CONST_NoneoftheSizes_AllowedWithSysManaged_Text = "Either '/I' or '/M' can not be specified with '/SYS'." CONST L_FormatNotSpecified_ErrorMessage = "Mandatory options '/FO' is missing." ' error messages for invalid usage of s,u,p switches CONST L_InvalidServerCredentials_ErrorMessage = "ERROR: Invalid Syntax. /U can be specified only when /S is specified." CONST L_InvalidUserCredentials_ErrorMessage = "ERROR: Invalid Syntax. /P can be specified only when /U is specified." ' constants for Mutliple line Error Messages CONST L_InsufficientMaxSize1_ErrorMessage = "ERROR: The maximum paging file size on volume '%1' should be greater than or " CONST L_InsufficientMaxSize2_ErrorMessage = " equal to the initial paging file size, and less than %2 MB or less " CONST L_InsufficientMaxSize3_ErrorMessage = " than the disk size." CONST L_InitialSizeRange1_ErrorMessage = "ERROR: The initial paging file size must be between 2 MB and %1 MB, and " CONST L_InitialSizeRange2_ErrorMessage = " cannot exceed the amount of free space on the drive '%2' selected. " CONST L_NotEnoughSpace1_ErrorMessage = "ERROR: There is not enough space on the drive '%1' for the paging file" CONST L_NotEnoughSpace2_ErrorMessage = " Please enter a smaller number or free some disk space." CONST L_AtLeastFiveMB1_ErrorMessage = "ERROR: There is not enough space on the drive '%1' to create the paging file" CONST L_AtLeastFiveMB2_ErrorMessage = " size specified. At least 5 megabytes of free disk space must be left" CONST L_AtLeastFiveMB3_ErrorMessage = " after the paging file is created. Specify a smaller paging file size" CONST L_AtLeastFiveMB4_ErrorMessage = " or free some disk space." CONST L_DiskTooSmall1_ErrorMessage = "ERROR: Drive '%1' is too small for the maximum paging file size specified." CONST L_DiskTooSmall2_ErrorMessage = " Please enter a smaller number." CONST L_CannotDelete1_ErrorMessage = "ERROR: The paging file from volume '%1' cannot be deleted." CONST L_CannotDelete2_ErrorMessage = " At least one paging file must be present." ' constants for Mutliple line Warning Messages CONST L_GrowsToFreeSpaceWarning1_Message = "WARNING: Drive '%1' does not have enough free space for the maximum paging " CONST L_GrowsToFreeSpaceWarning2_Message = " file specified. If you continue with this setting, the paging file " CONST L_GrowsToFreeSpaceWarning3_Message = " will only grow to the size of the available free space (%2 MB)." CONST L_CrashDumpSettingWarning1_Message = "WARNING: If the paging file on volume '%1' has an initial size of less than" CONST L_CrashDumpSettingWarning2_Message = " %2, then the system may not be able to create a crash dump debugging" CONST L_CrashDumpSettingWarning3_Message = " information file if a STOP error (blue screen) occurs." ' constants for Multiple line SUCCESS / SKIPPING messages CONST L_ChangeIntSuccess1_Message = "SUCCESS: The initial size for the paging file on '%1' was changed from " CONST L_ChangeIntSuccess2_Message = " %2 MB to %3 MB." CONST L_ChangeMaxSuccess1_Message = "SUCCESS: The maximum size for the paging file on '%1' was changed from " CONST L_ChangeMaxSuccess2_Message = " %2 MB to %3 MB." CONST L_ChangeIntSkipping1_Message = "SKIPPING: The initial size specified for the paging file on '%1' is same as " CONST L_ChangeIntSkipping2_Message = " the present value." CONST L_ChangeMaxSkipping1_Message = "SKIPPING: The maximum size specified for the paging file on '%1' is same as " CONST L_ChangeMaxSkipping2_Message = " the present value." CONST L_CreateSuccess1_Message = "SUCCESS: A paging file with initial size of %1 MB and a maximum size " CONST L_CreateSuccess2_Message = " of %2 MB was created on the volume: '%3'" CONST L_CreateSkipping_Message = "SKIPPING: A paging file already exists on the volume: '%1'" CONST L_DeleteSuccess_Message = "SUCCESS: The paging file from volume '%1' has successfully been removed." CONST L_CreateSystemSuccess_message = "SUCCESS: The paging file of system managed size has been created on the volume: '%1'." CONST L_ChangeSystemSuccess_message = "SUCCESS: The paging file on the volume '%1' has been changed to system managed size." CONST L_CONST_Already_SystemManaged_Text = "ERROR: The page File on drive %1 is already system managed." ' constant for other error messages CONST L_InvalidFormat_ErrorMessage = "Invalid format '%1' specified." CONST L_SystemManagedSize_ErrorMessage = "ERROR: Volume '%1' is system managed." CONST L_PromptForContinueAnyWay_Message = "Continue Anyway [y/n]?" CONST L_NotAllowedMoreThanOnce_ErrorMessage = "'%1' option is not allowed more than '1' time." CONST L_RestartComputer_Message = "Restart the computer for these changes to take effect." '****************************************************************************** ' END of Localization Content '****************************************************************************** ' constants used for format selection CONST PatternFormat_Text = "^(table|list|csv)$" CONST DefaultFormat_Text = "list" CONST ListFormat_Text = "list" ' the main options CONST OPTION_HELP = "?" CONST OPTION_CHANGE = "change" CONST OPTION_CREATE = "create" CONST OPTION_DELETE = "delete" CONST OPTION_QUERY = "query" ' the suboptions CONST SUB_OPTION_SERVER = "s" CONST SUB_OPTION_USER = "u" CONST SUB_OPTION_PASSWORD = "p" CONST SUB_OPTION_INTSIZE = "i" CONST SUB_OPTION_MAXSIZE = "m" CONST SUB_OPTION_VOLUME = "vo" CONST SUB_OPTION_FORMAT = "fo" CONST SUB_OPTION_NOHEADER = "nh" CONST SUB_OPTION_SYSTEM_MANAGED = "sys" ' constant for CScript CONST CONST_CSCRIPT = 2 ' constants for error codes CONST CONST_ERROR = 0 ' constants for options CONST CONST_SHOW_USAGE = 3 CONST CONST_CHANGE_OPTION = 11 CONST CONST_CREATE_OPTION = 21 CONST CONST_DELETE_OPTION = 31 CONST CONST_QUERY_OPTION = 41 ' constant for matched pattern CONST CONST_NO_MATCHES_FOUND = 0 ' utility specific constants CONST INITIAL_SIZE_LB = 2 CONST DRIVE_TYPE = 3 CONST MEGA_BYTES = " MB" CONST SIZE_FACTOR = 1.5 CONST CONVERSION_FACTOR = 1048576 CONST PAGEFILE_DOT_SYS = "\pagefile.sys" CONST CONST_SYSTEM_INIT_SIZE = 0 CONST CONST_SYSTEM_MAX_SIZE = 0 ' constant for the UNC format server name CONST UNC_FORMAT_SERVERNAME_PREFIX = "\\" ' constants for exit values CONST EXIT_SUCCESS = 0 CONST EXIT_UNEXPECTED = 255 CONST EXIT_INVALID_INPUT = 254 CONST EXIT_METHOD_FAIL = 250 CONST EXIT_QUERY_FAIL = 253 CONST EXIT_INVALID_PARAM = 999 CONST EXIT_PARTIAL_SUCCESS = 128 ' Define namespace and class names of wmi CONST CONST_WBEM_FLAG = 131072 CONST CONST_NAMESPACE_CIMV2 = "root\cimv2" CONST CLASS_PAGE_FILE_SETTING = "Win32_PageFileSetting" CONST CLASS_LOGICAL_DISK = "Win32_LogicalDisk" CONST CLASS_COMPUTER_SYSTEM = "Win32_ComputerSystem" CONST CLASS_PAGE_FILE_USAGE = "Win32_PageFileUsage" CONST CLASS_OPERATING_SYSTEM = "Win32_OperatingSystem" CONST CLASS_PERFDISK_PHYSICAL_DISK = "Win32_PerfRawData_PerfDisk_PhysicalDisk" Dim UseCscriptErrorMessage ' string to store the CScript usage Dim blnLocalConnection ' flag for local connection Dim blnSuccessMsg ' flag for indicating if any success messages have been delivered Dim blnFailureMsg ' flag to indicate if any failure messages have been delivered Dim component ' object for the common module ' Error Messages Dim InsufficientMaxSizeErrorMessage Dim InitialSizeRangeErrorMessage Dim NotEnoughSpaceErrorMessage Dim AtLeastFiveMBErrorMessage Dim DiskTooSmallErrorMessage Dim CannotDeleteErrorMessage ' Warning Messages Dim GrowsToFreeSpaceWarningMessage Dim CrashDumpSettingWarningMessage ' Success / Skipping messages Dim ChangeIntSuccessMessage Dim ChangeMaxSuccessMessage Dim ChangeIntSkippingMessage Dim ChangeMaxSkippingMessage Dim CreateSuccessMessage InsufficientMaxSizeErrorMessage = L_InsufficientMaxSize1_ErrorMessage & vbCRLF & _ L_InsufficientMaxSize2_ErrorMessage & vbCRLF & _ L_InsufficientMaxSize3_ErrorMessage InitialSizeRangeErrorMessage = L_InitialSizeRange1_ErrorMessage & vbCRLF & _ L_InitialSizeRange2_ErrorMessage NotEnoughSpaceErrorMessage = L_NotEnoughSpace1_ErrorMessage & vbCRLF & _ L_NotEnoughSpace2_ErrorMessage AtLeastFiveMBErrorMessage = L_AtLeastFiveMB1_ErrorMessage & vbCRLF & _ L_AtLeastFiveMB2_ErrorMessage & vbCRLF & _ L_AtLeastFiveMB3_ErrorMessage & vbCRLF & _ L_AtLeastFiveMB4_ErrorMessage DiskTooSmallErrorMessage = L_DiskTooSmall1_ErrorMessage & vbCRLF & _ L_DiskTooSmall2_ErrorMessage CannotDeleteErrorMessage = L_CannotDelete1_ErrorMessage & vbCRLF & _ L_CannotDelete2_ErrorMessage GrowsToFreeSpaceWarningMessage = L_GrowsToFreeSpaceWarning1_Message & vbCRLF & _ L_GrowsToFreeSpaceWarning2_Message & vbCRLF & _ L_GrowsToFreeSpaceWarning3_Message CrashDumpSettingWarningMessage = L_CrashDumpSettingWarning1_Message & vbCRLF & _ L_CrashDumpSettingWarning2_Message & vbCRLF & _ L_CrashDumpSettingWarning3_Message ChangeIntSuccessMessage = L_ChangeIntSuccess1_Message & vbCRLF & _ L_ChangeIntSuccess2_Message ChangeMaxSuccessMessage = L_ChangeMaxSuccess1_Message & vbCRLF & _ L_ChangeMaxSuccess2_Message ChangeIntSkippingMessage = L_ChangeIntSkipping1_Message & vbCRLF & _ L_ChangeIntSkipping2_Message ChangeMaxSkippingMessage = L_ChangeMaxSkipping1_Message & vbCRLF & _ L_ChangeMaxSkipping2_Message CreateSuccessMessage = L_CreateSuccess1_Message & vbCRLF & _ L_CreateSuccess2_Message blnLocalConnection = FALSE blnSuccessMsg = FALSE blnFailureMsg = FALSE ' create the object for commom module Set component = CreateObject( "Microsoft.CmdLib" ) ' check if the commom module(CmdLib.wsc) is not registered If Err.Number Then Err.Clear WScript.Echo(L_UnableToInclude_ErrorMessage) WScript.Quit(EXIT_METHOD_FAIL) End If ' set the scripting host to WScript Set component.ScriptingHost = WScript.Application ' Check whether the script is run using CScript If CInt(component.checkScript) <> CONST_CSCRIPT Then UseCscriptErrorMessage = L_UseCscript1_ErrorMessage & vbCRLF & _ ExpandEnvironmentString(L_UseCscript2_ErrorMessage) & vbCRLF & vbCRLF & _ L_UseCscript3_ErrorMessage & vbCRLF & _ L_UseCscript4_ErrorMessage & vbCRLF & vbCRLF & _ ExpandEnvironmentString(L_UseCscript5_ErrorMessage) WScript.Echo (UseCscriptErrorMessage) WScript.Quit(EXIT_UNEXPECTED) End If ' call the main function Call VBMain() ' quit with exit value = 0 WScript.Quit(EXIT_SUCCESS) '****************************************************************************** '* Sub: VBMain '* '* Purpose: This is the main function which starts execution '* '* Input: None '* '* Output: None '* '****************************************************************************** Sub VBMain() ON ERROR RESUME NEXT Err.Clear ' Declaring main variables Dim strMachine ' machine to configure page files on Dim strUserName ' user name to connect to the machine Dim strPassword ' <PASSWORD> Dim intIntSize ' initial size for the page file Dim intMaxSize ' maximum size for the page file Dim strVolName ' volume name Dim objVols ' object containing volume names Dim strFormat ' query display format Dim blnNoHeader ' stores if -nh is specified or not Dim blnSystemManaged ' Specifies whether pagefile has to be system managed Dim blnInitSize ' Specifies whether /I switch is specified or not Dim blnmaxSize ' Specifies whether /M switch is specified or not Dim intMainOption ' main option specified Dim intTempResult ' temporary variable to hold the return value Dim blnValidArguments ' stores the return value of ValidateArguments ' Initializing Variables intTempResult = CONST_ERROR ' default is CONST_ERROR (=0) strFormat = DefaultFormat_Text ' default format is LIST blnInitSize = FALSE blnMaxSize = FALSE Set objVols = CreateObject("Scripting.Dictionary") objVols.CompareMode = VBBinaryCompare If Err.Number Then ' Unable to create the dictionary object. Err.Clear WScript.Echo(L_FailCreateObject_ErrorMessage) WScript.Quit(EXIT_METHOD_FAIL) End If intTempResult = intParseCmdLine( strMachine, _ strUserName, _ strPassword, _ intIntSize, _ intMaxSize, _ strVolName, _ objVols, _ strFormat, _ blnNoHeader, _ blnSystemManaged, _ blnInitSize, _ blnMaxSize, _ intMainOption ) ' Select the operation specified by the user Select Case intTempResult Case CONST_SHOW_USAGE Select Case intMainOption Case CONST_CHANGE_OPTION Call ShowChangeUsage() Case CONST_CREATE_OPTION Call ShowCreateUsage() Case CONST_DELETE_OPTION Call ShowDeleteUsage() Case CONST_QUERY_OPTION Call ShowQueryUsage() Case Else Call ShowUsage() End Select Case CONST_CHANGE_OPTION blnValidArguments = ValidateArguments (strMachine, strUserName, strPassword, _ intIntSize, intMaxSize, objVols, strFormat, _ blnNoHeader, blnSystemManaged, blnInitSize, _ blnMaxSize, intMainOption) ' If all arguments valid, proceed If blnValidArguments Then Call ProcessChange(strMachine, strUserName, strPassword, _ intIntSize, intMaxSize, blnSystemManaged, objVols) End If Case CONST_CREATE_OPTION blnValidArguments = ValidateArguments (strMachine, strUserName, strPassword, _ intIntSize, intMaxSize, objVols, strFormat, _ blnNoHeader, blnSystemManaged, blnInitSize, _ blnMaxSize, intMainOption) ' If all arguments valid, proceed If blnValidArguments Then Call ProcessCreate(strMachine, strUserName, strPassword, _ intIntSize, intMaxSize, blnSystemManaged, objVols) End If Case CONST_DELETE_OPTION blnValidArguments = ValidateArguments (strMachine, strUserName, strPassword, _ intIntSize, intMaxSize, objVols, strFormat, _ blnNoHeader, blnSystemManaged, blnInitSize, _ blnMaxSize, intMainOption) ' If all arguments valid, proceed If blnValidArguments Then Call ProcessDelete(strMachine, strUserName, strPassword, blnSystemManaged, objVols) ' Here wild cards cannot be specified End If Case CONST_QUERY_OPTION blnValidArguments = ValidateArguments (strMachine, strUserName, strPassword, _ intIntSize, intMaxSize, objVols, strFormat, _ blnNoHeader, blnSystemManaged, blnInitSize, _ blnMaxSize, intMainOption) ' If all arguments valid, proceed If blnValidArguments Then Call ProcessQuery(strMachine, strUserName, strPassword, strFormat, blnSystemManaged, blnNoHeader) End If Case CONST_ERROR WSCript.Quit(EXIT_INVALID_INPUT) End Select End Sub '****************************************************************************** '* Function: intPaseCmdLine '* '* Purpose: Parses the command line arguments into the variables '* '* Input: '* [out] strMachine machine to configure page files on '* [out] strUserName user name to connect to the machine '* [out] strPassword <PASSWORD> the <PASSWORD> '* [out] intIntSize initial size for the page file '* [out] intMaxSize maximum size for the page file '* [in] strVolName individual volume name(s) '* [out] objVols object containing volume names '* [out] strFormat query display format '* [out] intMainOption main option specified '* '* Output: Returns CONST_SHOW_USAGE, CONST_CHANGE_OPTION , '* CONST_CREATE_OPTION, CONST_DELETE_OPTION , '* CONST_QUERY_OPTION or CONST_ERROR. '* Displays error message and quits if invalid option is asked '* '****************************************************************************** Private Function intParseCmdLine( ByRef strMachine, _ ByRef strUserName, _ ByRef strPassword, _ ByRef intIntSize, _ ByRef intMaxSize, _ ByVal strVolName, _ ByRef objVols, _ ByRef strFormat, _ ByRef blnNoHeader, _ ByRef blnSystemManaged, _ ByRef blninitSize, _ ByRef blnMaxSize, _ ByRef intMainOption ) ON ERROR RESUME NEXT Err.Clear Dim strUserGivenArg ' to temporarily store the user given arguments Dim intArgIter ' to count the number of arguments given Dim intQCount ' to count the number of help options given Dim intMainOptionNumber ' to count the number of main operations selected (Max allowed = 1) Dim intVolumes ' to store the number of volumes specified ' Following variables are used to check if a switch if given more than once Dim blnIntSizeSpecified Dim blnMaxSizeSpecified Dim blnFormatSpecified Dim blnMachineSpecified Dim blnUserSpecified Dim blnPasswordSpecified ' Initialization strUserGivenArg = "" intMainOptionNumber = 0 intQCount = 0 intArgIter = 0 intParseCmdLine = 0 ' initially none of the parameters are specified, so set all flags to FALSE blnIntSizeSpecified = FALSE blnMaxSizeSpecified = FALSE blnFormatSpecified = FALSE blnMachineSpecified = FALSE blnUserSpecified = FALSE blnPasswordSpecified = FALSE blnNoHeader = FALSE blnSystemManaged = FALSE ' if no arguments are specified, default option is query If WScript.Arguments.Count = 0 Then intParseCmdLine = CONST_QUERY_OPTION intMainOption = CONST_QUERY_OPTION End If ' Retrieve the command line parameters and their values Do While intArgIter <= WScript.Arguments.Count - 1 strUserGivenArg = WScript.Arguments.Item(intArgIter) ' check if the first character is a '-' OR '/' symbol; NOTE that "/" is the standard If Left(strUserGivenArg,1) = "/" OR Left(strUserGivenArg,1) = "-" Then ' ignore the symbol and take the rest as the switch specified strUserGivenArg = Right(strUserGivenArg,Len(strUserGivenArg) - 1) Select Case LCase(strUserGivenArg) Case LCase(OPTION_HELP) intQCount = intQCount + 1 If (CInt(intQCount) >= 2 OR CInt(WScript.Arguments.Count) > 2) Then intParseCmdLine = CONST_ERROR WScript.Echo(L_InvalidHelpUsage_ErrorMessage) Exit Function Else intParseCmdLine = CONST_SHOW_USAGE intArgIter = intArgIter + 1 End If Case LCase(OPTION_CHANGE) If intQCount = 1 Then ' intQCount = 1 means help specified intParseCmdLine = CONST_SHOW_USAGE Else intParseCmdLine = CONST_CHANGE_OPTION End If intMainOption = CONST_CHANGE_OPTION intMainOptionNumber = intMainOptionNumber + 1 intArgIter = intArgIter + 1 Case LCase(OPTION_CREATE) If intQCount = 1 Then ' intQCount = 1 means help specified intParseCmdLine = CONST_SHOW_USAGE Else intParseCmdLine = CONST_CREATE_OPTION End If intMainOption = CONST_CREATE_OPTION intMainOptionNumber = intMainOptionNumber + 1 intArgIter = intArgIter + 1 Case LCase(OPTION_DELETE) If intQCount = 1 Then ' intQCount = 1 means help specified intParseCmdLine = CONST_SHOW_USAGE Else intParseCmdLine = CONST_DELETE_OPTION End If intMainOption = CONST_DELETE_OPTION intMainOptionNumber = intMainOptionNumber + 1 intArgIter = intArgIter + 1 Case LCase(OPTION_QUERY) If intQCount = 1 Then ' intQCount = 1 means help specified intParseCmdLine = CONST_SHOW_USAGE Else intParseCmdLine = CONST_QUERY_OPTION End If intMainOption = CONST_QUERY_OPTION intMainOptionNumber = intMainOptionNumber + 1 intArgIter = intArgIter + 1 Case LCase(SUB_OPTION_SERVER) ' Check if server name is given with help usage If intParseCmdLine = CONST_SHOW_USAGE Then WScript.Echo(L_InvalidHelpUsage_ErrorMessage) WScript.Quit(EXIT_INVALID_INPUT) End If ' Check if Machine Name is already specified If NOT blnMachineSpecified Then blnMachineSpecified = TRUE ' Set Specified Flag to TRUE If NOT component.getArguments(L_MachineName_Text,strMachine,intArgIter,FALSE) Then component.VBPrintf L_InvalidSyntax_ErrorMessage Call typeMessage(intMainOption) intParseCmdLine = CONST_ERROR Exit Function End If intArgIter = intArgIter + 1 Else component.VBPrintf L_InvalidSyntax_ErrorMessage & " " & _ L_NotAllowedMoreThanOnce_ErrorMessage , _ Array(WScript.Arguments.Item(intArgIter)) ' print the appropriate help usage message Call typeMessage(intMainOption) WScript.Quit(EXIT_INVALID_INPUT) End If Case LCase(SUB_OPTION_USER) ' Check if user name is given with help usage If intParseCmdLine = CONST_SHOW_USAGE Then WScript.Echo(L_InvalidHelpUsage_ErrorMessage) WScript.Quit(EXIT_INVALID_INPUT) End If ' Check if User Name is already specified If NOT blnUserSpecified Then blnUserSpecified = TRUE ' Set Specified Flag to TRUE If NOT component.getArguments(L_User_Text,strUserName,intArgIter,FALSE) Then component.VBPrintf L_InvalidSyntax_ErrorMessage Call typeMessage(intMainOption) intParseCmdLine = CONST_ERROR Exit Function End If intArgIter = intArgIter + 1 Else component.VBPrintf L_InvalidSyntax_ErrorMessage & " " & _ L_NotAllowedMoreThanOnce_ErrorMessage , _ Array(WScript.Arguments.Item(intArgIter)) ' print the appropriate help usage message Call typeMessage(intMainOption) WScript.Quit(EXIT_INVALID_INPUT) End If Case LCase(SUB_OPTION_PASSWORD) ' Check if password is given with help usage If intParseCmdLine = CONST_SHOW_USAGE Then WScript.Echo(L_InvalidHelpUsage_ErrorMessage) WScript.Quit(EXIT_INVALID_INPUT) End If ' Check if Password is already specified If NOT blnPasswordSpecified Then blnPasswordSpecified = TRUE ' Set Specified Flag to TRUE If NOT component.getArguments(L_Password_Text,strPassword,intArgIter,FALSE) Then component.VBPrintf L_InvalidSyntax_ErrorMessage Call typeMessage(intMainOption) intParseCmdLine = CONST_ERROR Exit Function End If intArgIter = intArgIter + 1 Else component.VBPrintf L_InvalidSyntax_ErrorMessage & " " & _ L_NotAllowedMoreThanOnce_ErrorMessage , _ Array(WScript.Arguments.Item(intArgIter)) ' print the appropriate help usage message Call typeMessage(intMainOption) WScript.Quit(EXIT_INVALID_INPUT) End If Case LCase(SUB_OPTION_INTSIZE) ' Check if initsize is given with help usage If intParseCmdLine = CONST_SHOW_USAGE Then WScript.Echo(L_InvalidHelpUsage_ErrorMessage) WScript.Quit(EXIT_INVALID_INPUT) End If ' Check if initsize is already specified If NOT blnIntSizeSpecified Then blnIntSizeSpecified = TRUE ' Set Specified Flag to TRUE If NOT component.getArguments(L_Intsize_Text,intIntSize,intArgIter,FALSE) Then component.VBPrintf L_InvalidSyntax_ErrorMessage Call typeMessage(intMainOption) intParseCmdLine = CONST_ERROR Exit Function End If blnInitSize = TRUE intArgIter = intArgIter + 1 Else component.VBPrintf L_InvalidSyntax_ErrorMessage & " " & _ L_NotAllowedMoreThanOnce_ErrorMessage , _ Array(WScript.Arguments.Item(intArgIter)) ' print the appropriate help usage message Call typeMessage(intMainOption) WScript.Quit(EXIT_INVALID_INPUT) End If Case LCase(SUB_OPTION_MAXSIZE) ' Check if maxsize is given with help usage If intParseCmdLine = CONST_SHOW_USAGE Then WScript.Echo(L_InvalidHelpUsage_ErrorMessage) WScript.Quit(EXIT_INVALID_INPUT) End If ' Check if Maxsize is already specified If NOT blnMaxSizeSpecified Then blnMaxSizeSpecified = TRUE ' Set Specified Flag to TRUE If NOT component.getArguments(L_Maxsize_Text,intMaxSize,intArgIter,FALSE) Then component.VBPrintf L_InvalidSyntax_ErrorMessage Call typeMessage(intMainOption) intParseCmdLine = CONST_ERROR Exit Function End If blnMaxSize = TRUE intArgIter = intArgIter + 1 Else component.VBPrintf L_InvalidSyntax_ErrorMessage & " " & _ L_NotAllowedMoreThanOnce_ErrorMessage , _ Array(WScript.Arguments.Item(intArgIter)) ' print the appropriate help usage message Call typeMessage(intMainOption) WScript.Quit(EXIT_INVALID_INPUT) End If Case LCase(SUB_OPTION_FORMAT) ' Check if maxsize is given with help usage If intParseCmdLine = CONST_SHOW_USAGE Then WScript.Echo(L_InvalidHelpUsage_ErrorMessage) WScript.Quit(EXIT_INVALID_INPUT) End If ' Check if format is already specified If NOT blnFormatSpecified Then blnFormatSpecified = TRUE ' Set Specified Flag to TRUE If NOT component.getArguments(L_Format_Text,strFormat,intArgIter,FALSE) Then component.VBPrintf L_InvalidSyntax_ErrorMessage Call typeMessage(intMainOption) intParseCmdLine = CONST_ERROR Exit Function End If intArgIter = intArgIter + 1 Else component.VBPrintf L_InvalidSyntax_ErrorMessage & " " & _ L_NotAllowedMoreThanOnce_ErrorMessage , _ Array(WScript.Arguments.Item(intArgIter)) ' print the appropriate help usage message Call typeMessage(intMainOption) WScript.Quit(EXIT_INVALID_INPUT) End If Case LCase(SUB_OPTION_NOHEADER) ' Check if -nh is already specified If NOT blnNoHeader Then blnNoHeader = TRUE intArgIter = intArgIter + 1 Else component.VBPrintf L_InvalidSyntax_ErrorMessage & " " & _ L_NotAllowedMoreThanOnce_ErrorMessage , _ Array(WScript.Arguments.Item(intArgIter)) ' print the appropriate help usage message Call typeMessage(intMainOption) WScript.Quit(EXIT_INVALID_INPUT) End If Case Lcase(SUB_OPTION_SYSTEM_MANAGED) ' Check if -sm is specified If Not blnSystemManaged Then blnSystemManaged = TRUE intArgIter = intArgIter + 1 Else component.VBPrintf L_InvalidSyntax_ErrorMessage & " " & _ L_NotAllowedMoreThanOnce_ErrorMessage, _ Array(Wscript.Arguments.Item(intArgIter)) ' Print the corresponding help usage error message Call typeMessage(intMainOption) Wscript.Quit(EXIT_INVALID_INPUT) End If Case LCase(SUB_OPTION_VOLUME) ' Check if volume is given with help usage If intParseCmdLine = CONST_SHOW_USAGE Then WScript.Echo(L_InvalidHelpUsage_ErrorMessage) WScript.Quit(EXIT_INVALID_INPUT) End If If NOT component.getArguments(L_Volume_Text,strVolName,intArgIter,FALSE) Then component.VBPrintf L_InvalidSyntax_ErrorMessage Call typeMessage(intMainOption) intParseCmdLine = CONST_ERROR Exit Function Else If strVolName = "*" Then objVols.Add LCase(strVolName), -1 Else If NOT objVols.Exists(LCase(strVolName)) Then objVols.Add LCase(strVolName), -1 End If intVolumes = objVols.Count End If End If intArgIter = intArgIter + 1 Case Else ' display the invalid param err msg first component.VBPrintf L_InvalidParameter_ErrorMessage, _ Array(WScript.arguments.Item(intArgIter)) ' then display the 'type ..usage' message Select Case CInt(intMainOption) Case CONST_CHANGE_OPTION component.VBPrintf L_TypeChangeUsage_Message, _ Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_PARAM) Case CONST_CREATE_OPTION component.VBPrintf L_TypeCreateUsage_Message, _ Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_PARAM) Case CONST_DELETE_OPTION component.VBPrintf L_TypeDeleteUsage_Message, _ Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_PARAM) Case CONST_QUERY_OPTION component.VBPrintf L_TypeQueryUsage_Message, _ Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_PARAM) Case Else component.VBPrintf L_TypeUsage_Message, _ Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_PARAM) End Select End Select Else ' invalid argument specified ' display the invalid param err msg first component.VBPrintf L_InvalidParameter_ErrorMessage, _ Array(WScript.arguments.Item(intArgIter)) ' then display the 'type ..usage' message Select Case CInt(intMainOption) Case CONST_CHANGE_OPTION component.VBPrintf L_TypeChangeUsage_Message, _ Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_PARAM) Case CONST_CREATE_OPTION component.VBPrintf L_TypeCreateUsage_Message, _ Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_PARAM) Case CONST_DELETE_OPTION component.VBPrintf L_TypeDeleteUsage_Message, _ Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_PARAM) Case CONST_QUERY_OPTION component.VBPrintf L_TypeQueryUsage_Message, _ Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_PARAM) Case Else component.VBPrintf L_TypeUsage_Message, _ Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_PARAM) End Select End If Loop ' check if the there is any volume(s) specified. If objVols.Count = 0 Then intVolumes = objVols.Count End If ' Check if volumes | * is specified along with help If (intVolumes > 0 AND intQCount = 1) Then WScript.Echo(L_InvalidHelpUsage_ErrorMessage) WScript.Quit(EXIT_INVALID_INPUT) End If ' Check if two major operations are selected at a time If ( intMainOptionNumber > 1 ) Then WScript.Echo(L_InvalidSyntax_ErrorMessage) component.VBPrintf L_TypeUsage_Message,Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_INPUT) ElseIf (intQcount = 0 AND intmainoption = 0) Then intMainOption = CONST_QUERY_OPTION End If ' check if NO major option(s) is specified, but other switches are specified If ( intMainOptionNumber = 0 ) Then If blnIntSizeSpecified OR _ blnMaxSizeSpecified OR _ blnFormatSpecified OR _ blnMachineSpecified OR _ blnUserSpecified OR _ blnPasswordSpecified OR _ blnNoHeader OR _ intVolumes > 0 Then WScript.Echo(L_InvalidSyntax_ErrorMessage) component.VBPrintf L_TypeUsage_Message, _ Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_INPUT) End If End If ' check if format is specified with create option If (intMainOption = CONST_CREATE_OPTION) Then If blnFormatSpecified Then WScript.Echo(L_InvalidSyntax_ErrorMessage) component.VBPrintf L_TypeCreateUsage_Message, _ Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_INPUT) End If End If ' check if format is specified with change option If (intMainOption = CONST_CHANGE_OPTION) Then If blnFormatSpecified Then WScript.Echo(L_InvalidSyntax_ErrorMessage) component.VBPrintf L_TypeChangeUsage_Message, _ Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_INPUT) End If End If ' check if /Initsize, /Maxsize, /FO are specified If (intMainOption = CONST_DELETE_OPTION) Then If (blnIntSizeSpecified OR blnMaxSizeSpecified OR blnFormatSpecified OR blnSystemManaged) Then WScript.Echo(L_InvalidSyntax_ErrorMessage) component.VBPrintf L_TypeDeleteUsage_Message, _ Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_INPUT) End If End If ' check if /Initsize, /Maxsize, are specified If (intMainOption = CONST_QUERY_OPTION) Then If (blnIntSizeSpecified OR blnMaxSizeSpecified OR blnSystemManaged) Then WScript.Echo(L_InvalidSyntax_ErrorMessage) component.VBPrintf L_TypeQueryUsage_Message, _ Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_INPUT) End If End If End Function '****************************************************************************** '* Function: ValidateArguments '* '* Purpose: Validates the command line arguments given by the user '* '* Input: '* [out] strMachine machine to configure page files on '* [out] strUserName user name to connect to the machine '* [out] strPassword <PASSWORD> '* [out] intIntSize the initial size for the page file '* [out] intMaxSize the maximum size for the page file '* [out] objVols the object containing volume names '* [out] strFormat the query display format '* [out] blnNoHeader the query display format '* [out] intMainOption the main option specified '* '* Output: Returns true if all valid else displays error message and quits '* Gets the password from the user if not specified along with User. '* '****************************************************************************** Private Function ValidateArguments ( ByRef strMachine, _ ByRef strUserName, _ ByRef strPassword, _ ByRef intIntSize, _ ByRef intMaxSize, _ ByRef objVols, _ ByRef strFormat, _ ByRef blnNoHeader, _ ByRef blnSystemManaged, _ ByRef blnInitSize, _ ByRef blnMaxSize, _ ByRef intMainOption) ON ERROR RESUME NEXT Err.Clear Dim strMatchPattern ' the pattern to be matched Dim intVolumes ' to count the no.of volumes specified Dim arrVolume ' array to store the volumes specified Dim i ' Loop variable ' Initialization intVolumes = CInt(objVols.Count) arrVolume = objVols.Keys ValidateArguments = TRUE i = 0 ' Check if invalid server name is given If NOT IsEmpty(strMachine) Then If Trim(strMachine) = vbNullString Then WScript.Echo(L_InvalidServerName_ErrorMessage) WScript.Quit(EXIT_INVALID_INPUT) End If End If ' Check if invalid user name is given If NOT IsEmpty(strUserName) Then If Trim(strUserName) = vbNullString Then WScript.Echo(L_InvalidUserName_ErrorMessage) WScript.Quit(EXIT_INVALID_INPUT) End If End If ' check if user is given without machine OR password If ((strUserName <> VBEmpty) AND (strMachine = VBEmpty)) Then WScript.Echo L_InvalidServerCredentials_ErrorMessage component.VBPrintf L_TypeUsage_Message, _ Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_INPUT) ' check if password is given without user OR machine ElseIf ((strPassword <> VBEmpty) AND (strUserName = VBEmpty))Then WScript.Echo L_InvalidUserCredentials_ErrorMessage component.VBPrintf L_TypeUsage_Message, _ Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_INPUT) End If ' Check if initial size is specified, validate if it is a poistive number If Len(CStr(intIntSize)) > 0 Then ' Initsize should be numeric only ' chr(46) indicates "." (dot) If NOT (IsNumeric(intIntSize) AND InStr(intIntSize,chr(46)) = 0 AND Instr(intIntSize,"-") = 0) Then ValidateArguments = FALSE WScript.Echo L_InvalidInitSizeValue_ErrorMessage WScript.Quit(EXIT_INVALID_INPUT) End If End If ' Check if maximum size is specified, validate if it is a poistive number If Len(CStr(intMaxSize)) > 0 Then ' Maxsize should be numeric only ' chr(46) indicates "." (dot) If NOT (IsNumeric(intMaxSize) AND InStr(intMaxSize,chr(46)) = 0 AND Instr(intMaxSize,"-") = 0) Then ValidateArguments = FALSE WScript.Echo L_InvalidMaxSizeValue_ErrorMessage WScript.Quit(EXIT_INVALID_INPUT) End If End If Select Case CInt(intMainOption) Case CONST_CHANGE_OPTION ' Valid Cases : either (initsize + volume) OR (maxsize + volume) ' OR (initsize + maxsize + volume) ' If none of the parameters (initsize or maxsize) is specified If blnSystemManaged = FALSE Then If ( blnInitSize = FALSE AND blnMaxSize = FALSE ) Then ValidateArguments = FALSE WScript.Echo(L_InvalidSyntax_ErrorMessage & " " & _ L_NoneoftheSizeSpecified_ErrorMessage) component.VBPrintf L_TypeChangeUsage_Message, _ Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_INPUT) End If If (blnInitSize = TRUE AND Len(CStr(intIntSize)) = 0 ) Then ValidateArguments = FALSE Wscript.Echo(L_InvalidInput_ErrorMessage) WScript.Quit(EXIT_INVALID_INPUT) End If If (blnMaxSize = TRUE AND Len(CStr(intMaxSize)) = 0 ) Then ValidateArguments = FALSE Wscript.Echo(L_InvalidInput_ErrorMessage) WScript.Quit(EXIT_INVALID_INPUT) End If Else If (blnInitSize = TRUE OR blnMaxSize = TRUE) Then ValidateArguments = FALSE Wscript.Echo(L_InvalidSyntax_ErrorMessage & " " & _ L_CONST_NoneoftheSizes_AllowedWithSysManaged_Text) component.VBPrintf L_TypeChangeUsage_Message, _ Array(Ucase(Wscript.ScriptName)) Wscript.Quit(EXIT_INVALID_INPUT) End If End If ' check if the volume is specified If (objVols.Count = 0) Then ValidateArguments = FALSE WScript.Echo(L_InvalidSyntax_ErrorMessage & " " & _ L_VolumeNameNotSpecified_ErrorMessage) component.VBPrintf L_TypeChangeUsage_Message, _ Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_INPUT) ' check if volume name is valid ElseIf isValidDrive(objVols,intMainOption) Then ValidateArguments = TRUE End If Case CONST_CREATE_OPTION If blnSystemManaged = FALSE Then If ( blnInitSize = FALSE OR blnMaxSize = FALSE ) Then ValidateArguments = FALSE WScript.Echo(L_InvalidSyntax_ErrorMessage & " " & _ L_InitialSizeNotSpecified_ErrorMessage) component.VBPrintf L_TypeCreateUsage_Message, _ Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_INPUT) End If If (blnInitSize = TRUE AND Len(CStr(intIntSize)) = 0 ) Then ValidateArguments = FALSE Wscript.Echo(L_InvalidInput_ErrorMessage) WScript.Quit(EXIT_INVALID_INPUT) End If If (blnMaxSize = TRUE AND Len(CStr(intMaxSize)) = 0 ) Then ValidateArguments = FALSE Wscript.Echo(L_InvalidInput_ErrorMessage) WScript.Quit(EXIT_INVALID_INPUT) End If Else If (blnInitSize = TRUE OR blnMaxSize = TRUE) Then ValidateArguments = FALSE Wscript.Echo(L_InvalidSyntax_ErrorMessage & " " & _ L_CONST_NoneoftheSizes_AllowedWithSysManaged_Text) component.VBPrintf L_TypeCreateUsage_Message, _ Array(Ucase(Wscript.ScriptName)) Wscript.Quit(EXIT_INVALID_INPUT) End If End If ' volume name is required If (objVols.Count = 0) Then ValidateArguments = FALSE WScript.Echo(L_InvalidSyntax_ErrorMessage & " " & _ L_VolumeNameNotSpecified_ErrorMessage) component.VBPrintf L_TypeCreateUsage_Message, _ Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_INPUT) ' check if volume name is valid ElseIf isValidDrive(objVols,intMainOption) Then ValidateArguments = TRUE End If Case CONST_DELETE_OPTION ' ONLY volume is required If (objVols.Count = 0) Then ValidateArguments = FALSE WScript.Echo(L_InvalidSyntax_ErrorMessage & " " & _ L_VolumeNameNotSpecified_ErrorMessage) component.VBPrintf L_TypeDeleteUsage_Message, _ Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_INPUT) ' check if volume name is valid ElseIf isValidDrive(objVols,intMainOption) Then ValidateArguments = TRUE End If ' Wild Card Character * is not allowed for /Delete option If (objVols.Exists("*")) Then ValidateArguments = FALSE objVols.Remove "*" WScript.Echo(L_InvalidInput_ErrorMessage) WScript.Quit(EXIT_INVALID_INPUT) End If Case CONST_QUERY_OPTION ' check if any format is specified. If Len(strFormat) > 0 Then ' only table, list and csv display formats allowed ' PatternFormat_Text contains ^(table|list|csv)$ If CInt(component.matchPattern(PatternFormat_Text, strFormat)) = CONST_NO_MATCHES_FOUND Then component.vbPrintf L_InvalidSyntax_ErrorMessage & " " & _ L_InvalidFormat_ErrorMessage, Array(strFormat) component.VBPrintf L_TypeQueryUsage_Message, _ Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_INPUT) End If End If ' Check if -nh is specified for LIST format If (blnNoHeader) AND LCase(strFormat) = LCase(ListFormat_Text) then WScript.Echo (L_NoHeaderNotAllowed_ErrorMessage) WScript.Quit(EXIT_INVALID_INPUT) End If ' Validation to check if volume names are specified with Query Option: If (intVolumes <> 0) Then ValidateArguments = FALSE WScript.Echo(L_InvalidSyntax_ErrorMessage) component.VBPrintf L_TypeQueryUsage_Message, _ Array(UCase(WScript.ScriptName)) WScript.Quit(EXIT_INVALID_INPUT) End If Case Else ' if intMainOption has some non-zero value means one operation is selected If (intMainOption > 0) Then ' -operation & volname together are valid ValidateArguments = TRUE Else ValidateArguments = FALSE WScript.Echo(L_InvalidInput_ErrorMessage) WScript.Quit(EXIT_INVALID_INPUT) End If End Select ' verify If required credentials given If (((NOT IsEmpty(strUserName)) AND (IsEmpty(strMachine))) OR _ ((NOT IsEmpty(strPassword)) AND (IsEmpty(strUserName))) )Then ValidateArguments = FALSE WScript.Echo (L_InvalidCredentials_ErrorMessage) WScript.Quit(EXIT_INVALID_INPUT) End If ' check if the machine name is specified using "\\" (UNC format) If Left(strMachine,2) = UNC_FORMAT_SERVERNAME_PREFIX Then If Len(strMachine) = 2 Then WScript.Echo L_InvalidInput_ErrorMessage WScript.Quit(EXIT_UNEXPECTED) End If ' remove the "\\" from the front strMachine = Mid(strMachine,3,Len(strMachine)) End If ' If password not specified with the user name, Then get it using cmdlib.wsc function If ((NOT IsEmpty(strUserName)) AND (IsEmpty(strPassword)) OR strPassword = "*") Then strPassword = component.getPassword() End If End Function '****************************************************************************** '* Function: isValidDrive '* '* Purpose: To check if the specified volume is valid or not '* '* Input: '* [in] objVols object that store the volumes specified '* [in] intMainOption the main option specified '* '* Output: Returns TRUE or FALSE '* '****************************************************************************** Function isValidDrive(ByRef objVols,ByVal intMainOption) ON ERROR RESUME NEXT Err.Clear Dim intVolumes ' to count the no.of volumes specified Dim arrVolume ' array to store the volumes specified Dim i ' Loop variable ' Initialization intVolumes = CInt(objVols.Count) arrVolume = objVols.Keys isValidDrive = FALSE i = 0 ' Check if the drive name is in correct Format [c-z]: or [C-Z]: ' This has to be checked for each Drive specified - Do While Loop Do While (i < intVolumes) ' Volumes specified are valid for all option except Query If intMainOption <> CONST_QUERY_OPTION Then ' Valid volume is either '*' OR a letter followed by a colon (total length = 2) If ((Len(arrVolume(i)) = 2) AND (InStr(arrVolume(i),chr(58)) = 2) OR arrVolume(i) = "*") Then ' check if the volume name specified is in the format ^([c-zC-Z]:|\*)$ If CInt(component.matchPattern(L_VolumePatternFormat_Text,arrVolume(i))) = CONST_NO_MATCHES_FOUND Then ' Invalid Volume Names or junk data is specified component.VBPrintf L_InvalidVolumeName_ErrorMessage, _ Array(arrVolume(i)) isValidDrive = FALSE ' remove the INVALID drive(s) objVols.Remove arrVolume(i) End If Else isValidDrive = FALSE component.VBPrintf L_InvalidVolumeName_ErrorMessage, _ Array(arrVolume(i)) objVols.Remove arrVolume(i) End If ' check the number of valid drives specified If objVols.Count = 0 Then WScript.Quit(EXIT_INVALID_INPUT) End If Else WScript.Echo(L_InvalidInput_ErrorMessage) WScript.Quit (EXIT_INVALID_INPUT) End If isValidDrive = isValidDrive OR TRUE i = i + 1 Loop End Function '****************************************************************************** '* Sub: ProcessChange '* '* Purpose: Processes the /Change option and displays the changed '* details of the page file '* '* Input: '* [in] strMachine machine to configure page files on '* [in] strUserName user name to connect to the machine '* [in] strPassword <PASSWORD> '* [in] intIntSize the initial size for the page file '* [in] intMaxSize the maximum size for the page file '* [in] objVols the object containing volume names '* '* Output: Displays error message and quits if connection fails '* '****************************************************************************** Private Sub ProcessChange( ByVal strMachine, _ ByVal strUserName, _ ByVal strPassword, _ ByVal intIntSize, _ ByVal intMaxSize, _ ByVal blnSystemManaged, _ ByVal objVols ) ON ERROR RESUME NEXT Err.Clear Dim intOldInitialSize ' to store the old intial size Dim intOldMaximumSize ' to store the old maximum size Dim arrVolume ' to store all the volumes specified Dim intVolumes ' to store the no.of volumes specified Dim strQuery ' to store the query for pagefiles Dim strQueryDisk ' to store the query for disk Dim strQueryComp ' to store the query for computersystem Dim objService ' service object Dim objInstance ' instance object Dim objInst ' instance object Dim objEnumerator ' collection set for query results Dim objEnumforDisk ' collection set for query results Dim objEnum ' collection set for query results Dim blnBothSpecified ' flag to check if both initsize & maxsize are specified Dim intFreeSpace ' to store total free space Dim intFreeDiskSpace ' to store free disk space Dim intCurrentSize ' to store the current pagefile size Dim intDiskSize ' to store the disk size for the specified disk Dim intMemSize ' to store physical memory size Dim intCrashDump ' to store the current crash dump setting value Dim strReply ' to store the user reply Dim strDriveName ' to store the drive name Dim strHostName ' to store the host name Dim intMaxSizeUB ' to store the upper bound for maximum size Dim i ' loop variable ' Establish a connection with the server. If NOT component.wmiConnect(CONST_NAMESPACE_CIMV2 , _ strUserName , _ strPassword , _ strMachine , _ blnLocalConnection, _ objService ) Then WScript.Echo(L_HintCheckConnection_Message) WScript.Quit(EXIT_METHOD_FAIL) End If ' Initialize variables i = 0 intFreeSpace = 0 intFreeDiskSpace = 0 intCurrentSize = 0 blnBothSpecified = FALSE intMaxSizeUB = 0 strQuery = "Select * From " & CLASS_PAGE_FILE_SETTING If (objVols.Exists("*")) Then Set objEnumerator = objService.ExecQuery(strQuery, "WQL", 0, null) For each objInstance in objEnumerator strDriveName = Mid(objInstance.Name,1,2) If NOT objVols.Exists (LCase(strDriveName)) Then objVols.add LCase(strDriveName), -1 End If Next objVols.remove "*" End If intVolumes = objVols.Count arrVolume = objVols.keys ' get the host Name - used to get Crash Dump Settings strQueryComp = "Select * From " & CLASS_COMPUTER_SYSTEM Set objEnum = objService.ExecQuery(strQueryComp, "WQL", 0, null) ' check for any errors If Err.Number Then Err.Clear WScript.Echo(L_UnableToRetrieveInfo_ErrorMessage) WScript.Quit(EXIT_QUERY_FAIL) End If For each objInst in objEnum If NOT ISEmpty(objInst.Name) Then strHostName = objInst.Name Else WScript.Echo(L_UnableToRetrieveInfo_ErrorMessage) WScript.Quit(EXIT_QUERY_FAIL) End If Next ' check if initsize and maxsize both are specified If (Len(intIntSize) > 0 AND Len(intMaxSize) > 0) Then blnBothSpecified = TRUE End If ' check if no page files exist on the system. strQuery = "Select * From " & CLASS_PAGE_FILE_SETTING Set objEnumerator = objService.ExecQuery(strQuery, "WQL", 0, null) If (objEnumerator.Count = 0) Then WScript.Echo(L_NoPageFiles_Message) WScript.Quit(EXIT_UNEXPECTED) End If ' release the object for re-use. Set objEnumerator = nothing Do While( i < intVolumes ) ' check if its a valid drive/volume - check from Win32_LogicalDisk strQueryDisk = "Select * From " & CLASS_LOGICAL_DISK & _ " where DriveType = " & DRIVE_TYPE & " and DeviceID = '" & arrVolume(i) & "'" Set objEnumforDisk = objService.ExecQuery(strQueryDisk, "WQL", 0, null) If objEnumforDisk.Count > 0 Then strQuery = "Select * From " & CLASS_PAGE_FILE_SETTING strQuery = strQuery & " where NAME = '" & arrVolume(i) & _ "\" & PAGEFILE_DOT_SYS & "'" Set objEnumerator = objService.ExecQuery(strQuery, "WQL", 0, null) ' check for any errors If Err.Number Then Err.Clear WScript.Echo(L_UnableToRetrieveInfo_ErrorMessage) blnFailureMsg = TRUE quitbasedonsuccess EXIT_QUERY_FAIL End If ' check if a page file exists on the specified volume If (objEnumerator.Count > 0) Then For each objInstance in objEnumerator If blnSystemManaged = TRUE Then If( objInstance.InitialSize = 0 AND objInstance.MaximumSize = 0 ) Then Component.VBPrintf L_CONST_Already_SystemManaged_Text, Array(Ucase(arrVolume(i))) blnFailureMsg = TRUE Exit For End If objInstance.InitialSize = CONST_SYSTEM_INIT_SIZE objInstance.MaximumSize = CONST_SYSTEM_MAX_SIZE objInstance.Put_(CONST_WBEM_FLAG) If Err.Number Then Err.Clear Component.VBPrintf L_CannotCreate_ErrorMessage,Array(Ucase(arrVolume(i))) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If component.VBPrintf L_ChangeSystemSuccess_message, _ Array(UCase(arrVolume(i))) blnSuccessMsg = TRUE Exit For Else strDriveName = Mid(objInstance.Name,1,2) 'If the page file was system managed, then, the user has to specify both 'initial and maximum sizes.. If (objInstance.InitialSize =0 AND objInstance.MaximumSize = 0 ) Then If Not blnBothSpecified Then component.VBPrintf L_CONST_Systemmanaged_Earlier_Text, Array(Ucase( arrVolume(i))) blnFailureMsg = TRUE Exit For End If End If If NOT blnBothSpecified Then ' check if initsize is given If (intIntSize > 0) Then ' Check if initsize is greater than 2 MB If CLng(intIntSize) >= CLng(INITIAL_SIZE_LB) Then ' check for overflows If Err.Number Then Err.Clear ' get the upper bound allowed for maximum size intMaxSizeUB = getMaxSizeUB(objService) component.VBPrintf InsufficientMaxSizeErrorMessage, _ Array( UCase(arrVolume(i)) , intMaxSizeUB ) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If ' get the drive name first strDriveName = Mid(objInstance.Name,1,2) ' get the free space available on the specified disk intFreeDiskSpace = getFreeSpaceOnDisk(strDriveName,objService) ' get the current pagefile size intCurrentSize = getCurrentPageFileSize(objService,objInstance) ' get the total free space If Len(intCurrentSize) > 0 Then intFreeSpace = intFreeDiskSpace + intCurrentSize Else WScript.Echo(L_UnableToRetrieveInfo_ErrorMessage) blnFailureMsg = TRUE quitbasedonsuccess EXIT_QUERY_FAIL End If ' Check if it is greater than free disk space If CLng(intIntSize) > CLng(intFreeSpace) Then ' check for overflows If Err.Number Then Err.Clear ' get the upper bound allowed for maximum size intMaxSizeUB = getMaxSizeUB(objService) component.VBPrintf InsufficientMaxSizeErrorMessage, _ Array( UCase(arrVolume(i)) , intMaxSizeUB ) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If component.VBPrintf NotEnoughSpaceErrorMessage, Array( UCase(arrVolume(i))) blnFailureMsg = TRUE Exit For Else If CLng(intIntSize) > CLng(intFreeSpace) - 5 Then ' check for overflows If Err.Number Then Err.Clear WScript.Echo(L_InvalidInput_ErrorMessage) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If component.VBPrintf AtLeastFiveMBErrorMessage, Array( UCase(arrVolume(i))) blnFailureMsg = TRUE Exit For Else ' only one of initsize, maxsize is specified ' check if the specified initsize is less than existing maxsize If (CInt(intIntSize) <= objInstance.MaximumSize) Then ' get the crash dump setting value intCrashDump = GetCrashDumpSetting(strUserName,strPassword,strMachine) ' get the Physical Memory Size intMemSize = GetPhysicalMemorySize(strHostName,objService) ' If the user has selected "yes" for the warning message If isCrashDumpValueSet(intCrashDump,intIntSize,intMemSize,arrVolume(i)) Then ' Check if initsize is same as the present value If (CInt(intIntSize) <> objInstance.InitialSize) Then ' store the old initsize value intOldInitialSize = objInstance.InitialSize ' set the new initsize objInstance.InitialSize = intIntSize objInstance.Put_(CONST_WBEM_FLAG) If Err.Number Then Err.Clear WScript.Echo(L_UpdateFailed_ErrorMessage) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If component.VBPrintf ChangeIntSuccessMessage, _ Array(UCase(arrVolume(i)),CInt(intOldInitialSize),CInt(intIntSize)) blnSuccessMsg = TRUE Exit For Else component.VBPrintf ChangeIntSkippingMessage, Array(UCase(arrVolume(i))) blnFailureMsg = TRUE Exit For End If ' If User chooses No for CrashDumpSetting prompt Else ' Do Nothing just continue looping Exit For End If Else ' get the upper bound allowed for maximum size intMaxSizeUB = getMaxSizeUB(objService) component.VBPrintf InsufficientMaxSizeErrorMessage, _ Array( UCase(arrVolume(i)) , intMaxSizeUB ) blnFailureMsg = TRUE Exit For End If End If End If Else ' get the upper bound allowed for maximum size intMaxSizeUB = getMaxSizeUB(objService) component.VBPrintf InitialSizeRangeErrorMessage, _ Array(intMaxSizeUB, UCase(arrVolume(i))) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If Else ' Check if initsize specified as 0 If Len(intIntSize) > 0 Then ' get the upper bound allowed for maximum size intMaxSizeUB = getMaxSizeUB(objService) component.VBPrintf InitialSizeRangeErrorMessage, _ Array(intMaxSizeUB, UCase(arrVolume(i))) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If End If ' initsize checked ' check if maxsize is given If (intMaxSize > 0) Then ' get the free space available on the specified disk intFreeDiskSpace = getFreeSpaceOnDisk(strDriveName,objService) ' get the current pagefile size intCurrentSize = getCurrentPageFileSize(objService,objInstance) ' get the total free space If Len(intCurrentSize) > 0 Then intFreeSpace = intFreeDiskSpace + intCurrentSize Else WScript.Echo(L_UnableToRetrieveInfo_ErrorMessage) blnFailureMsg = TRUE quitbasedonsuccess EXIT_QUERY_FAIL End If ' Get the Disk Size for the specified drive intDiskSize = GetDiskSize(arrVolume(i),objService) ' check if maxsize is more than initsize If (CLng(intMaxSize) > CLng(intDiskSize)) Then ' check for overflows If Err.Number Then Err.Clear ' get the upper bound allowed for maximum size intMaxSizeUB = getMaxSizeUB(objService) component.VBPrintf InsufficientMaxSizeErrorMessage, _ Array( UCase(arrVolume(i)) , intMaxSizeUB ) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If component.VBPrintf DiskTooSmallErrorMessage, Array(UCase(arrVolume(i))) blnFailureMsg = TRUE Exit For Else If (CLng(intMaxSize) > CLng(intFreeSpace)) Then ' check for overflows If Err.Number Then Err.Clear WScript.Echo(L_InvalidInput_ErrorMessage) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If component.VBPrintf GrowsToFreeSpaceWarningMessage, _ Array(UCase(arrVolume(i)),intFreeSpace) strReply = getReply() If Trim(LCase(strReply)) = L_UserReplyYes_Text Then ' set the maxsize to be the free space on disk intMaxSize = intFreeSpace ' check if the given maxsize is greater than the existing initial size. If (CInt(intMaxSize) >= objInstance.InitialSize) Then If (CInt(intMaxSize) <> objInstance.MaximumSize) Then intOldMaximumSize = objInstance.MaximumSize objInstance.MaximumSize = intMaxSize objInstance.Put_(CONST_WBEM_FLAG) If Err.Number Then Err.Clear WScript.Echo(L_UpdateFailed_ErrorMessage) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If component.VBPrintf ChangeMaxSuccessMessage, _ Array(UCase(arrVolume(i)),CInt(intOldMaximumSize),CInt(intMaxSize)) blnSuccessMsg = TRUE Exit For Else component.VBPrintf ChangeMaxSkippingMessage, Array(UCase(arrVolume(i))) blnFailureMsg = TRUE Exit For End If Else ' get the upper bound allowed for maximum size intMaxSizeUB = getMaxSizeUB(objService) component.VBPrintf InsufficientMaxSizeErrorMessage, _ Array( UCase(arrVolume(i)) , intMaxSizeUB ) blnFailureMsg = TRUE Exit For End If ElseIf LCase(strReply) = L_UserReplyNo_Text Then ' Do Nothing continue with other drives Exit For Else WScript.Echo(L_InvalidInput_ErrorMessage) blnFailureMsg = TRUE ' Continue looping Exit For End If Else If (CInt(intMaxSize) >= objInstance.InitialSize) Then If (CInt(intMaxSize) <> objInstance.MaximumSize) Then intOldMaximumSize = objInstance.MaximumSize objInstance.MaximumSize = intMaxSize objInstance.Put_(CONST_WBEM_FLAG) If Err.Number Then Err.Clear WScript.Echo(L_UpdateFailed_ErrorMessage) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If component.VBPrintf ChangeMaxSuccessMessage, _ Array(UCase(arrVolume(i)),CInt(intOldMaximumSize),CInt(intMaxSize)) blnSuccessMsg = TRUE Exit For Else component.VBPrintf ChangeMaxSkippingMessage, Array(UCase(arrVolume(i))) blnFailureMsg = TRUE Exit For End If Else ' get the upper bound allowed for maximum size intMaxSizeUB = getMaxSizeUB(objService) component.VBPrintf InsufficientMaxSizeErrorMessage, _ Array( UCase(arrVolume(i)) , intMaxSizeUB ) blnFailureMsg = TRUE Exit For End If End If End If Else ' Check if maxsize specified as 0 If Len(intMaxSize) > 0 Then ' get the upper bound allowed for maximum size intMaxSizeUB = getMaxSizeUB(objService) component.VBPrintf InsufficientMaxSizeErrorMessage, _ Array( UCase(arrVolume(i)) , intMaxSizeUB ) blnFailureMsg = TRUE Exit For End If End If ' maxsize checked Else ' Case when both initsize and maxsize are selected ' check if maxsize is greater than initsize ' this will detect any overflow problems, if any If CLng(intIntSize) > CLng(intMaxSize) Then ' check for overflows and clear the error If Err.Number Then Err.Clear ' get the upper bound allowed for maximum size intMaxSizeUB = getMaxSizeUB(objService) component.VBPrintf InsufficientMaxSizeErrorMessage, _ Array( UCase(arrVolume(i)) , intMaxSizeUB ) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If If (intIntSize > 0) Then ' Check if initsize is greater than 2 MB If CLng(intIntSize) >= CLng(INITIAL_SIZE_LB) Then ' check for overflows If Err.Number Then Err.Clear ' get the upper bound allowed for maximum size intMaxSizeUB = getMaxSizeUB(objService) component.VBPrintf InsufficientMaxSizeErrorMessage, _ Array( UCase(arrVolume(i)) , intMaxSizeUB ) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If ' get the free space available on the specified disk intFreeDiskSpace = getFreeSpaceOnDisk(strDriveName,objService) ' get the current pagefile size intCurrentSize = getCurrentPageFileSize(objService,objInstance) ' get the total free space If Len(intCurrentSize) > 0 Then intFreeSpace = intFreeDiskSpace + intCurrentSize Else WScript.Echo(L_UnableToRetrieveInfo_ErrorMessage) blnFailureMsg = TRUE quitbasedonsuccess EXIT_QUERY_FAIL End If ' check if it is greater than free disk space If CLng(intIntSize) > CLng(intFreeSpace) Then ' check for overflows If Err.Number Then Err.Clear ' get the upper bound allowed for maximum size intMaxSizeUB = getMaxSizeUB(objService) component.VBPrintf InsufficientMaxSizeErrorMessage, _ Array( UCase(arrVolume(i)) , intMaxSizeUB ) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If component.VBPrintf NotEnoughSpaceErrorMessage, Array( UCase(arrVolume(i))) blnFailureMsg = TRUE Exit For End If If CLng(intIntSize) > CLng(intFreeSpace) - 5 Then ' check for overflows If Err.Number Then Err.Clear WScript.Echo(L_InvalidInput_ErrorMessage) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If component.VBPrintf AtLeastFiveMBErrorMessage, Array( UCase(arrVolume(i))) blnFailureMsg = TRUE Exit For Else ' get the crash dump setting value intCrashDump = GetCrashDumpSetting(strUserName,strPassword,strMachine) ' get the Physical Memory Size intMemSize = GetPhysicalMemorySize(strHostName,objService) ' If the user has selected "yes" for the warning message If isCrashDumpValueSet(intCrashDump,intIntSize,intMemSize,arrVolume(i)) Then ' store the old initsize value intOldInitialSize = objInstance.InitialSize ' set the new initsize objInstance.InitialSize = intIntSize ' check if maxsize is given If (intMaxSize > 0) Then ' Get the Disk Size for the specified drive intDiskSize = GetDiskSize(arrVolume(i),objService) ' check if maxsize is more than initsize If (CLng(intMaxSize) > CLng(intDiskSize)) Then ' check for overflows If Err.Number Then Err.Clear ' get the upper bound allowed for maximum size intMaxSizeUB = getMaxSizeUB(objService) component.VBPrintf InsufficientMaxSizeErrorMessage, _ Array( UCase(arrVolume(i)) , intMaxSizeUB ) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If component.VBPrintf DiskTooSmallErrorMessage, _ Array(UCase(arrVolume(i))) blnFailureMsg = TRUE Exit For Else If (CLng(intMaxSize) > CLng(intFreeSpace)) Then ' check for overflows If Err.Number Then Err.Clear WScript.Echo(L_InvalidInput_ErrorMessage) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If component.VBPrintf GrowsToFreeSpaceWarningMessage, _ Array(UCase(arrVolume(i)),intFreeSpace) strReply = getReply() If Trim(LCase(strReply)) = L_UserReplyYes_Text Then ' set the maxsize to be the free space on disk intMaxSize = intFreeSpace intOldMaximumSize = objInstance.MaximumSize objInstance.MaximumSize = intMaxSize If ( CInt(intIntSize) <> intOldInitialSize ) Then objInstance.Put_(CONST_WBEM_FLAG) If Err.Number Then Err.Clear WScript.Echo(L_UpdateFailed_ErrorMessage) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If component.VBPrintf ChangeIntSuccessMessage, _ Array(UCase(arrVolume(i)),CInt(intOldInitialSize),CInt(intIntSize)) blnSuccessMsg = TRUE Else component.VBPrintf ChangeIntSkippingMessage, _ Array(UCase(arrVolume(i))) blnFailureMsg = TRUE End If If (CInt(intMaxSize) <> intOldMaximumSize) Then objInstance.Put_(CONST_WBEM_FLAG) If Err.Number Then Err.Clear WScript.Echo(L_UpdateFailed_ErrorMessage) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If component.VBPrintf ChangeMaxSuccessMessage, _ Array(UCase(arrVolume(i)),CInt(intOldMaximumSize),CInt(intMaxSize)) blnSuccessMsg = TRUE Exit For Else component.VBPrintf ChangeMaxSkippingMessage, _ Array(UCase(arrVolume(i))) blnFailureMsg = TRUE Exit For End If ElseIf LCase(strReply) = L_UserReplyNo_Text Then Exit For Else WScript.Echo(L_InvalidInput_ErrorMessage) blnFailureMsg = TRUE Exit For End If Else intOldMaximumSize = objInstance.MaximumSize objInstance.MaximumSize = intMaxSize objInstance.Put_(CONST_WBEM_FLAG) If Err.Number Then Err.Clear WScript.Echo(L_UpdateFailed_ErrorMessage) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If If (CInt(intIntSize) <> intOldInitialSize ) Then component.VBPrintf ChangeIntSuccessMessage, _ Array(UCase(arrVolume(i)),CInt(intOldInitialSize),CInt(intIntSize)) blnSuccessMsg = TRUE Else component.VBPrintf ChangeIntSkippingMessage, Array(UCase(arrVolume(i))) blnFailureMsg = TRUE End If If (CInt(intMaxSize) <> intOldMaximumSize) Then component.VBPrintf ChangeMaxSuccessMessage, _ Array(UCase(arrVolume(i)),CInt(intOldMaximumSize),CInt(intMaxSize)) blnSuccessMsg = TRUE Exit For Else component.VBPrintf ChangeMaxSkippingMessage, Array(UCase(arrVolume(i))) blnFailureMsg = TRUE Exit For End If End If End If Else ' Check if maxsize specified as 0 If Len(intMaxSize) > 0 Then ' get the upper bound allowed for maximum size intMaxSizeUB = getMaxSizeUB(objService) component.VBPrintf InsufficientMaxSizeErrorMessage, _ Array( UCase(arrVolume(i)) , intMaxSizeUB ) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If End If ' maxsize checked End If End If Else ' get the upper bound allowed for maximum size intMaxSizeUB = getMaxSizeUB(objService) component.VBPrintf InitialSizeRangeErrorMessage, _ Array(intMaxSizeUB, UCase(arrVolume(i))) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If Else ' Check if initsize specified as 0 If Len(intIntSize) > 0 Then ' get the upper bound allowed for maximum size intMaxSizeUB = getMaxSizeUB(objService) component.VBPrintf InitialSizeRangeErrorMessage, _ Array(intMaxSizeUB, UCase(arrVolume(i))) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If End If ' initsize checked End If End If Next Else component.VBPrintf L_PageFileDoesNotExist_ErrorMessage, _ Array(UCase(arrVolume(i))) blnFailureMsg = TRUE End If Else ' the drive does not exist component.VBPrintf L_InvalidVolumeName_ErrorMessage, _ Array(UCase(arrVolume(i))) blnFailureMsg = TRUE ' remove the drive name from the valid drives list objVols.Remove arrVolume(i) ' decrement the loop count i = i - 1 ' check for the no.of valid drive names from the specified list. If Cint(objVols.Count) = 0 Then blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT Else intVolumes = objVols.Count arrVolume = objVols.keys End If End If i = i + 1 Loop If blnSuccessMsg = TRUE then WScript.Echo L_RestartComputer_Message End If If blnFailureMsg = TRUE Then If blnSuccessMsg = TRUE Then Wscript.Quit( EXIT_PARTIAL_SUCCESS) else Wscript.Quit( EXIT_INVALID_INPUT) End If End If End Sub '****************************************************************************** '* Sub: ProcessCreate '* '* Purpose: Creates new page files with the given specifications '* '* Input: '* [in] strMachine machine to configure page files on '* [in] strUserName user name to connect to the machine '* [in] strPassword <PASSWORD> '* [in] intIntSize the initial size for the page file '* [in] intMaxSize the maximum size for the page file '* [in] objVols the object containing volume names '* '* Output: Displays error message and quits if connection fails '* '****************************************************************************** Private Sub ProcessCreate( ByVal strMachine, _ ByVal strUserName, _ ByVal strPassword, _ ByVal intIntSize, _ ByVal intMaxSize, _ ByVal blnSystemManaged, _ ByVal objVols ) ON ERROR RESUME NEXT Err.Clear Dim arrVolume ' to store all the volumes specified Dim intVolumes ' to store the no.of volumes specified Dim strQuery ' to store the query for pagefiles Dim strQueryDisk ' to store the query for disk Dim strQueryComp ' to store the query for getting host name Dim objService ' service object Dim objInst ' instance object Dim objInstance ' instance object Dim objEnum ' collection object for query results Dim objEnumforDisk ' collection object for query results Dim strHostName ' to store the host name Dim i ' Loop variable ' variables used only if * is specified Dim objEnumerator ' collection object for query results i = 0 If NOT component.wmiConnect(CONST_NAMESPACE_CIMV2 , _ strUserName , _ strPassword , _ strMachine , _ blnLocalConnection , _ objService ) Then WScript.Echo(L_HintCheckConnection_Message) WScript.Quit(EXIT_METHOD_FAIL) End If If (objVols.Exists("*")) Then ' build the query intVolumes = 0 ' get all the drive names with drive type = 3 (other than floppy drive & CDROM Drive) strQuery = "Select DeviceID From " & CLASS_LOGICAL_DISK & _ " where DriveType = " & DRIVE_TYPE ' execute the query Set objEnumerator = objService.ExecQuery(strQuery, "WQL", 48, null) ' check for any errors If Err.Number Then Err.Clear WScript.Echo(L_UnableToRetrieveInfo_ErrorMessage) WScript.Quit(EXIT_QUERY_FAIL) End If For each objInstance in objEnumerator ' check if the volumename is not an alias name and neither a mapped drive. If IsValidPhysicalDrive(objService, objInstance.DeviceID) Then ' check if the volume name is specified more than once. If NOT objVols.Exists(LCase(objInstance.DeviceID)) Then objVols.Add LCase(objInstance.DeviceID),-1 End If End If Next ' Remove * from objVols after adding the drives to the object. objVols.Remove "*" End If intVolumes = objVols.Count arrVolume = objVols.Keys ' Get the host Name - used to get Crash Dump Settings strQueryComp = "Select * From " & CLASS_COMPUTER_SYSTEM Set objEnum = objService.ExecQuery(strQueryComp, "WQL", 0, null) ' check for any errors If Err.Number Then Err.Clear WScript.Echo(L_UnableToRetrieveInfo_ErrorMessage) WScript.Quit(EXIT_QUERY_FAIL) End If For each objInst in objEnum If NOT ISEmpty(objInst.Name) Then strHostName = objInst.Name Else WSCript.Echo(L_UnableToRetrieveInfo_ErrorMessage) WScript.Quit(EXIT_QUERY_FAIL) End If Next ' No wild Cards Specified Do While( i < intVolumes ) strQueryDisk = "Select * From " & CLASS_LOGICAL_DISK & _ " where DriveType = " & DRIVE_TYPE & " and DeviceID = '" & arrVolume(i) & "'" Set objEnumforDisk = objService.ExecQuery(strQueryDisk, "WQL", 0, null) strQuery = "Select * From " & CLASS_PAGE_FILE_SETTING & _ " where Name = '" & arrVolume(i) & "\" & PAGEFILE_DOT_SYS & "'" Set objEnum = objService.ExecQuery(strQuery, "WQL", 0, null) ' If valid drive and pagefile exists on that drive If (objEnumforDisk.Count = 0 AND objEnum.Count = 0 ) Then ' the drive does not exist component.VBPrintf L_InvalidVolumeName_ErrorMessage, _ Array(UCase(arrVolume(i))) bFailureMsg = TRUE ' remove the drive name from the valid drives list objVols.Remove arrVolume(i) ' decrement the loop count i = i - 1 ' check for the no.of valid drive names from the specified list. If Cint(objVols.Count) = 0 Then blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT Else intVolumes = objVols.Count arrVolume = objVols.keys End If Else ' SKIP - if at least one instance is found then dont create a new instance If (objEnumforDisk.Count = 1 AND objEnum.Count = 1) Then component.VBPrintf L_CreateSkipping_Message, _ Array(UCase(arrVolume(i))) blnFailureMsg = TRUE Else ' check if the volumename is an alias name or a mapped drive If NOT IsValidPhysicalDrive(objService, arrVolume(i)) Then component.VBPrintf L_InvalidPhysicalDrive_ErrorMessage, _ Array(UCase(arrVolume(i))) blnFailureMsg = TRUE Else CreatePageFile objService, arrVolume, blnSystemManaged, _ intIntSize, intMaxSize, strMachine, strUserName, _ strPassword, strHostName, i End If End If End If i = i + 1 Loop ' Prompt for reboot if atleast one operation is successful If blnSuccessMsg = TRUE then WScript.Echo L_RestartComputer_Message End If ' DEcide on the return level. If atleast one succeds, return partial success.. If all fails return complete failure If blnFailureMsg = TRUE Then If blnSuccessMsg = TRUE Then Wscript.Quit( EXIT_PARTIAL_SUCCESS) else Wscript.Quit( EXIT_INVALID_INPUT) End If End If End Sub '************************************************************************************************** '* sub: CreatePageFile '* '* Purpose: Creates new page file on a specified drive at the specified index '* '* INPUT: '* '* [IN] objService The WMI service object '* [IN] arrVolume Array of volumes to create the page files on '* [IN] blnSystemManaged Indicates whether the drive has to be system managed '* [IN] intIntSize Indicates the InitialSize '* [IN] intMaxSize Indicates the Maximum Size '* [IN] strMachine The system to connect to '* [IN] strUserName User name '* [IN] strPassword Password '* [IN] strHostName The host name for the remote machine '* [IN] i The index of the drive name in arrVolume to create the page file '* '************************************************************************************************** Private Sub CreatePageFile(ByVal objService, _ ByVal arrVolume, _ ByVal blnSystemManaged, _ ByVal intIntSize, _ ByVal intMaxSize, _ ByVal strMachine, _ ByVal strUserName, _ ByVal strPassword, _ ByVal strHostName, _ BYVal i) ON ERROR RESUME NEXT Dim objInstance ' instance object Dim objNewInstance ' instance object Dim intFreeSpace ' to store total free space Dim intFreeDiskSpace ' to store free disk space Dim intCurrentSize ' to store the current pagefile size Dim intDiskSize ' to store the disk size for the specified disk Dim intMemSize ' to store physical memory size Dim intCrashDump ' to store the current crash dump setting value Dim strReply ' to store the user reply Dim intMaxSizeUB ' to store the upper bound for maximum size intFreeSpace = 0 intFreeDiskSpace = 0 intCurrentSize = 0 intMaxSizeUB = 0 Err.Clear ' set the security privilege to allow pagefile creation objService.Security_.Privileges.AddAsString("SeCreatePagefilePrivilege") If Err.Number then Err.Clear WScript.Echo("ERROR: Failed to set the security privilege.") blnFailureMsg = TRUE quitbasedonsuccess EXIT_METHOD_FAIL End If Set objInstance = objService.Get(CLASS_PAGE_FILE_SETTING) ' check for any errors If Err.Number Then Err.Clear Component.VBPrintf L_CannotCreate_ErrorMessage,Array(Ucase(arrVolume(i))) blnFailureMsg = TRUE quitbasedonsuccess EXIT_METHOD_FAIL End If Set objNewInstance = objInstance.SpawnInstance_ ' check for any errors If Err.Number Then Err.Clear Component.VBPrintf L_CannotCreate_ErrorMessage,Array(Ucase(arrVolume(i))) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If ' append the filename to the volume name objNewInstance.Name = UCase(arrVolume(i)) & PAGEFILE_DOT_SYS 'Check if the page file has to be managed by the system If blnSystemManaged = TRUE Then objNewInstance.InitialSize = CONST_SYSTEM_INIT_SIZE objNewInstance.MaximumSize = CONST_SYSTEM_MAX_SIZE objNewInstance.Put_(CONST_WBEM_FLAG) If Err.Number Then Err.Clear Component.VBPrintf L_CannotCreate_ErrorMessage,Array(Ucase(arrVolume(i))) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If component.VBPrintf L_CreateSystemSuccess_message, _ Array(UCase(arrVolume(i))) blnSuccessMsg = TRUE ' If not System managed Else ' check if maxsize is greater than initsize ' this will detect any overflow problems, if any If ( CLng(intIntSize) > CLng(intMaxSize) ) Then ' check for overflows and clear the error If Err.Number Then Err.Clear ' get the upper bound allowed for maximum size intMaxSizeUB = getMaxSizeUB(objService) component.VBPrintf InsufficientMaxSizeErrorMessage, _ Array( UCase(arrVolume(i)) , intMaxSizeUB ) blnFailureMsg = TRUE Exit Sub End If ' Check the initial size with the free space on the disk If CLng(intIntSize) >= CLng(INITIAL_SIZE_LB) Then ' check for overflows If Err.Number Then Err.Clear WScript.Echo(L_InvalidInput_ErrorMessage) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If ' get the free space on the specified disk intFreeDiskSpace = getFreeSpaceOnDisk(arrVolume(i),objService) ' get the total free space Since its a new instane the current size willNOT be available. So the initial size is taken into considerarion for calculating the total free space. intFreeSpace = intFreeDiskSpace ' Check if it greater than free disk space If CLng(intIntSize) > CLng(intFreeSpace) Then ' check for overflows If Err.Number Then Err.Clear WScript.Echo(L_InvalidInput_ErrorMessage) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If component.VBPrintf NotEnoughSpaceErrorMessage, Array( UCase(arrVolume(i))) blnFailureMsg = TRUE Exit Sub End If If CLng(intIntSize) > CLng(intFreeSpace) - 5 Then ' check for overflows If Err.Number Then Err.Clear WScript.Echo(L_InvalidInput_ErrorMessage) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If component.VBPrintf AtLeastFiveMBErrorMessage, Array( UCase(arrVolume(i))) blnFailureMsg = TRUE Exit Sub End If ' get the crash dump setting value intCrashDump = GetCrashDumpSetting(strUserName,strPassword,strMachine) ' get the Physical Memory Size intMemSize = GetPhysicalMemorySize(strHostName,objService) ' check if the user has selected "yes" for the warning message If isCrashDumpValueSet(intCrashDump,intIntSize,intMemSize,arrVolume(i)) Then objNewInstance.InitialSize = CInt(intIntSize) ' Get the Disk Size for the specified drive intDiskSize = GetDiskSize(arrVolume(i),objService) If (CLng(intMaxSize) > CLng(intDiskSize)) Then ' check for overflows If Err.Number Then Err.Clear ' get the upper bound allowed for maximum size intMaxSizeUB = getMaxSizeUB(objService) component.VBPrintf InsufficientMaxSizeErrorMessage, _ Array( UCase(arrVolume(i)) , intMaxSizeUB ) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If component.VBPrintf DiskTooSmallErrorMessage, _ Array(UCase(arrVolume(i))) blnFailureMsg = TRUE Exit Sub ElseIf (CLng(intMaxSize) > CLng(intFreeSpace)) Then ' check for overflows If Err.Number Then Err.Clear WScript.Echo(L_InvalidInput_ErrorMessage) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If component.VBPrintf GrowsToFreeSpaceWarningMessage, _ Array(UCase(arrVolume(i)),intFreeSpace) strReply = getReply() If Trim(LCase(strReply)) = L_UserReplyYes_Text Then ' maxsize can grow only to the free disk space available. ' set the maxsize to the free space on disk. intMaxSize = intFreeSpace objNewInstance.MaximumSize = intMaxSize objNewInstance.Put_(CONST_WBEM_FLAG) If Err.Number Then Err.Clear Component.VBPrintf L_CannotCreate_ErrorMessage,Array(Ucase(arrVolume(i))) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If component.VBPrintf CreateSuccessMessage, _ Array(CInt(intIntSize),CInt(intMaxSize),UCase(arrVolume(i))) blnSuccessMsg = TRUE ElseIf LCase(strReply) = L_UserReplyNo_Text Then Exit Sub Else WScript.Echo(L_InvalidInput_ErrorMessage) blnFailureMsg = TRUE Exit Sub End If Else objNewInstance.MaximumSize = CInt(intMaxSize) objNewInstance.Put_(CONST_WBEM_FLAG) If Err.Number Then Err.Clear Component.VBPrintf L_CannotCreate_ErrorMessage,Array(Ucase(arrVolume(i))) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If component.VBPrintf CreateSuccessMessage, _ Array(CInt(intIntSize),CInt(intMaxSize),UCase(arrVolume(i))) blnSuccessMsg = TRUE End If End If 'End of IsCrashDumpset Else 'If initial size is less than 2 MB ' get the upper bound allowed for maximum size intMaxSizeUB = getMaxSizeUB(objService) component.VBPrintf InitialSizeRangeErrorMessage, _ Array(intMaxSizeUB, UCase(arrVolume(i))) blnFailureMsg = TRUE End If End If ' End of system managed If condition End Sub '****************************************************************************** '* Sub: ProcessDelete '* '* Purpose: Deletes existing page files on the specified volumes '* '* Input: '* [in] strMachine machine to configure page files on '* [in] strUserName user name to connect to the machine '* [in] strPassword <PASSWORD> '* [in] objVols the object containing volume names '* '* Output: Displays error message and quits if connection fails '* '****************************************************************************** Private Sub ProcessDelete ( ByVal strMachine, _ ByVal strUserName, _ ByVal strPassword, _ ByVal blnSystemManaged, _ ByVal objVols ) ON ERROR RESUME NEXT Err.Clear Dim arrVolume ' to store all the volumes specified Dim intVolumes ' to store the no.of volumes specified Dim objService ' service object Dim objInstance ' instance object Dim strQueryDisk ' to store the query for disk Dim objEnumforDisk ' collection object for query results Dim intMemSize ' to store physical memory size Dim intCrashDump ' to store the current crash dump setting value Dim strQueryComp ' to store the query for computersystem Dim objEnum ' collection object for query results Dim objInst ' instance object Dim strHostName ' to store the host name Dim i ' Loop variable Dim strQueryPageFile ' to store the query for pagefiles Dim objEnumPageFile ' collection object for pagefiles ' Establish connection to WMI to get pagefile info If NOT component.wmiConnect(CONST_NAMESPACE_CIMV2 , _ strUserName , _ strPassword , _ strMachine , _ blnLocalConnection , _ objService ) Then WScript.Echo(L_HintCheckConnection_Message) WScript.Quit(EXIT_METHOD_FAIL) End If i = 0 intVolumes = objVols.Count arrVolume = objVols.Keys ' Get the host Name - used to get Crash Dump Settings strQueryComp = "Select * From " & CLASS_COMPUTER_SYSTEM Set objEnum = objService.ExecQuery(strQueryComp, "WQL", 0, null) ' check for any errors If Err.Number Then Err.Clear WScript.Echo(L_UnableToRetrieveInfo_ErrorMessage) WScript.Quit(EXIT_QUERY_FAIL) End If For each objInst in objEnum If NOT ISEmpty(objInst.Name) Then strHostName = objInst.Name Else WSCript.Echo(L_UnableToRetrieveInfo_ErrorMessage) WScript.Quit(EXIT_QUERY_FAIL) End If Next Do While( i < intVolumes ) strQueryDisk = "Select * From " & CLASS_LOGICAL_DISK & _ " where DriveType = " & DRIVE_TYPE & " and DeviceID = '" & arrVolume(i) & "'" Set objEnumforDisk = objService.ExecQuery(strQueryDisk, "WQL", 0, null) If objEnumforDisk.Count > 0 Then Set objInstance = objService.Get(CLASS_PAGE_FILE_SETTING & "='" & _ arrVolume(i) & PAGEFILE_DOT_SYS & "'") If Err.Number Then Err.Clear component.VBPrintf L_PageFileDoesNotExist_ErrorMessage, _ Array(UCase(arrVolume(i))) blnFailureMsg = TRUE Else intCrashDump = GetCrashDumpSetting(strUserName,strPassword,strMachine) ' get the Physical Memory Size intMemSize = GetPhysicalMemorySize(strHostName,objService) ' If the user has selected "yes" for the warning message ' pass initsize as 0 because initsize = maxsize = 0 (assumed) after deletion If isCrashDumpValueSet(intCrashDump,0,intMemSize,arrVolume(i)) Then strQueryPageFile = "Select * from " & CLASS_PAGE_FILE_SETTING Set objEnumPageFile = objService.ExecQuery(strQueryPageFile, "WQL", 0, null) If objEnumPageFile.Count > 1 Then ' Delete the instance objInstance.Delete_ ' check for any errors If Err.Number Then Err.Clear WScript.Echo(L_InvalidInput_ErrorMessage) blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT End If component.VBPrintf L_DeleteSuccess_Message, _ Array(UCase(arrVolume(i))) blnSuccessMsg = TRUE Else component.VBPrintf CannotDeleteErrorMessage, _ Array(UCase(arrVolume(i))) blnFailureMsg = TRUE End If End If End If Else ' the drive does not exist component.VBPrintf L_InvalidVolumeName_ErrorMessage, _ Array(UCase(arrVolume(i))) blnFailureMsg = TRUE ' remove the drive name from the valid drives list objVols.Remove arrVolume(i) ' decrement the loop count i = i - 1 ' check for the no.of valid drive names from the specified list. If Cint(objVols.Count) = 0 Then blnFailureMsg = TRUE quitbasedonsuccess EXIT_INVALID_INPUT Else intVolumes = objVols.Count arrVolume = objVols.keys End If End If i = i + 1 Loop ' The instances of the following classes are also deleted along with the Win32_PageFile instances ' Win32_PageFileUsage - instances are deleted only after reboot ' Win32_PageFileSetting - instances are deleted automatically along with Win32_PageFile instances If blnSuccessMsg = TRUE then WScript.Echo L_RestartComputer_Message End If ' DEcide on the return level. If atleast one succeds, return partial success.. If all fails return complete failure If blnFailureMsg = TRUE Then If blnSuccessMsg = TRUE Then Wscript.Quit( EXIT_PARTIAL_SUCCESS) else Wscript.Quit( EXIT_INVALID_INPUT) End If End If End sub '****************************************************************************** '* Sub: ProcessQuery '* '* Purpose: Displays the Page File Details in the specified format '* '* Input: '* [in] strMachine machine to configure page files on '* [in] strUserName user name to connect to the machine '* [in] strPassword password for the <PASSWORD> '* [in] strFormat the query display format '* [in] blnNoHeader flag to store if -nh is specified or not '* '* Output: Displays error message and quits if connection fails '* Calls component.showResults() to display the page file '* details '* '****************************************************************************** Private Sub ProcessQuery( ByVal strMachine, _ ByVal strUserName, _ ByVal strPassword, _ ByVal strFormat, _ ByVal blnSystemManaged, _ ByVal blnNoHeader ) ON ERROR RESUME NEXT Err.Clear Dim objEnumerator ' to store the results of the query is executed Dim objInstance ' to refer to the instances of the objEnumerator Dim strQuery ' to store the query obtained for given conditions Dim intTotSize ' to store the total size on all drives Dim intRecommendedSize ' to store the recommended size for all drives Dim arrResultsDrives ' to store the columns of page file info. Dim arrHeaderDrives ' to store the array header values Dim arrMaxLengthDrives ' to store the maximum length for each column Dim arrFinalResultsDrives ' used to send the arrResults to ShowResults() Dim intColumnCountDrives ' number of columns to be displayed in the output Dim blnPrintHeaderDrives ' variable which decides whether header is to be displayed or not Dim arrResultsSummary ' to store the columns of page file info. Dim arrHeaderSummary ' to store the array header values Dim arrMaxLengthSummary ' to store the maximum length for each column Dim arrFinalResultsSummary ' used to send the arrResults to ShowResults() Dim intColumnCountSummary ' number of columns to be displayed in the output Dim blnPrintHeaderSummary ' variable which decides whether header is to be displayed or not Dim objDiskDriveInstance ' Instance for drive name Dim objMemSizeInstance ' Instance for memory size Dim arrblnNoDisplayDrives ' boolean variable for -noheader option Dim arrblnNoDisplaySummary ' boolean variable for -noheader option Dim objService ' service object Dim strDriveName ' to store the drive name Dim objUsageInstance ' Instance for PageFileUsage ' Initializing the blnPrintHeaders to true. Header should be printed by default blnPrintHeaderDrives = TRUE blnPrintHeaderSummary = TRUE intTotSize = 0 If blnNoHeader Then blnPrintHeaderDrives = FALSE blnPrintHeaderSummary = FALSE End If ' Establish connection to WMI to get pagefile information If NOT component.wmiConnect(CONST_NAMESPACE_CIMV2 , _ strUserName , _ strPassword , _ strMachine , _ blnLocalConnection , _ objService ) Then WScript.Echo(L_HintCheckConnection_Message) WScript.Quit(EXIT_METHOD_FAIL) End If arrHeaderDrives = Array(L_ColHeaderHostname_Text , L_ColHeaderDrive_Text, _ L_ColHeaderVolumeLabel_Text, L_ColHeaderFileName_Text, _ L_ColHeaderInitialSize_Text, L_ColHeaderMaximumSize_Text, _ L_ColHeaderCurrentSize_Text, L_ColHeaderFreeSpace_Text,_ L_ColHeaderPageFileStatus_Text) arrHeaderSummary = Array(L_ColHeaderHostname_Text, L_ColHeaderTotalMinimumSize_Text, _ L_ColHeaderTotalRecommendedSize_Text, L_ColHeaderTotalSize_Text) ' Data Lengths = (15,13,13,19,20,20,20,22) arrMaxLengthDrives = Array(L_CONST_HOSTNAME_Length_Text, L_CONST_DRIVENAME_Length_Text, L_CONST_VOLLABEL_Length_Text, _ L_CONST_PAGEFILENAME_Length_Text, L_CONST_INTSIZE_Length_Text, L_CONST_MAXSIZE_Length_Text, _ L_CONST_CURRENTSIZE_Length_Text, L_CONST_FREESPACE_Length_Text, _ L_ColHeaderPageFileStatusLength_Text) ' Data Lengths = (15,33,37,40) arrMaxLengthSummary = Array(L_CONST_HOSTNAME_Length_Text, L_CONST_TOTALMINSIZE_Length_Text,_ L_CONST_TOTALRECSIZE_Length_Text, L_CONST_TOTALSIZE_Length_Text) arrblnNoDisplayDrives = Array(0,0,0,0,0,0,0,0,0) arrblnNoDisplaySummary = Array(0,0,0,0) ' first initialize the array with N/A arrResultsDrives = Array(L_Na_Text,L_Na_Text,L_Na_Text,L_Na_Text,L_Na_Text,L_Na_Text,_ L_Na_Text,L_Na_Text, L_Na_Text) arrResultsSummary = Array(L_Na_Text,L_Na_Text,L_Na_Text,L_Na_Text) ' build the query strQuery = "SELECT * FROM " & CLASS_PAGE_FILE_SETTING ' execute the query Set objEnumerator = objService.ExecQuery(strQuery, "WQL", 0, null) ' check for any errors If Err.Number Then Err.Clear WScript.Echo(L_UnableToRetrieveInfo_ErrorMessage) WScript.Quit(EXIT_QUERY_FAIL) End If ' If no.of pagefile instances are 0 (zero) If (objEnumerator.Count = 0) Then WScript.Echo(L_NoPageFiles_Message) WScript.Quit(EXIT_UNEXPECTED) End If ReDim arrFinalResultsDrives(0) ReDim arrFinalResultsSummary(0) If(LCase(strFormat) <> "csv") Then WScript.Echo("") ' Blank Line End If ' Loop through all the instances for the first report For each objInstance in objEnumerator If NOT IsEmpty(objInstance.Name) Then strDriveName = Mid(objInstance.Name,1,2) End If ' check if it is a valid physical drive If IsValidPhysicalDrive(objService,strDriveName) Then If IsEmpty(objInstance.Name) Then arrResultsDrives(1) = L_Na_Text Else strDriveName = Mid(objInstance.Name,1,2) arrResultsDrives(1) = UCase(strDriveName) End If ' to get the data from Win32_PageFileUsage Set objUsageInstance = objService.Get(CLASS_PAGE_FILE_USAGE & "='" & objInstance.Name & "'") ' to get the current size If Len(objUsageInstance.AllocatedBaseSize) = 0 Then arrResultsDrives(6) = L_Na_Text Else arrResultsDrives(6) = objUsageInstance.AllocatedBaseSize & MEGA_BYTES intTotSize = intTotSize + objUsageInstance.AllocatedBaseSize End If ' To set the PageFile status field If (objInstance.InitialSize = 0 AND objInstance.MaximumSize = 0) Then arrResultsDrives(8) = L_CONST_System_Managed_Text Else arrResultsDrives(8) = L_Custom_Text End If ' to get the data from Win32_LogicalDisk Set objDiskDriveInstance = objService.Get(CLASS_LOGICAL_DISK & "='" & strDriveName & "'") If Len(objDiskDriveInstance.VolumeName) = 0 Then arrResultsDrives(2) = L_Na_Text Else arrResultsDrives(2) = objDiskDriveInstance.VolumeName End If If Len(objDiskDriveInstance.SystemName) = 0 Then arrResultsDrives(0) = L_Na_Text Else arrResultsDrives(0) = objDiskDriveInstance.SystemName arrResultsSummary(0) = objDiskDriveInstance.SystemName End If If (objDiskDriveInstance.FreeSpace) Then arrResultsDrives(7) = Int(objDiskDriveInstance.FreeSpace/CONVERSION_FACTOR) + Int(objUsageInstance.AllocatedBaseSize) &_ MEGA_BYTES Else arrResultsDrives(7) = L_Na_Text End If If IsEmpty(objInstance.Name) Then arrResultsDrives(3) = L_Na_Text Else arrResultsDrives(3) = objInstance.Name End If If objInstance.InitialSize Then arrResultsDrives(4) = objInstance.InitialSize & MEGA_BYTES Else arrResultsDrives(4) = L_Na_Text End If If objInstance.MaximumSize Then arrResultsDrives(5) = objInstance.MaximumSize & MEGA_BYTES Else arrResultsDrives(5) = L_Na_Text End If arrFinalResultsDrives(0) = arrResultsDrives Call component.showResults(arrHeaderDrives, arrFinalResultsDrives, arrMaxLengthDrives, _ strFormat, blnPrintHeaderDrives, arrblnNoDisplayDrives) blnPrintHeaderDrives = FALSE End If Next WScript.Echo("") ' Display the summary report arrResultsSummary(1) = INITIAL_SIZE_LB & MEGA_BYTES Set objMemSizeInstance = objService.Get(CLASS_COMPUTER_SYSTEM & "='" & arrResultsDrives(0) & "'") If objMemSizeInstance.TotalPhysicalMemory Then intRecommendedSize = Int(Int(objMemSizeInstance.TotalPhysicalMemory/CONVERSION_FACTOR)* SIZE_FACTOR) arrResultsSummary(2) = intRecommendedSize & MEGA_BYTES Else arrResultsSummary(2) = L_Na_Text End If arrResultsSummary(3) = intTotSize & MEGA_BYTES arrFinalResultsSummary(0) = arrResultsSummary Call component.showResults(arrHeaderSummary, arrFinalResultsSummary, arrMaxLengthSummary, strFormat, _ blnPrintHeaderSummary,arrblnNoDisplaySummary) blnPrintHeaderSummary = FALSE End Sub '****************************************************************************** '* Function: IsValidPhysicalDrive '* '* Purpose: To check if the specified drive is a valid physical drive. '* This check is done only for Win2K builds '* '* Input: '* [in] objServiceParam service object to maintain wmi connection. '* [in] strDriveName drive name whose validity has to be checked. '* '* Output: Returns TRUE or FALSE '* TRUE - when the drive is a valid physical drive. '* FALSE - when the drive is not a valid physical drive. '* '****************************************************************************** Private Function IsValidPhysicalDrive ( ByVal objServiceParam, _ ByVal strDriveName ) ON ERROR RESUME NEXT Err.Clear CONST WIN2K_MAJOR_VERSION = 5000 CONST WINXP_MAJOR_VERSION = 5001 Dim strQuery ' to store the query to be executed Dim objEnum ' collection object Dim objInstance ' instance object Dim strValidDrives ' to store all valid physical drives Dim strVersion ' to store the OS version Dim arrVersionElements ' to store the OS version elements Dim CurrentMajorVersion ' the major version number strValidDrives = "" ' by default set it to true IsValidPhysicalDrive = TRUE strquery = "Select * From " & CLASS_OPERATING_SYSTEM set objEnum = objServiceParam.ExecQuery(strQuery,"WQL",48,null) For each objInstance in objEnum strVersion= objInstance.Version Next ' OS Version : 5.1.xxxx(Windows XP), 5.0.xxxx(Windows 2000) arrVersionElements = split(strVersion,".") ' converting to major version CurrentMajorVersion = arrVersionElements(0) * 1000 + arrVersionElements(1) ' Determine the OS Type ' If the OS version is 5.1 or later, then NO NEED to validate. ' If the OS is Win2K, then validate the drive name. If CInt(CurrentMajorVersion) <= CInt(WINXP_MAJOR_VERSION) Then strQuery = "Select * From " & CLASS_PERFDISK_PHYSICAL_DISK Set objEnum = objServiceParam.ExecQuery(strQuery, "WQL", 0, null) For each objInstance in objEnum ' get all the instance except the last one If (objInstance.Name <> "_Total") Then strValidDrives = strValidDrives & " " & objInstance.Name End If Next ' check if the specified drive is present in the list of valid physical drives If Instr(strValidDrives, UCase(strDriveName)) = 0 Then IsValidPhysicalDrive = FALSE End If End If End Function '****************************************************************************** '* Function: getFreeSpaceOnDisk '* '* Purpose: To get the Free Space for the Specified Disk '* '* Input: '* [in] strDriveName drive name whose free space is needed '* [in] objServiceParam service object to maintain wmi connection '* '* Output: Returns the free space (in MB) on the specified disk. '* '****************************************************************************** Private Function getFreeSpaceOnDisk(ByVal strDriveName, ByVal objServiceParam) ON ERROR RESUME NEXT Err.Clear Dim objValidDiskInst Set objValidDiskInst = objServiceParam.Get(CLASS_LOGICAL_DISK & "='" & strDriveName & "'") If Err.Number Then Err.Clear WScript.Echo(L_UnableToRetrieveInfo_ErrorMessage) blnFailureMsg = TRUE QuitbasedonSuccess EXIT_QUERY_FAIL End If getFreeSpaceOnDisk = Int(objValidDiskInst.FreeSpace/CONVERSION_FACTOR) End Function '****************************************************************************** '* Function: getCurrentPageFileSize '* '* Purpose: To get the current pagefile size on the specified drive '* '* Input: '* [in] objService wbem service object '* [in] objInstance instance of win32_pagefilesetting '* '* Output: current pagefile size '* '****************************************************************************** Private Function getCurrentPageFileSize(ByVal objService, ByVal objInstance) ON ERROR RESUME NEXT Err.Clear Dim objUsageInstance ' get the data from Win32_PageFileUsage Set objUsageInstance = objService.Get(CLASS_PAGE_FILE_USAGE & "='" & objInstance.Name & "'") ' return the current size ( allocated base size ) getCurrentPageFileSize = objUsageInstance.AllocatedBaseSize End Function '****************************************************************************** '* Function: GetDiskSize '* '* Purpose: To get the disk size for the specified drive '* '* Input: '* [in] strDriveName drive name whose free space is needed '* [in] objServiceParam service object to maintain wmi connection '* '* Output: Returns the total disk size in MB. '* '****************************************************************************** Private Function GetDiskSize(ByVal strDriveName, ByVal objServiceParam) ON ERROR RESUME NEXT Err.Clear Dim objValidDiskInst ' object to store valid disk name Set objValidDiskInst = objServiceParam.Get(CLASS_LOGICAL_DISK & "='" & strDriveName & "'") If Err.Number Then Err.Clear WScript.Echo(L_UnableToRetrieveInfo_ErrorMessage) blnFailureMsg = TRUE QuitBasedOnSuccess EXIT_QUERY_FAIL End If GetDiskSize = Int(objValidDiskInst.Size / CONVERSION_FACTOR) End Function '****************************************************************************** '* Function: GetPhysicalMemorySize '* '* Purpose: To get the physical memory size. '* '* Input: '* [in] strHostName host name to connect to '* [in] objServiceParam service object to maintain wmi connection '* '* Output: Returns the physical memory size in MB. '* '****************************************************************************** Private Function GetPhysicalMemorySize( ByVal strHostName, ByVal objServiceParam ) ON ERROR RESUME NEXT Err.Clear Dim objMemSizeInstance ' to store memory size Dim intReturnValue ' to store return value Set objMemSizeInstance = objServiceParam.Get(CLASS_COMPUTER_SYSTEM & "='" & strHostName & "'") If Err.Number Then Err.Clear WScript.Echo L_UnableToRetrieveInfo_ErrorMessage blnFailureMsg = TRUE QuitBasedOnSuccess EXIT_QUERY_FAIL End If If objMemSizeInstance.TotalPhysicalMemory Then intReturnValue = Int(objMemSizeInstance.TotalPhysicalMemory/CONVERSION_FACTOR) GetPhysicalMemorySize = intReturnValue End If End Function '****************************************************************************** '* Function: getMaxSizeUB '* '* Purpose: To get the allowed upper bound for maximum size '* '* Input: '* [in] objServiceParam service object to maintain wmi connection '* '* Output: Returns the upper bound for maximum size '* '****************************************************************************** Private Function getMaxSizeUB(objServiceParam) ON ERROR RESUME NEXT Err.Clear CONST PROCESSOR_X86_BASED = "X86" CONST PROCESSOR_IA64_BASED = "IA64" Dim objInstance ' object instance Dim intReturnValue ' to store return value Dim strProcessorType ' to store the processor type Dim strQuery ' to store the query Dim objEnum ' collection of objects getMaxSizeUB = 0 strQuery = "Select * From " & CLASS_COMPUTER_SYSTEM Set objEnum = objServiceParam.ExecQuery(strQuery,"WQL",48,null) If Err.Number Then Err.Clear WScript.Echo L_UnableToRetrieveInfo_ErrorMessage blnFailureMsg = TRUE QuitBasedOnSuccess EXIT_QUERY_FAIL End If ' The following code will handle only single processor environment For each objInstance in objEnum strProcessorType = objInstance.SystemType Next ' check if its a 32-bit processor If InStr( UCase(strProcessorType),PROCESSOR_X86_BASED ) > 0 Then getMaxSizeUB = 4096 End If ' check if its a 64-bit processor If Instr( UCase(strProcessorType),PROCESSOR_IA64_BASED ) > 0 Then getMaxSizeUB = 33554432 End If End Function '****************************************************************************** '* Function: GetCrashDumpSetting '* '* Purpose: To get the Crash Dump Settings for the machine specified '* '* Input: '* [in] strUserNameParam user name to connect to the machine '* [in] strPasswordParam password for the user '* [in] strMachineParam machine to get crash dump settings for '* '* Output: Returns the current crash dump setting value [ 0,1,2,3 ] '* 0 - None '* 1 - Complete Memory Dump '* 2 - Kernel Memory Dump '* 3 - Small Memory Dump '* '****************************************************************************** Private Function GetCrashDumpSetting( ByVal strUserNameParam, _ ByVal strPasswordParam, _ ByVal strMachineParam ) ON ERROR RESUME NEXT Err.Clear CONST CONST_NAMESPACE_DEFAULT = "root\default" ' name space to connect to CONST CONST_HKEY_LOCAL_MACHINE = 2147483650 ' registry value for HKEY_LOCAL_MACHINE CONST CONST_KEY_VALUE_NAME = "CrashDumpEnabled" ' value name to be retrieved CONST CONST_STD_REGISTRY_PROVIDER = "StdRegProv" ' standard registry provider ' the Sub Key Name CONST CONST_CRASH_DUMP_REGKEY = "SYSTEM\CurrentControlSet\Control\CrashControl" Dim objInstance ' to store the object instance Dim objService ' service object Dim intCrashDumpValue ' to store the crash dump setting value Dim intReturnVal ' to store return value ' connect to the WMI name space If NOT component.wmiConnect(CONST_NAMESPACE_DEFAULT , _ strUserNameParam , _ strPasswordParam , _ strMachineParam , _ blnLocalConnection , _ objService ) Then WScript.Echo(L_HintCheckConnection_Message) blnFailureMsg = TRUE QuitBasedOnSuccess EXIT_METHOD_FAIL End If ' get the instance of the Standard Registry Provider Set objInstance = objService.Get(CONST_STD_REGISTRY_PROVIDER) ' get the key value for from the registry intReturnVal = objInstance.GetDWORDValue( CONST_HKEY_LOCAL_MACHINE, _ CONST_CRASH_DUMP_REGKEY, _ CONST_KEY_VALUE_NAME, _ intCrashDumpValue ) ' check if any error has occured If Err.Number <> 0 Then Err.Clear WScript.Echo(L_FailCreateObject_ErrorMessage) blnFailureMsg = TRUE QuitBasedOnSuccess EXIT_INVALID_PARAM End If ' check for the return value after registry is accessed. If intReturnVal = 0 Then GetCrashDumpSetting = CInt(intCrashDumpValue) Else WScript.Echo(L_FailCreateObject_ErrorMessage) blnFailureMsg = TRUE QuitBasedOnSuccess EXIT_INVALID_PARAM End If End Function ' Function used to get the reply in y/n from the user '****************************************************************************** '* Function: getReply '* '* Purpose: To get reply from the user '* '* Input: None '* '* Output: Prompts for a warning message and accepts the user's choice [y/n] '* '****************************************************************************** Private Function getReply() ON ERROR RESUME NEXT Err.Clear Dim objStdIn ' to store value from standard input Dim strReply ' to store the user reply WScript.Echo(L_PromptForContinueAnyWay_Message) Set objStdIn = WScript.StdIn If Err.Number Then Err.Clear WScript.Echo(L_FailCreateObject_ErrorMessage) blnFailureMsg = TRUE QuitBasedOnSuccess EXIT_INVALID_PARAM End If strReply = objStdIn.ReadLine() getReply = Trim(strReply) End Function '****************************************************************************** '* Function: isCrashDumpValueSet '* '* Purpose: To check if the crash dump value is set '* '* Input: '* [in] intCrashDumpParam crash dump setting value '* [in] intIntSizeParam initial size of the pagefile '* [in] intMemSizeParam physical memory size '* [in] strVolume drive/volume name '* '* Output: Returns TRUE or FALSE '* '****************************************************************************** Private Function isCrashDumpValueSet( ByVal intCrashDumpParam,_ ByVal intIntSizeParam, _ ByVal intMemSizeParam, _ ByVal strVolume ) ON ERROR RESUME NEXT Err.Clear ' Constants for Crash Dump Settings CONST NO_MEMORY_DUMP = 0 CONST COMPLETE_MEMORY_DUMP = 1 CONST KERNEL_MEMORY_DUMP = 2 CONST SMALL_MEMORY_DUMP = 3 Dim strReply ' to store user reply Dim intSizeValue ' to store the size value used for comparison ' default value is NO [n] strReply = L_UserReplyNo_Text Select Case CInt(intCrashDumpParam) Case COMPLETE_MEMORY_DUMP If CInt(intIntSizeParam) < CInt(intMemSizeParam) Then component.VBPrintf CrashDumpSettingWarningMessage, Array(UCase(strVolume),CInt(intMemSizeParam) & MEGA_BYTES) ' Ask for choice until a yes[y] or no[n] is given Do strReply = getReply() If Trim(LCase(strReply)) = L_UserReplyYes_Text Then isCrashDumpValueSet = TRUE ElseIf Trim(LCase(strReply)) = L_UserReplyNo_Text Then isCrashDumpValueSet = FALSE Else WScript.Echo(L_InvalidUserReply_ErrorMessage) End If Loop Until (Trim(LCase(strReply)) = L_UserReplyYes_Text OR Trim(LCase(strReply)) = L_UserReplyNo_Text) Else isCrashDumpValueSet = TRUE End If Case KERNEL_MEMORY_DUMP ' check if RAM size is less than or equal to 128 MB If CInt(intMemSizeParam) <= 128 Then ' assign size value to be checked to 50 MB intSizeValue = 50 Else ' check if RAM size is less than or equal to 4 GB If CInt(intMemSizeParam) <= 4096 Then ' assign size value to be checked to 200 MB intSizeValue = 200 Else ' check if RAM size is less than or equal to 8 GB If CInt(intMemSizeParam) <= 8192 Then ' assign size value to be checked to 400 MB intSizeValue = 400 Else ' assign size value to be checked to 800 MB intSizeValue = 800 End If End If End If If CInt(intIntSizeParam) < CInt(intSizeValue) Then component.VBPrintf CrashDumpSettingWarningMessage, Array(UCase(strVolume),intSizeValue & MEGA_BYTES) ' Ask for choice until a yes[y] or no[n] is given Do strReply = getReply() If Trim(LCase(strReply)) = L_UserReplyYes_Text Then isCrashDumpValueSet = TRUE ElseIf Trim(LCase(strReply)) = L_UserReplyNo_Text Then isCrashDumpValueSet = FALSE Else WScript.Echo(L_InvalidUserReply_ErrorMessage) End If Loop Until (Trim(LCase(strReply)) = L_UserReplyYes_Text OR Trim(LCase(strReply)) = L_UserReplyNo_Text) Else isCrashDumpValueSet = TRUE End If Case SMALL_MEMORY_DUMP ' initial size should not be less than 64 KB ( less than or equal to 0 MB ) If CInt(intIntSizeParam) <= 0 Then component.VBPrintf CrashDumpSettingWarningMessage, Array(UCase(strVolume),"64 KB") ' Ask for choice until a yes[y] or no[n] is given Do strReply = getReply() If Trim(LCase(strReply)) = L_UserReplyYes_Text Then isCrashDumpValueSet = TRUE ElseIf Trim(LCase(strReply)) = L_UserReplyNo_Text Then isCrashDumpValueSet = FALSE Else WScript.Echo(L_InvalidUserReply_ErrorMessage) End If Loop Until (Trim(LCase(strReply)) = L_UserReplyYes_Text OR Trim(LCase(strReply)) = L_UserReplyNo_Text) Else isCrashDumpValueSet = TRUE End If Case NO_MEMORY_DUMP ' Crash Dump values 0 has no problem isCrashDumpValueSet = TRUE End Select End Function '******************************************************************************* '* sub: QuitBasedOnSuccess '* '* purpose: To quit the script based on the partial success of the operations '* '* Input: intReturnVal - Return value to be returned '* '****************************************************************************** sub QuitBasedOnSuccess(Byval intReturnVal ) ON ERROR RESUME NEXT Err.Clear ' Prompt for reboot if at least one operation was successful. If blnSuccessMsg = TRUE Then WScript.Echo L_RestartComputer_Message End If ' If zero has to be returned, return based on the failure status If intReturnVal = EXIT_SUCCESS Then If blnFailureMsg = TRUE Then Wscript.Quit( EXIT_PARTIAL_SUCCESS ) Else Wscript.Quit( EXIT_SUCCESS ) End If 'If other return levels are to be returned, just chck success value to return partial success value Else If blnSuccessMsg = TRUE Then Wscript.Quit( EXIT_PARTIAL_SUCCESS ) Else Wscript.Quit( intReturnVal) End If End If End sub '****************************************************************************** '* Sub: typeMessage '* '* Purpose: To print the type usage messages relevent to the main option '* selected. '* '* Input: The main option selected. '* '* Output: Prints "type..usage" messages for the main option selected. '* '****************************************************************************** Sub typeMessage(ByVal intMainOption) ON ERROR RESUME NEXT Err.Clear Select Case CInt(intMainOption) Case CONST_CHANGE_OPTION component.VBPrintf L_TypeChangeUsage_Message,Array(UCase(WScript.ScriptName)) Case CONST_CREATE_OPTION component.VBPrintf L_TypeCreateUsage_Message,Array(UCase(WScript.ScriptName)) Case CONST_DELETE_OPTION component.VBPrintf L_TypeDeleteUsage_Message,Array(UCase(WScript.ScriptName)) Case CONST_QUERY_OPTION component.VBPrintf L_TypeQueryUsage_Message,Array(UCase(WScript.ScriptName)) Case Else component.VBPrintf L_TypeUsage_Message,Array(UCase(WScript.ScriptName)) End Select End Sub '****************************************************************************** '* Function: ExpandEnvironmentString() '* '* Purpose: This function expands the environment variables. '* '* Input: [in] strOriginalString the string that needs expansion. '* Output: Returns ExpandedEnvironmentString '* '****************************************************************************** Private Function ExpandEnvironmentString(ByVal strOriginalString) ON ERROR RESUME NEXT Err.Clear Dim ObjWshShell ' Object to hold Shell. ' Create the shell object. Set ObjWshShell = CreateObject("WScript.Shell") If Err.Number Then WScript.Echo( L_FailCreateObject_ErrorMessage ) blnFailureMsg = TRUE QuitBasedOnSuccess EXIT_METHOD_FAIL End If ' Return the string. ExpandEnvironmentString = ObjWshShell.ExpandEnvironmentStrings(strOriginalString) End Function '****************************************************************************** '* Sub: ShowUsage '* '* Purpose: Shows the correct usage to the user. '* '* Input: None '* '* Output: Help messages are displayed on screen. '* '****************************************************************************** Sub ShowUsage() WScript.Echo vbCr ' Line 1 WScript.Echo( L_ShowUsageLine02_Text ) ' Line 2 WScript.Echo vbCr ' Line 3 WScript.Echo( L_UsageDescription_Text ) ' Line 4 WScript.Echo( L_ShowUsageLine05_Text ) ' Line 5 WScript.Echo( L_ShowUsageLine06_Text ) ' Line 6 WScript.Echo vbCr ' Line 7 WScript.Echo( L_ShowUsageLine08_Text ) ' Line 8 WScript.Echo( L_ShowUsageLine09_Text ) ' Line 9 WScript.Echo( L_ShowUsageLine10_Text ) ' Line 10 WScript.Echo vbCr ' Line 11 WScript.Echo( L_ShowUsageLine12_Text ) ' Line 12 WScript.Echo vbCr ' Line 13 WScript.Echo( L_ShowUsageLine14_Text ) ' Line 14 WScript.Echo vbCr ' Line 15 WScript.Echo( L_ShowUsageLine16_Text ) ' Line 16 WScript.Echo( L_ShowUsageLine17_Text ) ' Line 17 WScript.Echo vbCr ' Line 18 WScript.Echo( L_ShowUsageLine19_Text ) ' Line 19 WScript.Echo( L_ShowUsageLine20_Text ) ' Line 20 WScript.Echo( L_ShowUsageLine21_Text ) ' Line 21 WScript.Echo( L_ShowUsageLine22_Text ) ' Line 22 WScript.Echo( L_ShowUsageLine23_Text ) ' Line 23 WScript.Echo( L_ShowUsageLine24_Text ) ' Line 24 WScript.Echo( L_ShowUsageLine25_Text ) ' Line 25 End Sub '****************************************************************************** '* Sub: ShowChangeUsage '* '* Purpose: Shows the correct usage to the user. '* '* Input: None '* '* Output: Help messages for the /Change o ption are displayed on screen. '* '****************************************************************************** Sub ShowChangeUsage() WScript.Echo vbCr ' Line 1 WScript.Echo( L_ShowChangeUsageLine02_Text ) ' Line 2 WScript.Echo( L_ShowChangeUsageLine03_Text ) ' Line 3 WScript.Echo( L_ShowChangeUsageLine04_Text ) ' Line 4 WScript.Echo vbCr ' Line 5 WScript.Echo( L_UsageDescription_Text ) ' Line 6 WScript.Echo( L_ShowChangeUsageLine07_Text ) ' Line 7 WScript.Echo vbCr ' Line 8 WScript.Echo( L_UsageParamList_Text ) ' Line 9 WScript.Echo( L_UsageMachineName_Text ) ' Line 10 WScript.Echo vbCr ' Line 11 WScript.Echo( L_UsageUserNameLine1_Text ) ' Line 12 WScript.Echo( L_UsageUserNameLine2_Text ) ' Line 13 WScript.Echo vbCr ' Line 14 WScript.Echo( L_UsagePasswordLine1_Text ) ' Line 15 WScript.Echo( L_UsagePasswordLine2_Text ) ' Line 16 WScript.Echo vbCr ' Line 17 WScript.Echo( L_ShowChangeUsageLine18_Text ) ' Line 18 WScript.Echo( L_ShowChangeUsageLine19_Text ) ' Line 19 WScript.Echo vbCr ' Line 20 WScript.Echo( L_ShowChangeUsageLine21_Text ) ' Line 21 WScript.Echo( L_ShowChangeUsageLine22_Text ) ' Line 22 WScript.Echo vbCr ' Line 23 WScript.Echo( L_ShowChangeUsageLine24_Text ) ' Line 24 WScript.Echo( L_ShowChangeUsageLine25_Text ) ' Line 25 WScript.Echo vbCr ' Line 26 WScript.Echo( L_ShowChangeUsageLine27_Text ) ' Line 27 WScript.Echo( L_ShowChangeUsageLine28_Text ) ' Line 28 WScript.Echo( L_ShowChangeUsageLine29_Text ) ' Line 29 WScript.Echo( L_ShowChangeUsageLine30_Text ) ' Line 30 WScript.Echo vbCr ' Line 31 WScript.Echo( L_UsageExamples_Text ) ' Line 31 WScript.Echo( L_ShowChangeUsageLine33_Text ) ' Line 33 WScript.Echo( L_ShowChangeUsageLine34_Text ) ' Line 34 WScript.Echo( L_ShowChangeUsageLine35_Text ) ' Line 35 WScript.Echo( L_ShowChangeUsageLine36_Text ) ' Line 36 WScript.Echo( L_ShowChangeUsageLine37_Text ) ' Line 37 WScript.Echo( L_ShowChangeUsageLine38_Text ) ' Line 38 WScript.Echo( L_ShowChangeUsageLine39_Text ) ' Line 39 End Sub '****************************************************************************** '* Sub: ShowCreateUsage '* '* Purpose: Shows the correct usage to the user. '* '* Input: None '* '* Output: Help messages for the /Create option are displayed on screen. '* '****************************************************************************** Sub ShowCreateUsage() WScript.Echo vbCr ' Line 1 WScript.Echo( L_ShowCreateUsageLine02_Text ) ' Line 2 WScript.Echo( L_ShowCreateUsageLine03_Text ) ' Line 3 WScript.Echo( L_ShowCreateUsageLine04_Text ) ' Line 4 WScript.Echo vbCr ' Line 5 WScript.Echo( L_UsageDescription_Text ) ' Line 6 WScript.Echo( L_ShowCreateUsageLine07_Text ) ' Line 7 WScript.Echo vbCr ' Line 8 WScript.Echo( L_UsageParamList_Text ) ' Line 9 WScript.Echo( L_UsageMachineName_Text ) ' Line 10 WScript.Echo vbCr ' Line 11 WScript.Echo( L_UsageUserNameLine1_Text ) ' Line 12 WScript.Echo( L_UsageUserNameLine2_Text ) ' Line 13 WScript.Echo vbCr ' Line 14 WScript.Echo( L_UsagePasswordLine1_Text ) ' Line 15 WScript.Echo( L_UsagePasswordLine2_Text ) ' Line 16 WScript.Echo vbCr ' Line 17 WScript.Echo( L_ShowCreateUsageLine18_Text ) ' Line 18 WScript.Echo( L_ShowCreateUsageLine19_Text ) ' Line 19 WScript.Echo vbCr ' Line 20 WScript.Echo( L_ShowCreateUsageLine21_Text ) ' Line 21 WScript.Echo( L_ShowCreateUsageLine22_Text ) ' Line 22 WScript.Echo vbCr ' Line 23 WScript.Echo( L_ShowCreateUsageLine24_Text ) ' Line 24 WScript.Echo( L_ShowCreateUsageLine25_Text ) ' Line 25 WScript.Echo vbCr ' Line 26 WScript.Echo( L_ShowCreateUsageLine27_Text ) ' Line 27 WScript.Echo( L_ShowCreateUsageLine28_Text ) ' Line 28 WScript.Echo( L_ShowCreateUsageLine29_Text ) ' Line 29 WScript.Echo( L_ShowCreateUsageLine30_Text ) ' Line 30 WScript.Echo vbCr ' Line 31 WScript.Echo( L_UsageExamples_Text ) ' Line 32 WScript.Echo( L_ShowCreateUsageLine33_Text ) ' Line 33 WScript.Echo( L_ShowCreateUsageLine34_Text ) ' Line 34 WScript.Echo( L_ShowCreateUsageLine35_Text ) ' Line 35 WScript.Echo( L_ShowCreateUsageLine36_Text ) ' Line 36 WScript.Echo( L_ShowCreateUsageLine37_Text ) ' Line 37 WScript.Echo( L_ShowCreateUsageLine38_Text ) ' Line 38 WScript.Echo( L_ShowCreateUsageLine39_Text ) ' Line 39 End Sub '****************************************************************************** '* Sub: ShowDeleteUsage '* '* Purpose: Shows the correct usage to the user. '* '* Input: None '* '* Output: Help messages for the /Delete option are displayed on screen. '* '****************************************************************************** Sub ShowDeleteUsage() WScript.Echo vbCr ' Line 1 WScript.Echo( L_ShowDeleteUsageLine02_Text ) ' Line 2 WScript.Echo( L_ShowDeleteUsageLine03_Text ) ' Line 3 WScript.Echo vbCr ' Line 4 WScript.Echo( L_UsageDescription_Text ) ' Line 5 WScript.Echo( L_ShowDeleteUsageLine06_Text ) ' Line 6 WScript.Echo vbCr ' Line 7 WScript.Echo( L_UsageParamList_Text ) ' Line 8 WScript.Echo( L_UsageMachineName_Text ) ' Line 9 WScript.Echo vbCr ' Line 10 WScript.Echo( L_UsageUserNameLine1_Text ) ' Line 11 WScript.Echo( L_UsageUserNameLine2_Text ) ' Line 12 WScript.Echo vbCr ' Line 13 WScript.Echo( L_UsagePasswordLine1_Text ) ' Line 14 WScript.Echo( L_UsagePasswordLine2_Text ) ' Line 15 WScript.Echo vbCr ' Line 16 WScript.Echo( L_ShowDeleteUsageLine17_Text ) ' Line 17 WScript.Echo( L_ShowDeleteUsageLine18_Text ) ' Line 18 WScript.Echo( L_ShowDeleteUsageLine19_Text ) ' Line 19 WScript.Echo vbCr ' Line 20 WScript.Echo( L_UsageExamples_Text ) ' Line 21 WScript.Echo( L_ShowDeleteUsageLine22_Text ) ' Line 22 WScript.Echo( L_ShowDeleteUsageLine23_Text ) ' Line 23 WScript.Echo( L_ShowDeleteUsageLine24_Text ) ' Line 24 WScript.Echo( L_ShowDeleteUsageLine25_Text ) ' Line 25 End Sub '****************************************************************************** '* Sub: ShowQueryUsage '* '* Purpose: Shows the correct usage to the user. '* '* Input: None '* '* Output: Help messages for the /Query option are displayed on screen. '* '****************************************************************************** Sub ShowQueryUsage() WScript.Echo vbCr ' Line 1 WScript.Echo( L_ShowQueryUsageLine02_Text ) ' Line 2 WScript.Echo( L_ShowQueryUsageLine03_Text ) ' Line 3 WScript.Echo vbCr ' Line 4 WScript.Echo( L_UsageDescription_Text ) ' Line 5 WScript.Echo( L_ShowQueryUsageLine06_Text ) ' Line 6 WScript.Echo vbCr ' Line 7 WScript.Echo( L_UsageParamList_Text ) ' Line 8 WScript.Echo( L_UsageMachineName_Text ) ' Line 9 WScript.Echo vbCr ' Line 10 WScript.Echo( L_UsageUserNameLine1_Text ) ' Line 11 WScript.Echo( L_UsageUserNameLine2_Text ) ' Line 12 WScript.Echo vbCr ' Line 13 WScript.Echo( L_UsagePasswordLine1_Text ) ' Line 14 WScript.Echo( L_UsagePasswordLine2_Text ) ' Line 15 WScript.Echo vbCr ' Line 16 WScript.Echo( L_ShowQueryUsageLine17_Text ) ' Line 17 WScript.Echo( L_ShowQueryUsageLine18_Text ) ' Line 18 WScript.Echo( L_ShowQueryUsageLine19_Text ) ' Line 19 WScript.Echo vbCr ' Line 20 WScript.Echo( L_ShowQueryUsageLine21_Text ) ' Line 21 WScript.Echo( L_ShowQueryUsageLine22_Text ) ' Line 22 WScript.Echo vbCr ' Line 23 WScript.Echo( L_UsageExamples_Text ) ' Line 24 WScript.Echo( L_ShowQueryUsageLine25_Text ) ' Line 25 WScript.Echo( L_ShowQueryUsageLine26_Text ) ' Line 26 WScript.Echo( L_ShowQueryUsageLine27_Text ) ' Line 27 WScript.Echo( L_ShowQueryUsageLine28_Text ) ' Line 28 WScript.Echo( L_ShowQueryUsageLine29_Text ) ' Line 29 WScript.Echo( L_ShowQueryUsageLine30_Text ) ' Line 30 WScript.Echo( L_ShowQueryUsageLine31_Text ) ' Line 31 End Sub '' SIG '' Begin signature block '' SIG '' MIIaLwYJKoZIhvcNAQcCoIIaIDCCGhwCAQExDjAMBggq '' SIG '' hkiG9w0CBQUAMGYGCisGAQQBgjcCAQSgWDBWMDIGCisG '' SIG '' AQQBgjcCAR4wJAIBAQQQTvApFpkntU2P5azhDxfrqwIB '' SIG '' AAIBAAIBAAIBAAIBADAgMAwGCCqGSIb3DQIFBQAEEHko '' SIG '' YVpKucLx6zWsK5hurrSgghS8MIICvDCCAiUCEEoZ0jiM '' SIG '' glkcpV1zXxVd3KMwDQYJKoZIhvcNAQEEBQAwgZ4xHzAd '' SIG '' BgNVBAoTFlZlcmlTaWduIFRydXN0IE5ldHdvcmsxFzAV '' SIG '' BgNVBAsTDlZlcmlTaWduLCBJbmMuMSwwKgYDVQQLEyNW '' SIG '' ZXJpU2lnbiBUaW1lIFN0YW1waW5nIFNlcnZpY2UgUm9v '' SIG '' dDE0MDIGA1UECxMrTk8gTElBQklMSVRZIEFDQ0VQVEVE '' SIG '' LCAoYyk5NyBWZXJpU2lnbiwgSW5jLjAeFw05NzA1MTIw '' SIG '' MDAwMDBaFw0wNDAxMDcyMzU5NTlaMIGeMR8wHQYDVQQK '' SIG '' ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMRcwFQYDVQQL '' SIG '' Ew5WZXJpU2lnbiwgSW5jLjEsMCoGA1UECxMjVmVyaVNp '' SIG '' Z24gVGltZSBTdGFtcGluZyBTZXJ2aWNlIFJvb3QxNDAy '' SIG '' BgNVBAsTK05PIExJQUJJTElUWSBBQ0NFUFRFRCwgKGMp '' SIG '' OTcgVmVyaVNpZ24sIEluYy4wgZ8wDQYJKoZIhvcNAQEB '' SIG '' BQADgY0AMIGJAoGBANMuIPBofCwtLoEcsQaypwu3EQ1X '' SIG '' 2lPYdePJMyqy1PYJWzTz6ZD+CQzQ2xtauc3n9oixncCH '' SIG '' Jet9WBBzanjLcRX9xlj2KatYXpYE/S1iEViBHMpxlNUi '' SIG '' WC/VzBQFhDa6lKq0TUrp7jsirVaZfiGcbIbASkeXarSm '' SIG '' NtX8CS3TtDmbAgMBAAEwDQYJKoZIhvcNAQEEBQADgYEA '' SIG '' YVUOPnvHkhJ+ERCOIszUsxMrW+hE5At4nqR+86cHch7i '' SIG '' We/MhOOJlEzbTmHvs6T7Rj1QNAufcFb2jip/F87lY795 '' SIG '' aQdzLrCVKIr17aqp0l3NCsoQCY/Os68olsR5KYSS3P+6 '' SIG '' Z0JIppAQ5L9h+JxT5ZPRcz/4/Z1PhKxV0f0RY2MwggQC '' SIG '' MIIDa6ADAgECAhAIem1cb2KTT7rE/UPhFBidMA0GCSqG '' SIG '' SIb3DQEBBAUAMIGeMR8wHQYDVQQKExZWZXJpU2lnbiBU '' SIG '' cnVzdCBOZXR3b3JrMRcwFQYDVQQLEw5WZXJpU2lnbiwg '' SIG '' SW5jLjEsMCoGA1UECxMjVmVyaVNpZ24gVGltZSBTdGFt '' SIG '' cGluZyBTZXJ2aWNlIFJvb3QxNDAyBgNVBAsTK05PIExJ '' SIG '' QUJJTElUWSBBQ0NFUFRFRCwgKGMpOTcgVmVyaVNpZ24s '' SIG '' IEluYy4wHhcNMDEwMjI4MDAwMDAwWhcNMDQwMTA2MjM1 '' SIG '' OTU5WjCBoDEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4x '' SIG '' HzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdvcmsx '' SIG '' OzA5BgNVBAsTMlRlcm1zIG9mIHVzZSBhdCBodHRwczov '' SIG '' L3d3dy52ZXJpc2lnbi5jb20vcnBhIChjKTAxMScwJQYD '' SIG '' VQQDEx5WZXJpU2lnbiBUaW1lIFN0YW1waW5nIFNlcnZp '' SIG '' Y2UwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB '' SIG '' AQDAemGH67KnA2MbKxph3oC3FR2gi5A9uyeShBQ564XO '' SIG '' KZIGZkikA0+N6E+n8K9e0S8Zx5HxtZ57kSHO6f/jTvD8 '' SIG '' r5VYuGMt5o72KRjNcI5Qw+2Wu0DbviXoQlXW9oXyBueL '' SIG '' mRwx8wMP1EycJCrcGxuPgvOw76dN4xSn4I/Wx2jCYVip '' SIG '' ctT4MEhP2S9vYyDZicqCe8JLvCjFgWjn5oJArEY6oPk/ '' SIG '' Ns1Mu1RCWnple/6E5MdHVKy5PeyAxxr3xDOBgckqlft/ '' SIG '' XjqHkBTbzC518u9r5j2pYL5CAapPqluoPyIxnxIV+XOh '' SIG '' HoKLBCvqRgJMbY8fUC6VSyp4BoR0PZGPLEcxAgMBAAGj '' SIG '' gbgwgbUwQAYIKwYBBQUHAQEENDAyMDAGCCsGAQUFBzAB '' SIG '' hiRodHRwOi8vb2NzcC52ZXJpc2lnbi5jb20vb2NzcC9z '' SIG '' dGF0dXMwCQYDVR0TBAIwADBEBgNVHSAEPTA7MDkGC2CG '' SIG '' SAGG+EUBBwEBMCowKAYIKwYBBQUHAgEWHGh0dHBzOi8v '' SIG '' d3d3LnZlcmlzaWduLmNvbS9ycGEwEwYDVR0lBAwwCgYI '' SIG '' KwYBBQUHAwgwCwYDVR0PBAQDAgbAMA0GCSqGSIb3DQEB '' SIG '' BAUAA4GBAC3zT2NgLBja9SQPUrMM67O8Z4XCI+2PRg3P '' SIG '' Gk2+83x6IDAyGGiLkrsymfCTuDsVBid7PgIGAKQhkoQT '' SIG '' CsWY5UBXxQUl6K+vEWqp5TvL6SP2lCldQFXzpVOdyDY6 '' SIG '' OWUIc3OkMtKvrL/HBTz/RezD6Nok0c5jrgmn++Ib4/1B '' SIG '' CmqWMIIEEjCCAvqgAwIBAgIPAMEAizw8iBHRPvZj7N9A '' SIG '' MA0GCSqGSIb3DQEBBAUAMHAxKzApBgNVBAsTIkNvcHly '' SIG '' aWdodCAoYykgMTk5NyBNaWNyb3NvZnQgQ29ycC4xHjAc '' SIG '' BgNVBAsTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEhMB8G '' SIG '' A1UEAxMYTWljcm9zb2Z0IFJvb3QgQXV0aG9yaXR5MB4X '' SIG '' DTk3MDExMDA3MDAwMFoXDTIwMTIzMTA3MDAwMFowcDEr '' SIG '' MCkGA1UECxMiQ29weXJpZ2h0IChjKSAxOTk3IE1pY3Jv '' SIG '' c29mdCBDb3JwLjEeMBwGA1UECxMVTWljcm9zb2Z0IENv '' SIG '' cnBvcmF0aW9uMSEwHwYDVQQDExhNaWNyb3NvZnQgUm9v '' SIG '' dCBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IB '' SIG '' DwAwggEKAoIBAQCpAr3BcOY78k4bKJ+XeF4w6qKpjSVf '' SIG '' +P6VTKO3/p2iID58UaKboo9gMmvRQmR57qx2yVTa8uuc '' SIG '' hhyPn4Rms8VremIj1h083g8BkuiWxL8tZpqaaCaZ0Dos '' SIG '' vwy1WCbBRucKPjiWLKkoOajsSYNC44QPu5psVWGsgnyh '' SIG '' YC13TOmZtGQ7mlAcMQgkFJ+p55ErGOY9mGMUYFgFZZ8d '' SIG '' N1KH96fvlALGG9O/VUWziYC/OuxUlE6u/ad6bXROrxjM '' SIG '' lgkoIQBXkGBpN7tLEgc8Vv9b+6RmCgim0oFWV++2O14W '' SIG '' gXcE2va+roCV/rDNf9anGnJcPMq88AijIjCzBoXJsyB3 '' SIG '' E4XfAgMBAAGjgagwgaUwgaIGA1UdAQSBmjCBl4AQW9Bw '' SIG '' 72lyniNRfhSyTY7/y6FyMHAxKzApBgNVBAsTIkNvcHly '' SIG '' aWdodCAoYykgMTk5NyBNaWNyb3NvZnQgQ29ycC4xHjAc '' SIG '' BgNVBAsTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEhMB8G '' SIG '' A1UEAxMYTWljcm9zb2Z0IFJvb3QgQXV0aG9yaXR5gg8A '' SIG '' wQCLPDyIEdE+9mPs30AwDQYJKoZIhvcNAQEEBQADggEB '' SIG '' AJXoC8CN85cYNe24ASTYdxHzXGAyn54Lyz4FkYiPyTrm '' SIG '' IfLwV5MstaBHyGLv/NfMOztaqTZUaf4kbT/JzKreBXzd '' SIG '' MY09nxBwarv+Ek8YacD80EPjEVogT+pie6+qGcgrNyUt '' SIG '' vmWhEoolD2Oj91Qc+SHJ1hXzUqxuQzIH/YIX+OVnbA1R '' SIG '' 9r3xUse958Qw/CAxCYgdlSkaTdUdAqXxgOADtFv0sd3I '' SIG '' V+5lScdSVLa0AygS/5DW8AiPfriXxas3LOR65Kh343ag '' SIG '' ANBqP8HSNorgQRKoNWobats14dQcBOSoRQTIWjM4bk0c '' SIG '' DWK3CqKM09VUP0bNHFWmcNsSOoeTdZ+n0qAwggTJMIID '' SIG '' saADAgECAhBqC5lPwADeqhHU2ECaqL7mMA0GCSqGSIb3 '' SIG '' DQEBBAUAMHAxKzApBgNVBAsTIkNvcHlyaWdodCAoYykg '' SIG '' MTk5NyBNaWNyb3NvZnQgQ29ycC4xHjAcBgNVBAsTFU1p '' SIG '' Y3Jvc29mdCBDb3Jwb3JhdGlvbjEhMB8GA1UEAxMYTWlj '' SIG '' cm9zb2Z0IFJvb3QgQXV0aG9yaXR5MB4XDTAwMTIxMDA4 '' SIG '' MDAwMFoXDTA1MTExMjA4MDAwMFowgaYxCzAJBgNVBAYT '' SIG '' AlVTMRMwEQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQH '' SIG '' EwdSZWRtb25kMR4wHAYDVQQKExVNaWNyb3NvZnQgQ29y '' SIG '' cG9yYXRpb24xKzApBgNVBAsTIkNvcHlyaWdodCAoYykg '' SIG '' MjAwMCBNaWNyb3NvZnQgQ29ycC4xIzAhBgNVBAMTGk1p '' SIG '' Y3Jvc29mdCBDb2RlIFNpZ25pbmcgUENBMIIBIDANBgkq '' SIG '' hkiG9w0BAQEFAAOCAQ0AMIIBCAKCAQEAooQVU9gLMA40 '' SIG '' lf86G8LzL3ttNyNN89KM5f2v/cUCNB8kx+Wh3FTsfgJ0 '' SIG '' R6vbMlgWFFEpOPF+srSMOke1OU5uVMIxDDpt+83Ny1Cc '' SIG '' G66n2NlKJj+1xcuPluJJ8m3Y6ZY+3gXP8KZVN60vYM2A '' SIG '' YUKhSVRKDxi3S9mTmTBaR3VktNO73barDJ1PuHM7GDqq '' SIG '' tIeMsIiwTU8fThG1M4DfDTpkb0THNL1Kk5u8ph35BSNO '' SIG '' YCmPzCryhJqZrajbCnB71jRBkKW3ZsdcGx2jMw6bVAMa '' SIG '' P5iQuMznPQR0QxyP9znms6xIemsqDmIBYTl2bv0+mAdL '' SIG '' FPEBRv0VAOBH2k/kBeSAJQIBA6OCASgwggEkMBMGA1Ud '' SIG '' JQQMMAoGCCsGAQUFBwMDMIGiBgNVHQEEgZowgZeAEFvQ '' SIG '' cO9pcp4jUX4Usk2O/8uhcjBwMSswKQYDVQQLEyJDb3B5 '' SIG '' cmlnaHQgKGMpIDE5OTcgTWljcm9zb2Z0IENvcnAuMR4w '' SIG '' HAYDVQQLExVNaWNyb3NvZnQgQ29ycG9yYXRpb24xITAf '' SIG '' BgNVBAMTGE1pY3Jvc29mdCBSb290IEF1dGhvcml0eYIP '' SIG '' AMEAizw8iBHRPvZj7N9AMBAGCSsGAQQBgjcVAQQDAgEA '' SIG '' MB0GA1UdDgQWBBQpXLkbts0z7rueWX335couxA00KDAZ '' SIG '' BgkrBgEEAYI3FAIEDB4KAFMAdQBiAEMAQTALBgNVHQ8E '' SIG '' BAMCAUYwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0B '' SIG '' AQQFAAOCAQEARVjimkF//J2/SHd3rozZ5hnFV7QavbS5 '' SIG '' XwKhRWo5Wfm5J5wtTZ78ouQ4ijhkIkLfuS8qz7fWBsrr '' SIG '' Kr/gGoV821EIPfQi09TAbYiBFURfZINkxKmULIrbkDdK '' SIG '' D7fo1GGPdnbh2SX/JISVjQRWVJShHDo+grzupYeMHIxL '' SIG '' eV+1SfpeMmk6H1StdU3fZOcwPNtkSUT7+8QcQnHmoD1F '' SIG '' 7msAn6xCvboRs1bk+9WiKoHYH06iVb4nj3Cmomwb/1SK '' SIG '' gryBS6ahsWZ6qRenywbAR+ums+kxFVM9KgS//3NI3Isn '' SIG '' Q/xj6O4kh1u+NtHoMfUy2V7feXq6MKxphkr7jBG/G41U '' SIG '' WTCCBQ8wggP3oAMCAQICCmEHEUMAAAAAADQwDQYJKoZI '' SIG '' hvcNAQEFBQAwgaYxCzAJBgNVBAYTAlVTMRMwEQYDVQQI '' SIG '' EwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4w '' SIG '' HAYDVQQKExVNaWNyb3NvZnQgQ29ycG9yYXRpb24xKzAp '' SIG '' BgNVBAsTIkNvcHlyaWdodCAoYykgMjAwMCBNaWNyb3Nv '' SIG '' ZnQgQ29ycC4xIzAhBgNVBAMTGk1pY3Jvc29mdCBDb2Rl '' SIG '' IFNpZ25pbmcgUENBMB4XDTAyMDUyNTAwNTU0OFoXDTAz '' SIG '' MTEyNTAxMDU0OFowgaExCzAJBgNVBAYTAlVTMRMwEQYD '' SIG '' VQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25k '' SIG '' MR4wHAYDVQQKExVNaWNyb3NvZnQgQ29ycG9yYXRpb24x '' SIG '' KzApBgNVBAsTIkNvcHlyaWdodCAoYykgMjAwMiBNaWNy '' SIG '' b3NvZnQgQ29ycC4xHjAcBgNVBAMTFU1pY3Jvc29mdCBD '' SIG '' b3Jwb3JhdGlvbjCCASIwDQYJKoZIhvcNAQEBBQADggEP '' SIG '' ADCCAQoCggEBAKqZvTmoGCf0Kz0LTD98dy6ny7XRjA3C '' SIG '' OnTXk7XgoEs/WV7ORU+aeSnxScwaR+5Vwgg+EiD4VfLu '' SIG '' X9Pgypa8MN7+WMgnMtCFVOjwkRC78yu+GeUDmwuGHfOw '' SIG '' OYy4/QsdPHMmrFcryimiFZCCFeJ3o0BSA4udwnC6H+k0 '' SIG '' 9vM1kk5Vg/jaMLYg3lcGtVpCBt5Zy/Lfpr0VR3EZJSPS '' SIG '' y2+bGXnfalvxdgV5KfzDVsqPRAiFVYrLyA9GS1XLjJZ3 '' SIG '' SofoqUEGx/8N6WhXY3LDaVe0Q88yOjDcG+nVQyYqef6V '' SIG '' 2yJnJMkv0DTj5vtRSYa4PNAlX9bsngNhh6loQMf44gPm '' SIG '' zwUCAwEAAaOCAUAwggE8MA4GA1UdDwEB/wQEAwIGwDAT '' SIG '' BgNVHSUEDDAKBggrBgEFBQcDAzAdBgNVHQ4EFgQUa8jG '' SIG '' USDwtC/ToLauf14msriHUikwgakGA1UdIwSBoTCBnoAU '' SIG '' KVy5G7bNM+67nll99+XKLsQNNCihdKRyMHAxKzApBgNV '' SIG '' BAsTIkNvcHlyaWdodCAoYykgMTk5NyBNaWNyb3NvZnQg '' SIG '' Q29ycC4xHjAcBgNVBAsTFU1pY3Jvc29mdCBDb3Jwb3Jh '' SIG '' dGlvbjEhMB8GA1UEAxMYTWljcm9zb2Z0IFJvb3QgQXV0 '' SIG '' aG9yaXR5ghBqC5lPwADeqhHU2ECaqL7mMEoGA1UdHwRD '' SIG '' MEEwP6A9oDuGOWh0dHA6Ly9jcmwubWljcm9zb2Z0LmNv '' SIG '' bS9wa2kvY3JsL3Byb2R1Y3RzL0NvZGVTaWduUENBLmNy '' SIG '' bDANBgkqhkiG9w0BAQUFAAOCAQEANSP9E1T86dzw3QwU '' SIG '' evqns879pzrIuuXn9gP7U9unmamgmzacA+uCRxwhvRTL '' SIG '' 52dACccWkQJVzkNCtM0bXbDzMgQ9EuUdpwenj6N+RVV2 '' SIG '' G5aVkWnw3TjzSInvcEC327VVgMADxC62KNwKgg7HQ+N6 '' SIG '' SF24BomSQGxuxdz4mu8LviEKjC86te2nznGHaCPhs+QY '' SIG '' fbhHAaUrxFjLsolsX/3TLMRvuCOyDf888hFFdPIJBpkY '' SIG '' 3W/AhgEYEh0rFq9W72UzoepnTvRLgqvpD9wB+t9gf2ZH '' SIG '' XcsscMx7TtkGuG6MDP5iHkL5k3yiqwqe0CMQrk17J5Fv '' SIG '' Jr5o+qY/nyPryJ27hzGCBN0wggTZAgEBMIG1MIGmMQsw '' SIG '' CQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQ '' SIG '' MA4GA1UEBxMHUmVkbW9uZDEeMBwGA1UEChMVTWljcm9z '' SIG '' b2Z0IENvcnBvcmF0aW9uMSswKQYDVQQLEyJDb3B5cmln '' SIG '' aHQgKGMpIDIwMDAgTWljcm9zb2Z0IENvcnAuMSMwIQYD '' SIG '' VQQDExpNaWNyb3NvZnQgQ29kZSBTaWduaW5nIFBDQQIK '' SIG '' YQcRQwAAAAAANDAMBggqhkiG9w0CBQUAoIGqMBkGCSqG '' SIG '' SIb3DQEJAzEMBgorBgEEAYI3AgEEMBwGCisGAQQBgjcC '' SIG '' AQsxDjAMBgorBgEEAYI3AgEVMB8GCSqGSIb3DQEJBDES '' SIG '' BBAZBnnYm2gRb/lDE2fqJ+IWME4GCisGAQQBgjcCAQwx '' SIG '' QDA+oCaAJABwAGEAZwBlAGYAaQBsAGUAYwBvAG4AZgBp '' SIG '' AGcALgB2AGIAc6EUgBJ3d3cubWljcm9zb2Z0LmNvbSAw '' SIG '' DQYJKoZIhvcNAQEBBQAEggEAVrY7HUIi4Emzwy+RpCJA '' SIG '' pVRYEi7yH9RDTWX+kPe/wdJpJpae9X7j4wU+C2oIywCF '' SIG '' wCqxcE1HwYJu5MR4DV6EAcXJHs/eEuqU2qeMJh1zOmvy '' SIG '' vFbVgTpsFcGSMOXvTRXjeTHSQFGfuP1FhU90ENIYrK/k '' SIG '' RXUPH16d6rGQ8nBQUGi8uxzLOA94YXGfufMznaTCe6/z '' SIG '' WLFioxEv9lpbaxIcnQjKXHCsnQLM557p1wGtb6/TtZuN '' SIG '' veQbz6fcgJOZxLIk1B9Ffy90sO+YAvK6vgValTEZ1EFV '' SIG '' lPBP13vTgdFH9ALo4BSeDKOHn8pxf3zW3+ZFJNQPRl7A '' SIG '' o0fXKB0T5ni10KGCAkwwggJIBgkqhkiG9w0BCQYxggI5 '' SIG '' MIICNQIBATCBszCBnjEfMB0GA1UEChMWVmVyaVNpZ24g '' SIG '' VHJ1c3QgTmV0d29yazEXMBUGA1UECxMOVmVyaVNpZ24s '' SIG '' IEluYy4xLDAqBgNVBAsTI1ZlcmlTaWduIFRpbWUgU3Rh '' SIG '' bXBpbmcgU2VydmljZSBSb290MTQwMgYDVQQLEytOTyBM '' SIG '' SUFCSUxJVFkgQUNDRVBURUQsIChjKTk3IFZlcmlTaWdu '' SIG '' LCBJbmMuAhAIem1cb2KTT7rE/UPhFBidMAwGCCqGSIb3 '' SIG '' DQIFBQCgWTAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcB '' SIG '' MBwGCSqGSIb3DQEJBTEPFw0wMjEwMzAwMDE1NDdaMB8G '' SIG '' CSqGSIb3DQEJBDESBBAeS2yNHwLSVyiXAZeQB+I2MA0G '' SIG '' CSqGSIb3DQEBAQUABIIBAKffznG7CddPvTyv8VFLP8CJ '' SIG '' KknWy7Jp8LJnptz+QdfY0ywUNxcjt5N2lBSy+Q6t93bz '' SIG '' i6w6qQ6B3eZK7KtF2s0kWzSebRm9Mw0bcOxLWKz2FnuN '' SIG '' BwhQp+CpJbKf6egJaqWfgbo7ULkrZhM9LqiBZE7OqLTn '' SIG '' bRo22pHAgTEIo3wzO6ul203i98aJ1HMM42xKuqgFEe/9 '' SIG '' 6qDnWEvZZu/UpH7jU4PogKEZxH1EQrahyaVxHAwg6J1X '' SIG '' uh55iLbkcXoKLJ19E/djijoX9qUnFp7Vccw6VebJU7QR '' SIG '' eX4R20WeD9v/7C4K+VngvBiawLQf8p+FYya6uyIbg6Yt '' SIG '' 7gGQq8NPq1M= '' SIG '' End signature block
<filename>Task/Total-circles-area/VBA/total-circles-area.vba Public c As Variant Public pi As Double Dim arclists() As Variant Public Enum circles_ xc = 0 yc rc End Enum Public Enum arclists_ rho x_ y_ i_ End Enum Public Enum shoelace_axis u = 0 v End Enum Private Sub give_a_list_of_circles() c = Array(Array(1.6417233788, 1.6121789534, 0.0848270516), _ Array(-1.4944608174, 1.2077959613, 1.1039549836), _ Array(0.6110294452, -0.6907087527, 0.9089162485), _ Array(0.3844862411, 0.2923344616, 0.2375743054), _ Array(-0.249589295, -0.3832854473, 1.0845181219), _ Array(1.7813504266, 1.6178237031, 0.8162655711), _ Array(-0.1985249206, -0.8343333301, 0.0538864941), _ Array(-1.7011985145, -0.1263820964, 0.4776976918), _ Array(-0.4319462812, 1.4104420482, 0.7886291537), _ Array(0.2178372997, -0.9499557344, 0.0357871187), _ Array(-0.6294854565, -1.3078893852, 0.7653357688), _ Array(1.7952608455, 0.6281269104, 0.2727652452), _ Array(1.4168575317, 1.0683357171, 1.1016025378), _ Array(1.4637371396, 0.9463877418, 1.1846214562), _ Array(-0.5263668798, 1.7315156631, 1.4428514068), _ Array(-1.2197352481, 0.9144146579, 1.0727263474), _ Array(-0.1389358881, 0.109280578, 0.7350208828), _ Array(1.5293954595, 0.0030278255, 1.2472867347), _ Array(-0.5258728625, 1.3782633069, 1.3495508831), _ Array(-0.1403562064, 0.2437382535, 1.3804956588), _ Array(0.8055826339, -0.0482092025, 0.3327165165), _ Array(-0.6311979224, 0.7184578971, 0.2491045282), _ Array(1.4685857879, -0.8347049536, 1.3670667538), _ Array(-0.6855727502, 1.6465021616, 1.0593087096), _ Array(0.0152957411, 0.0638919221, 0.9771215985)) pi = WorksheetFunction.pi() End Sub Private Function shoelace(s As Collection) As Double 's is a collection of coordinate pairs (x, y), 'in clockwise order for positive result. 'The last pair is identical to the first pair. 'These pairs map a polygonal area. 'The area is computed with the shoelace algoritm. 'see the Rosetta Code task. Dim t As Double If s.Count > 2 Then s.Add s(1) For i = 1 To s.Count - 1 t = t + s(i + 1)(u) * s(i)(v) - s(i)(u) * s(i + 1)(v) Next i End If shoelace = t / 2 End Function Private Sub arc_sub(acol As Collection, f0 As Double, u0 As Double, v0 As Double, _ f1 As Double, u1 As Double, v1 As Double, this As Integer, j As Integer) 'subtract the arc from f0 to f1 from the arclist acol 'complicated to deal with edge cases If acol.Count = 0 Then Exit Sub 'nothing to subtract from Debug.Assert acol.Count Mod 2 = 0 Debug.Assert f0 <> f1 If f1 = pi Or f1 + pi < 5E-16 Then f1 = -f1 If f0 = pi Or f0 + pi < 5E-16 Then f0 = -f0 If f0 < f1 Then 'the arc does not pass the negative x-axis 'find a such that acol(a)(0)<f0<acol(a+1)(0) ' and b such that acol(b)(0)<f1<acol(b+1)(0) If f1 < acol(1)(rho) Or f0 > acol(acol.Count)(rho) Then Exit Sub 'nothing to subtract i = acol.Count + 1 start = 1 Do i = i - 1 Loop Until f1 > acol(i)(rho) If i Mod 2 = start Then acol.Add Array(f1, u1, v1, j), after:=i End If i = 0 Do i = i + 1 Loop Until f0 < acol(i)(rho) If i Mod 2 = 1 - start Then acol.Add Array(f0, u0, v0, j), before:=i i = i + 1 End If Do While acol(i)(rho) < f1 acol.Remove i If i > acol.Count Then Exit Do Loop Else start = 1 If f0 > acol(1)(rho) Then i = acol.Count + 1 Do i = i - 1 Loop While f0 < acol(i)(0) If f0 = pi Then acol.Add Array(f0, u0, v0, j), before:=i Else If i Mod 2 = start Then acol.Add Array(f0, u0, v0, j), after:=i End If End If End If If f1 <= acol(acol.Count)(rho) Then i = 0 Do i = i + 1 Loop While f1 > acol(i)(rho) If f1 + pi < 5E-16 Then acol.Add Array(f1, u1, v1, j), after:=i Else If i Mod 2 = 1 - start Then acol.Add Array(f1, u1, v1, j), before:=i End If End If End If Do While acol(acol.Count)(rho) > f0 Or acol(acol.Count)(i_) = -1 acol.Remove acol.Count If acol.Count = 0 Then Exit Do Loop If acol.Count > 0 Then Do While acol(1)(rho) < f1 Or (f1 = -pi And acol(1)(i_) = this) acol.Remove 1 If acol.Count = 0 Then Exit Do Loop End If End If End Sub Private Sub circle_cross() ReDim arclists(LBound(c) To UBound(c)) Dim alpha As Double, beta As Double Dim x3 As Double, x4 As Double, y3 As Double, y4 As Double Dim i As Integer, j As Integer For i = LBound(c) To UBound(c) Dim arccol As New Collection 'arccol is a collection or surviving arcs of circle i. 'It starts with the full circle. The collection 'alternates between start and ending angles of the arcs. 'This winds counter clockwise. 'Noted are angle, x coordinate, y coordinate and 'index number of circles with which circle i 'intersects at that angle and -1 marks visited. This defines 'ultimately a double linked list. So winding 'clockwise in the end is easy. arccol.Add Array(-pi, c(i)(xc) - c(i)(r), c(i)(yc), i) arccol.Add Array(pi, c(i)(xc) - c(i)(r), c(i)(yc), -1) For j = LBound(c) To UBound(c) If i <> j Then x0 = c(i)(xc) y0 = c(i)(yc) r0 = c(i)(rc) x1 = c(j)(xc) y1 = c(j)(yc) r1 = c(j)(rc) d = Sqr((x0 - x1) ^ 2 + (y0 - y1) ^ 2) 'Ignore 0 and 1, we need only the 2 case. If d >= r0 + r1 Or d <= Abs(r0 - r1) Then 'no intersections Else a = (r0 ^ 2 - r1 ^ 2 + d ^ 2) / (2 * d) h = Sqr(r0 ^ 2 - a ^ 2) x2 = x0 + a * (x1 - x0) / d y2 = y0 + a * (y1 - y0) / d x3 = x2 + h * (y1 - y0) / d y3 = y2 - h * (x1 - x0) / d alpha = WorksheetFunction.Atan2(x3 - x0, y3 - y0) x4 = x2 - h * (y1 - y0) / d y4 = y2 + h * (x1 - x0) / d beta = WorksheetFunction.Atan2(x4 - x0, y4 - y0) 'alpha is counterclockwise positioned w.r.t beta 'so the arc from beta to alpha (ccw) has to be 'subtracted from the list of surviving arcs as 'this arc lies fully in circle j arc_sub arccol, alpha, x3, y3, beta, x4, y4, i, j End If End If Next j Set arclists(i) = arccol Set arccol = Nothing Next i End Sub Private Sub make_path() Dim pathcol As New Collection, arcsum As Double i0 = UBound(arclists) finished = False Do While True arcsum = 0 Do While arclists(i0).Count = 0 i0 = i0 - 1 Loop j0 = arclists(i0).Count next_i = i0 next_j = j0 Do While True x = arclists(next_i)(next_j)(x_) y = arclists(next_i)(next_j)(y_) pathcol.Add Array(x, y) prev_i = next_i prev_j = next_j If arclists(next_i)(next_j - 1)(i_) = next_i Then 'skip the join point at the negative x-axis next_j = arclists(next_i).Count - 1 If next_j = 1 Then Exit Do 'loose full circle arc Else next_j = next_j - 1 End If '------------------------------ r = c(next_i)(rc) a1 = arclists(next_i)(prev_j)(rho) a2 = arclists(next_i)(next_j)(rho) If a1 > a2 Then alpha = a1 - a2 Else alpha = 2 * pi - a2 + a1 End If arcsum = arcsum + r * r * (alpha - Sin(alpha)) / 2 '------------------------------ next_i = arclists(next_i)(next_j)(i_) next_j = arclists(next_i).Count If next_j = 0 Then Exit Do 'skip loose arcs Do While arclists(next_i)(next_j)(i_) <> prev_i 'find the matching item next_j = next_j - 1 Loop If next_i = i0 And next_j = j0 Then finished = True Exit Do End If Loop If finished Then Exit Do i0 = i0 - 1 Set pathcol = Nothing Loop Debug.Print shoelace(pathcol) + arcsum End Sub Public Sub total_circles() give_a_list_of_circles circle_cross make_path End Sub
<filename>Task/Loops-Continue/VBA/loops-continue.vba<gh_stars>1-10 Public Sub LoopContinue() Dim value As Integer For value = 1 To 10 Debug.Print value; If value Mod 5 = 0 Then 'VBA does not have a continue statement Debug.Print Else Debug.Print ","; End If Next value End Sub
Set objSet = GetObject("winmgmts:").InstancesOf("Win32_VolumeUserQuota") for each obj in objSet WScript.Echo obj.Account & " <-> " & obj.Volume next
<filename>admin/wmi/wbem/scripting/test/vb/property/property.frm<gh_stars>10-100 VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 'Windows Default End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Form_Load() Dim Properties As SWbemPropertySet Set Properties = GetObject("winmgmts:").Get().Properties_ Properties.Add("p1", wbemCimtypeBoolean).Value = True Properties.Add("p2", wbemCimtypeReal32).Value = 1.278368 Properties.Add("p3", wbemCimtypeSint32).Value = -1289 Dim P As SWbemProperty Dim PP As SWbemProperty For Each P In Properties Debug.Print P.Name, "=", P.Value For Each PP In Properties Debug.Print PP.Name, PP.CIMType Next Next End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '' '' DELCOMP.VBS '' '' Deletes the specified computer account from the specified container '' '' usage: delcomp container computername '' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Option Explicit Dim oArgs Dim oContainer On Error Resume Next 'Stop Set oArgs = WScript.Arguments If (oArgs.Count <> 1) Then WScript.Echo "Usage: delcomp computername" WScript.Echo "Example: cscript delcomp.vbs chuckc0" WScript.Quit End If Set oContainer = GetObject("LDAP://ntdev.microsoft.com/CN=Computers,DC=ntdev,DC=microsoft,DC=com") If (Err.Number <> 0) Then WScript.Echo "Error 0x" & CStr(Hex(Err.Number)) & " occurred binding to container." WScript.Quit(Err.Number) End If oContainer.Delete "computer", "CN=" + oArgs(0) If (Err.Number = 0) Then Script.Echo "The computer account was deleted successfully." Else WScript.Echo "Error 0x" & CStr(Hex(Err.Number)) & " occurred deleting computer account." WScript.Quit(Err.Number) End If WScript.Quit(0)
Option Explicit Private Declare Sub GetMem8 Lib "msvbvm60.dll" _ (ByVal SrcAddr As Long, ByVal TarAddr As Long) Sub Main() Dim PlusInfinity As Double Dim MinusInfinity As Double Dim IndefiniteNumber As Double On Error Resume Next PlusInfinity = 1 / 0 MinusInfinity = -1 / 0 IndefiniteNumber = 0 / 0 Debug.Print "PlusInfinity = " & CStr(PlusInfinity) _ & " (" & DoubleAsHex(PlusInfinity) & ")" Debug.Print "MinusInfinity = " & CStr(MinusInfinity) _ & " (" & DoubleAsHex(MinusInfinity) & ")" Debug.Print "IndefiniteNumber = " & CStr(IndefiniteNumber) _ & " (" & DoubleAsHex(IndefiniteNumber) & ")" End Sub Function DoubleAsHex(ByVal d As Double) As String Dim l(0 To 1) As Long GetMem8 VarPtr(d), VarPtr(l(0)) DoubleAsHex = Right$(String$(8, "0") & Hex$(l(1)), 8) _ & Right$(String$(8, "0") & Hex$(l(0)), 8) End Function
Function PrimeFactors(n) arrP = Split(ListPrimes(n)," ") divnum = n Do Until divnum = 1 'The -1 is to account for the null element of arrP For i = 0 To UBound(arrP)-1 If divnum = 1 Then Exit For ElseIf divnum Mod arrP(i) = 0 Then divnum = divnum/arrP(i) PrimeFactors = PrimeFactors & arrP(i) & " " End If Next Loop End Function Function IsPrime(n) If n = 2 Then IsPrime = True ElseIf n <= 1 Or n Mod 2 = 0 Then IsPrime = False Else IsPrime = True For i = 3 To Int(Sqr(n)) Step 2 If n Mod i = 0 Then IsPrime = False Exit For End If Next End If End Function Function ListPrimes(n) ListPrimes = "" For i = 1 To n If IsPrime(i) Then ListPrimes = ListPrimes & i & " " End If Next End Function WScript.StdOut.Write PrimeFactors(CInt(WScript.Arguments(0))) WScript.StdOut.WriteLine
<reponame>npocmaka/Windows-Server-2003 set IPConfigSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _ ("select IPAddress from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE") for each IPConfig in IPConfigSet if Not IsNull(IPConfig.IPAddress) then for i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress) WScript.Echo IPConfig.IPAddress(i) next end if next
Function build_spiral(n) botcol = 0 : topcol = n - 1 botrow = 0 : toprow = n - 1 'declare a two dimensional array Dim matrix() ReDim matrix(topcol,toprow) dir = 0 : col = 0 : row = 0 'populate the array For i = 0 To n*n-1 matrix(col,row) = i Select Case dir Case 0 If col < topcol Then col = col + 1 Else dir = 1 : row = row + 1 : botrow = botrow + 1 End If Case 1 If row < toprow Then row = row + 1 Else dir = 2 : col = col - 1 : topcol = topcol - 1 End If Case 2 If col > botcol Then col = col - 1 Else dir = 3 : row = row - 1 : toprow = toprow - 1 End If Case 3 If row > botrow Then row = row - 1 Else dir = 0 : col = col + 1 : botcol = botcol + 1 End If End Select Next 'print the array For y = 0 To n-1 For x = 0 To n-1 WScript.StdOut.Write matrix(x,y) & vbTab Next WScript.StdOut.WriteLine Next End Function build_spiral(CInt(WScript.Arguments(0)))
function Main() MsgBox("Hello, World!") ' Display message on computer screen. end function call Main
Option Explicit On Error Resume Next Main Sub Main Dim sDomain Dim oClusApp Dim sCluster Set oClusApp = CreateObject("MSCluster.ClusApplication") for each sDomain in oClusApp.DomainNames MsgBox "Domain name is " & sDomain for each sCluster in oClusApp.ClusterNames( sDomain ) MsgBox "Cluster name is " & sCluster next next End Sub
<filename>admin/wmi/wbem/scripting/test/vbscript/subclasscr.vbs '*************************************************************************** 'This script tests the enumeration of subclasses '*************************************************************************** On Error Resume Next Set Service = GetObject("winmgmts:") Set DiskSubclass = Service.Get("CIM_LogicalDisk").SpawnDerivedClass_() 'Set the name of the subclass DiskSubClass.Path_.Class = "SUBCLASSTEST00" 'Add a property to the subclass Set NewProperty = DiskSubClass.Properties_.Add ("MyNewProperty", 19) NewProperty.Value = 12 'Add a qualifier to the property with an integer array value NewProperty.Qualifiers_.Add "MyNewPropertyQualifier", Array (1,2,3) 'Persist the subclass in CIMOM DiskSubclass.Put_ () 'Now delete it Service.Delete "SUBCLASSTEST00" if Err <> 0 Then WScript.Echo Err.Description Err.Clear End if
Dim MyWord MyWord = UCase("alphaBETA") ' Returns "ALPHABETA" MyWord = LCase("alphaBETA") ' Returns "alphabeta"
'******************************************************************** '* '* File: LISTPROPERTIES.VBS '* Created: July 1998 '* Version: 1.0 '* '* Main Function: Lists properties of a WBEM object. '* Usage: LISTPROPERTIES.VBS [/P:objectpath | /C:class] [/N:namespace] '* [/O:outputfile] [/U:username] [/W:password] [/D] [/M] [/QA] [/Q] '* '* Copyright (C) 1998 Microsoft Corporation '* '******************************************************************** OPTION EXPLICIT ON ERROR RESUME NEXT 'Define constants CONST CONST_ERROR = 0 CONST CONST_WSCRIPT = 1 CONST CONST_CSCRIPT = 2 CONST CONST_SHOW_USAGE = 3 CONST CONST_PROCEED = 4 'Declare variables Dim intOpMode, i Dim strWbemPath, strClass, strNameSpace, strOutputFile, strUserName, strPassword Dim blnDerivation, blnMethods, blnQualifiers, blnQuiet ReDim strArgumentArray(0) 'Initialize variables blnAll = False strWbemPath = "" strClass = "" strNameSpace = "root\cimv2" strOutputFile = "" strUserName = "" strPassword = "" blnDerivation = False blnMethods = False blnQualifiers = False blnQuiet = False strArgumentArray(0) = "" 'Get the command line arguments For i = 0 to Wscript.Arguments.Count - 1 ReDim Preserve strArgumentArray(i) strArgumentArray(i) = Wscript.Arguments.Item(i) Next 'Check whether the script is run using CScript Select Case intChkProgram() Case CONST_CSCRIPT 'Do Nothing Case CONST_WSCRIPT WScript.Echo "Please run this script using CScript." & vbCRLF & _ "This can be achieved by" & vbCRLF & _ "1. Using ""CScript LISTPROPERTIES.VBS arguments"" for Windows 95/98 or" & vbCRLF & _ "2. Changing the default Windows Scripting Host setting to CScript" & vbCRLF & _ " using ""CScript //H:CScript //S"" and running the script using" & vbCRLF & _ " ""LISTPROPERTIES.VBS arguments"" for Windows NT." WScript.Quit Case Else WScript.Quit End Select 'Parse the command line intOpMode = intParseCmdLine(strArgumentArray, strWbemPath, strClass, strNameSpace, _ strOutputFile, strUserName, strPassword, blnDerivation, blnMethods, _ blnQualifiers, blnQuiet) If Err.Number then Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred in parsing the command line." If Err.Description <> "" Then Print "Error description: " & Err.Description & "." End If WScript.Quit End If Select Case intOpMode Case CONST_SHOW_USAGE Call ShowUsage() Case CONST_PROCEED Call ListProperties(strWbemPath, strClass, strNameSpace, strOutputFile, _ strUserName, strPassword, blnDerivation, blnMethods, blnQualifiers) Case CONST_ERROR 'Do nothing. Case Else 'Default -- should never happen Print "Error occurred in passing parameters." End Select '******************************************************************** '* '* Function intChkProgram() '* Purpose: Determines which program is used to run this script. '* Input: None '* Output: intChkProgram is set to one of CONST_ERROR, CONST_WSCRIPT, '* and CONST_CSCRIPT. '* '******************************************************************** Private Function intChkProgram() ON ERROR RESUME NEXT Dim strFullName, strCommand, i, j 'strFullName should be something like C:\WINDOWS\COMMAND\CSCRIPT.EXE strFullName = WScript.FullName If Err.Number then Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred." If Err.Description <> "" Then If Err.Description <> "" Then Print "Error description: " & Err.Description & "." End If End If intChkProgram = CONST_ERROR Exit Function End If i = InStr(1, strFullName, ".exe", 1) If i = 0 Then intChkProgram = CONST_ERROR Exit Function Else j = InStrRev(strFullName, "\", i, 1) If j = 0 Then intChkProgram = CONST_ERROR Exit Function Else strCommand = Mid(strFullName, j+1, i-j-1) Select Case LCase(strCommand) Case "cscript" intChkProgram = CONST_CSCRIPT Case "wscript" intChkProgram = CONST_WSCRIPT Case Else 'should never happen Print "An unexpected program is used to run this script." Print "Only CScript.Exe or WScript.Exe can be used to run this script." intChkProgram = CONST_ERROR End Select End If End If End Function '******************************************************************** '* '* Function intParseCmdLine() '* Purpose: Parses the command line. '* Input: strArgumentArray an array containing input from the command line '* Output: strWbemPath the path of a WBEM object '* strClass a class name '* strNameSpace a namespace string '* strOutputFile an output file name '* strUserName the current user's name '* strPassword the current user's password '* blnDerivation specifies whether to get derivation info '* blnMethods specifies whether to get methods info '* blnQualifiers specifies whether to get qualifiers info '* blnQuiet specifies whether to suppress messages '* intParseCmdLine is set to one of CONST_ERROR, CONST_SHOW_USAGE, CONST_PROCEED. '* '******************************************************************** Private Function intParseCmdLine(strArgumentArray, strWbemPath, strClass, strNameSpace, _ strOutputFile, strUserName, strPassword, blnDerivation, blnMethods, _ blnQualifiers, blnQuiet) ON ERROR RESUME NEXT Dim strFlag, i strFlag = strArgumentArray(0) If strFlag = "" then 'No arguments have been received Print "Arguments are required." Print "Please check the input and try again." intParseCmdLine = CONST_ERROR Exit Function End If If (strFlag="help") OR (strFlag="/h") OR (strFlag="\h") OR (strFlag="-h") _ OR (strFlag = "\?") OR (strFlag = "/?") OR (strFlag = "?") OR (strFlag="h") Then intParseCmdLine = CONST_SHOW_USAGE Exit Function End If For i = 0 to UBound(strArgumentArray) strFlag = LCase(Left(strArgumentArray(i), InStr(1, strArgumentArray(i), ":")-1)) If Err.Number Then 'An error occurs if there is no : in the string Err.Clear Select Case LCase(strArgumentArray(i)) Case "/d" blnDerivation = True Case "/m" blnMethods = True Case "/qa" blnQualifiers = True Case "/q" blnQuiet = True Case Else Print strArgumentArray(i) & " is not a valid input." Print "Please check the input and try again." intParseCmdLine = CONST_ERROR Exit Function End Select Else Select Case strFlag Case "/p" strWbemPath = Right(strArgumentArray(i), Len(strArgumentArray(i))-3) Case "/c" strClass = Right(strArgumentArray(i), Len(strArgumentArray(i))-3) Case "/n" strNameSpace = Right(strArgumentArray(i), Len(strArgumentArray(i))-3) Case "/o" strOutputFile = Right(strArgumentArray(i), Len(strArgumentArray(i))-3) Case "/u" strUserName = Right(strArgumentArray(i), Len(strArgumentArray(i))-3) Case "/w" strPassword = Right(strArgumentArray(i), Len(strArgumentArray(i))-3) Case Else Print "Invalid flag " & """" & strFlag & ":""" & "." Print "Please check the input and try again." intParseCmdLine = CONST_ERROR Exit Function End Select End If Next If strWbemPath = "" And strClass = "" Then Print "Please enter an object path or a class name." intParseCmdLine = CONST_ERROR Exit Function End If If strWbemPath <> "" And strClass <> "" Then Print "You can not enter both an object path and a class name." Print "Please check the input and try again." intParseCmdLine = CONST_ERROR Exit Function End If intParseCmdLine = CONST_PROCEED End Function '******************************************************************** '* '* Sub ShowUsage() '* Purpose: Shows the correct usage to the user. '* Input: None '* Output: Help messages are displayed on screen. '* '******************************************************************** Private Sub ShowUsage() Wscript.echo "" Wscript.echo "Lists properties of a WBEM object or class." & vbCRLF Wscript.echo "LISTPROPERTIES.VBS [/P:objectpath | /C:class] [/N:namespace]" Wscript.echo "[/O:outputfile] [/U:username] [/W:password] [/D] [/M] [/QA] [/Q]" Wscript.echo "/P, /C, /N, /O, /U, /W" Wscript.Echo " Parameter specifiers." Wscript.Echo " objectpath The path of a WBEM object." Wscript.Echo " class The path of a WBEM class." Wscript.Echo " namespace A namespace. The default is root\cimv2" Wscript.Echo " outputfile The output file name." Wscript.Echo " username The current user's name." Wscript.Echo " password Password of the current user." Wscript.Echo " /D Shows the derivation information." Wscript.Echo " /M Shows methods available for the object." Wscript.Echo " /QA Shows qualifiers of the object." Wscript.Echo " /Q Suppresses all output messages." & vbCRLF Wscript.Echo "EXAMPLE:" Wscript.echo "1. LISTPROPERTIES.VBS /P:WINMGMTS:\\MyServer\root\cimv2:" Wscript.echo " Win32_Process.Handle=30" Wscript.echo " lists properties of a Win32 process with a handle of 30." Wscript.echo "2. LISTPROPERTIES.VBS /C:Win32_Process" Wscript.echo " lists properties of class Win32 process." End Sub '******************************************************************** '* '* Sub ListProperties() '* Purpose: Lists properties of a WBEM object. '* Input: strWbemPath the path of a WBEM object '* strClass a class name '* strNameSpace a namespace string '* strOutputFile an output file name '* strUserName the current user's name '* strPassword <PASSWORD> '* blnDerivation specifies whether to get derivation info '* blnMethods specifies whether to get methods info '* blnQualifiers specifies whether to get qualifiers info '* Output: Results are either printed on screen or saved in strOutputFile. '* '******************************************************************** Private Sub ListProperties(strWbemPath, strClass, strNameSpace, strOutputFile, _ strUserName, strPassword, blnDerivation, blnMethods, blnQualifiers) ON ERROR RESUME NEXT Dim objFileSystem, objOutputFile, objService, objWBEM If strOutputFile = "" Then objOutputFile = "" Else 'Create a filesystem object. Set objFileSystem = CreateObject("Scripting.FileSystemObject") If Err.Number then Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred in opening a filesystem object." If Err.Description <> "" Then Print "Error description: " & Err.Description & "." End If Exit Sub End If 'Open the file For output Set objOutputFile = objFileSystem.OpenTextFile(strOutputFile, 8, True) If Err.Number then Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred in opening file " & strOutputFile If Err.Description <> "" Then Print "Error description: " & Err.Description & "." End If Exit Sub End If End If If strWbemPath <> "" Then Set objService = GetObject("winmgmts:" & strNameSpace) Set objWBEM = objService.Get(strWbemPath) ElseIf strClass <> "" Then Set objService = GetObject("winmgmts:" & strNameSpace) Set objWBEM = objService.Get(strClass) End If If Err.Number Then Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred in getting the WBEM object." If Err.Description <> "" Then Print "Error description: " & Err.Description & "." End If Err.Clear Exit Sub End If Call ShowProperties(objWBEM, blnDerivation, blnMethods, blnQualifiers, objOutputFile) If strOutputFile <> "" Then objOutputFile.Close If intResult > 0 Then Wscript.echo "Results are saved in file " & strOutputFile & "." End If End If End Sub '******************************************************************** '* '* Sub ShowProperties() '* Purpose: Lists properties of a WBEM object. '* Input: objWBEM a WBEM object '* blnDerivation specifies whether to get derivation info '* blnMethods specifies whether to get methods info '* blnQualifiers specifies whether to get qualifiers info '* objOutputFile an output file object '* Output: Results are either printed on screen or saved in strOutputFile. '* '******************************************************************** Private Sub ShowProperties(objWBEM, blnDerivation, blnMethods, blnQualifiers, objOutputFile) ON ERROR RESUME NEXT Dim i, j, k, strMessage Dim objWbemProperty, objWbemObjectPath, objWbemMethod, objQualifier, objParameter 'Print a header WriteLine "PROPERTIES", objOutputFile strMessage = strPackString("Name", 20, 1, 0) strMessage = strMessage & strPackString("CIMType", 15, 1, 0) strMessage = strMessage & strPackString("IsLocal", 10, 1, 0) strMessage = strMessage & strPackString("Origin", 20, 1, 0) strMessage = strMessage & strPackString("Value", 20, 1, 0) WriteLine strMessage & vbCRLF, objOutputFile For Each objWbemProperty in objWBEM.Properties_ strMessage = strPackString(objWbemProperty.Name, 20, 1, 0) strMessage = strMessage & strPackString(strCIMType(objWbemProperty.CIMType), 15, 1, 0) strMessage = strMessage & strPackString(objWbemProperty.IsLocal, 10, 1, 0) strMessage = strMessage & strPackString(objWbemProperty.Origin, 20, 1, 0) strMessage = strMessage & strPackString(objWbemProperty.Value, 20, 1, 0) WriteLine strMessage, objOutputFile If Err.Number Then Err.Clear End If Next Set objWbemObjectPath = objWBEM.Path_ strMessage = vbCRLF & "Class = " & objWbemObjectPath.Class & vbCRLF strMessage = strMessage & "DisplayName = " & objWbemObjectPath.DisplayName & vbCRLF strMessage = strMessage & "IsClass = " & objWbemObjectPath.IsClass & vbCRLF strMessage = strMessage & "IsSingleton = " & objWbemObjectPath.IsSingleton & vbCRLF strMessage = strMessage & "Namespace = " & objWbemObjectPath.Namespace & vbCRLF strMessage = strMessage & "Path = " & objWbemObjectPath.Path & vbCRLF strMessage = strMessage & "RelPath = " & objWbemObjectPath.RelPath & vbCRLF strMessage = strMessage & "Server = " & objWbemObjectPath.Server & vbCRLF WriteLine strMessage, objOutputFile If blnDerivation Then strMessage = "DERIVED FROM" & vbCRLF For i = 0 To UBound(objWBEM.Derivation_) strMessage = strMessage & objWBEM.Derivation_(i) & vbCRLF Next WriteLine strMessage, objOutputFile If Err.Number Then Err.Clear End If End If If blnMethods Then WriteLine "METHODS", objOutputFile k = 0 For Each objWbemMethod in objWBEM.Methods_ WriteLine "Method name = " & objWbemMethod.Name, objOutputFile i = 0 Set objParameter = objWbemMethod.InParameters For Each objWbemProperty in objParameter.Properties_ If Err.Number Then Err.Clear Else i = i + 1 strMessage = strPackString(" " & objWbemProperty.Name, 30, 1, 0) strMessage = strMessage & strPackString("In", 10, 1, 0) strMessage = strMessage & _ strPackString(strCIMType(objWbemProperty.CIMType), 20, 1, 0) WriteLine strMessage, objOutputFile End If Next If Err.Number Then Err.Clear End If j = 0 Set objParameter = objWbemMethod.OutParameters For Each objWbemProperty in objParameter.Properties_ If Err.Number Then Err.Clear Else j = j + 1 strMessage = strPackString(" " & objWbemProperty.Name, 30, 1, 0) strMessage = strMessage & strPackString("Out", 10, 1, 0) strMessage = strMessage & _ strPackString(strCIMType(objWbemProperty.CIMType), 20, 1, 0) WriteLine strMessage, objOutputFile End If Next If Err.Number Then Err.Clear End If If i = 0 and j = 0 Then WriteLine " (None)", objOutputFile End If If blnQualifiers Then Call ShowQualifiers(objWbemMethod, objOutputFile, 0) End If If Err.Number Then Err.Clear End If k = k + 1 Next If k = 0 Then WriteLine "There is no method for this object.", objOutputFile End If End If If blnQualifiers Then WriteLine vbCRLF & "QUALIFIERS", objOutputFile i = intShowQualifiers(objWBEM, objOutputFile, 1) If i = 0 Then WriteLine "(None)", objOutputFile End If End If End Sub '******************************************************************** '* '* Function intShowQualifiers() '* Purpose: Shows qualifiers of a WBEM object. '* Input: objWBEM a WBEM object '* objOutputFile an output file object '* blnHeader specifies whether to display a header '* Output: Results are either printed on screen or saved in strOutputFile. '* intShowQualifiers is set to the number of qualifiers found. '* '******************************************************************** Private Function intShowQualifiers(objWBEM, objOutputFile, blnHeader) ON ERROR RESUME NEXT Dim objQualifier, strMessage, i 'Print a header If blnHeader Then strMessage = strPackString("Name", 15, 1, 0) strMessage = strMessage & strPackString("IsLocal", 10, 1, 0) strMessage = strMessage & strPackString("Override", 10, 1, 0) strMessage = strMessage & strPackString("ToInstance", 10, 1, 0) strMessage = strMessage & strPackString("ToSubClass", 10, 1, 0) strMessage = strMessage & strPackString("Value", 20, 1, 0) WriteLine strMessage & vbCRLF, objOutputFile End If i = 0 For Each objQualifier in objWBEM.Qualifiers_ strMessage = strPackString(objQualifier.Name, 15, 1, 0) strMessage = strMessage & strPackString(objQualifier.IsLocal, 10, 1, 0) strMessage = strMessage & strPackString(objQualifier.IsOverridable, 10, 1, 0) strMessage = strMessage & strPackString(objQualifier.PropagatesToInstance, 10, 1, 0) strMessage = strMessage & strPackString(objQualifier.PropagatesToSubClass, 10, 1, 0) strMessage = strMessage & strPackString(objQualifier.Value, 20, 1, 0) WriteLine strMessage, objOutputFile If Err.Number Then Err.Clear End If i = i + 1 Next intShowQualifiers = i End Function '******************************************************************** '* '* Function strCIMType() '* Purpose: Finds the namd of CIMType corresponding to an integer. '* Input: intCIMType an integer corresponding to a CIM type '* Output: strCIMType is returned as the name of the CIM type. '* '******************************************************************** Private Function strCIMType(intCIMType) Select Case intCIMType Case 2 strCIMType = "CIM_SINT16" Case 3 strCIMType = "CIM_SINT32" Case 4 strCIMType = "CIM_REAL32" Case 5 strCIMType = "CIM_REAL64" Case 8 strCIMType = "CIM_STRING" Case 11 strCIMType = "CIM_BOOLEAN" Case 13 strCIMType = "CIM_OBJECT" Case 17 strCIMType = "CIM_UINT8" Case 18 strCIMType = "CIM_UINT16" Case 19 strCIMType = "CIM_UINT32" Case 20 strCIMType = "CIM_SINT64" Case 21 strCIMType = "CIM_UINT64" Case 101 strCIMType = "CIM_DATETIME" Case 102 strCIMType = "CIM_REFERENCE" Case 103 strCIMType = "CIM_CHAR16" Case Else strCIMType = CStr(intCIMType) End Select End Function '******************************************************************** '* '* Function strPackString() '* Purpose: Attaches spaces to a string to increase the length to intLength. '* Input: strString a string '* intLength the intended length of the string '* blnAfter specifies whether to add spaces after or before the string '* blnTruncate specifies whether to truncate the string or not if '* the string length is longer than intLength '* Output: strPackString is returned as the packed string. '* '******************************************************************** Private Function strPackString(strString, ByVal intLength, blnAfter, blnTruncate) ON ERROR RESUME NEXT intLength = CInt(intLength) blnAfter = CBool(blnAfter) blnTruncate = CBool(blnTruncate) If Err.Number Then Print "Argument type is incorrect!" Err.Clear Wscript.Quit End If If IsNull(strString) Then strPackString = "null" & Space(intLength-4) Exit Function End If strString = CStr(strString) If Err.Number Then Print "Argument type is incorrect!" Err.Clear Wscript.Quit End If If intLength > Len(strString) Then If blnAfter Then strPackString = strString & Space(intLength-Len(strString)) Else strPackString = Space(intLength-Len(strString)) & strString & " " End If Else If blnTruncate Then strPackString = Left(strString, intLength-1) & " " Else strPackString = strString & " " End If End If End Function '******************************************************************** '* '* Sub WriteLine() '* Purpose: Writes a text line either to a file or on screen. '* Input: strMessage the string to print '* objFile an output file object '* Output: strMessage is either displayed on screen or written to a file. '* '******************************************************************** Sub WriteLine(ByRef strMessage, ByRef objFile) If IsObject(objFile) then 'objFile should be a file object objFile.WriteLine strMessage Else Wscript.Echo strMessage End If End Sub '******************************************************************** '* '* Sub Print() '* Purpose: Prints a message on screen if blnQuiet = False. '* Input: strMessage the string to print '* Output: strMessage is printed on screen if blnQuiet = False. '* '******************************************************************** Sub Print(ByRef strMessage) If Not blnQuiet then Wscript.Echo strMessage End If End Sub '******************************************************************** '* * '* End of File * '* * '******************************************************************** '******************************************************************** '* '* Procedures calling sequence: LISTPROPERTIES.VBS -wbem '* '* intParseCmdLine '* ShowUsage '* ListProperties '* WriteLine '* '******************************************************************** '******************************************************************** '* '* Sub Debug() '* Purpose: Prints a debug message and the error condition. '* Input: i an integer '* strMessage a message string '* Output: A message is printed on screen. '* '******************************************************************** Sub Debug(i, strMessage) If Err.Number then Wscript.echo "Error 0X" & Hex(Err.Number) & " occurred." Wscript.echo "Error description " & i & " " & Err.Description Wscript.echo strMessage ' Err.Clear Else Wscript.echo "No problem " & i Wscript.echo strMessage End If End Sub '******************************************************************** '* '* Sub PrintArray() '* Purpose: Prints all elements of an array on screen. '* Input: strArray an array name '* Output: All elements of the array are printed on screen. '* '******************************************************************** Sub PrintArray(strArray) Dim i For i = 0 To UBound(strArray) Wscript.echo strArray(i) Next End Sub
Option Explicit '-------------------------------------------------------------------------- '-- SetBldStatus.vbs '-------------------------------------------------------------------------- '-- This a wrapper script for pushing build status information into the '-- buildinfo database. '-- '-------------------------------------------------------------------------- '-- 2002-05-01 <EMAIL> '-- Cleaned up pre-existing code. '-- 2002-05-13 <EMAIL> '-- Fixed status translation. const DB_CONNECT_STRING = "PROVIDER=SQLOLEDB;DRIVER={SQL SERVER};SERVER=primecd-ixf;DATABASE=buildinfo;User Id=SCRIPT;Password=<PASSWORD>" const adCmdStoredProc = 4 const adInteger = 3 const adparamInput = 1 const adparamOutput = 2 const adChar = 129 const adVarChar = 200 Main '-------------------------------------------------------------------------- public sub Main if wscript.arguments.count <> 4 then wscript.stdout.writeline "Error: Wrong number of arguments" Usage wscript.quit end if WriteBuildRecord wscript.arguments(0) , wscript.arguments(1) , wscript.arguments(2) , wscript.arguments(3) end sub '-------------------------------------------------------------------------- public sub Usage wscript.stdout.writeline "SetBldStatus.vbs [buildname] [language] [branch] [status]" end sub '-------------------------------------------------------------------------- '-- WriteBuildRecord public sub WriteBuildRecord( buildnumber , language , branch , status ) dim dbCon , dbCmd , dbParamSwitch , dbParamUser , switch '-- Open a connection to the database and get a ADODB Commend set dbCon = GetDbConnect( DB_CONNECT_STRING ) set dbCmd = GetDbCmd( dbCon , adCmdStoredProc , "spPubBuild" ) '-- Build the Switch parameter. switch = "+build:" + buildnumber + " (" + language + ") +branch:" + branch + " +status:" + status set dbParamSwitch = GetDBParameter( "@Switch" , adChar , 7000 , adParamInput , switch ) dbCmd.Parameters.Append( dbParamSwitch ) '-- Build the user parameter set dbParamUser = GetDBParameter( "@Username" , adChar , 255 , adParamInput , "SetBuildStatus.vbs" ) dbCmd.Parameters.Append( dbParamUser ) '-- Execute the command and close the connection dbCmd.Execute dbCon.Close End Sub '-------------------------------------------------------------------------- '-- Standard ADODB Functions Public Function GetDBConnect( connectStr ) dim dbcon set dbCon = CreateObject( "ADODB.Connection" ) dbCon.Open connectStr dbCon.CommandTimeOut = 180 set GetDBConnect = DbCon end Function Public Function GetDBCmd( DBConnection , cmdType , cmdText ) dim dbCmd set DbCmd = Createobject("ADODB.Command") DBCmd.CommandTimeOut = 180 DbCmd.ActiveConnection = DbConnection DbCmd.CommandType = cmdType DbCmd.CommandText = cmdText set GetDBCmd = DbCmd end Function Public Function GetDBParameter( pName , pType , pSize , pDirection , pValue ) dim DBParam set DBParam = CreateObject( "ADODB.Parameter") DBParam.Name = pName DBParam.Type = pType DBParam.Size = pSize DBParam.Direction = pDirection DBParam.Value = pValue Set GetDBParameter = DBParam end function
<reponame>npocmaka/Windows-Server-2003 Attribute VB_Name = "WCHelper" ' ' WCHelper January 17, 2000 ' Option Explicit 'VB format - function '-------------------- 'Declare Function name Lib ["SYS" | "GSM"] "function name" [([arglist])] [As type] 'VB format - Sub '--------------- 'Declare Sub name Lib ["SYS" | "GSM"] "function name" [([arglist])] '--------------------------------------------------------------------- 'Constants '---------- '* Reserved UIDs * Public Const PRINCIPALUID_INVALID = &H0 Public Const PRINCIPALUID_ANONYMOUS = &H1 '* fileAttribute * Public Const FILEATTR_FILEF = &H0 Public Const FILEATTR_DIRF = &H8000 Public Const FILEATTR_ACLF = &H4000 Public Const FILEATTR_RSRV1 = &H2000 Public Const FILEATTR_RSRV2 = &H1000 '* setPosition Modes * Public Const FILE_BEGIN = 0 Public Const FILE_CURRENT = 1 Public Const FILE_END = 2 '* resourceType * Public Const RESOURCETYPE_FILE = &H0 Public Const RESOURCETYPE_DIR = &H10 Public Const RESOURCETYPE_COMMAND = &H20 'Reserved for future use Public Const RESOURCETYPE_CHANNEL = &H30 'Reserved for future use Public Const RESOURCETYPE_ANY = &HE0 Public Const SCW_RESOURCETYPE_FILE = &H0 Public Const SCW_RESOURCETYPE_DIR = &H10 Public Const SCW_RESOURCETYPE_COMMAND = &H20 'Reserved for future use Public Const SCW_RESOURCETYPE_CHANNEL = &H30 'Reserved for future use Public Const SCW_RESOURCETYPE_ANY = &HE0 '* resourceOperation on RESOURCETYPE_FILE * Public Const RESOURCEOPERATION_FILE_READ = RESOURCETYPE_FILE Or &H1 Public Const RESOURCEOPERATION_FILE_WRITE = RESOURCETYPE_FILE Or &H2 Public Const RESOURCEOPERATION_FILE_EXECUTE = RESOURCETYPE_FILE Or &H3 Public Const RESOURCEOPERATION_FILE_EXTEND = RESOURCETYPE_FILE Or &H4 Public Const RESOURCEOPERATION_FILE_DELETE = RESOURCETYPE_FILE Or &H5 Public Const RESOURCEOPERATION_FILE_GETATTRIBUTES = RESOURCETYPE_FILE Or &H6 Public Const RESOURCEOPERATION_FILE_SETATTRIBUTES = RESOURCETYPE_FILE Or &H7 Public Const RESOURCEOPERATION_FILE_CRYPTO = RESOURCETYPE_FILE Or &H8 Public Const RESOURCEOPERATION_FILE_INCREASE = 0 Public Const RESOURCEOPERATION_FILE_DECREASE = 0 Public Const SCW_RESOURCEOPERATION_FILE_READ = RESOURCETYPE_FILE Or &H1 Public Const SCW_RESOURCEOPERATION_FILE_WRITE = RESOURCETYPE_FILE Or &H2 Public Const SCW_RESOURCEOPERATION_FILE_EXECUTE = RESOURCETYPE_FILE Or &H3 Public Const SCW_RESOURCEOPERATION_FILE_EXTEND = RESOURCETYPE_FILE Or &H4 Public Const SCW_RESOURCEOPERATION_FILE_DELETE = RESOURCETYPE_FILE Or &H5 Public Const SCW_RESOURCEOPERATION_FILE_GETATTRIBUTES = RESOURCETYPE_FILE Or &H6 Public Const SCW_RESOURCEOPERATION_FILE_SETATTRIBUTES = RESOURCETYPE_FILE Or &H7 Public Const SCW_RESOURCEOPERATION_FILE_CRYPTO = RESOURCETYPE_FILE Or &H8 '* resourceOperation on RESOURCETYPE_DIR * Public Const RESOURCEOPERATION_DIR_ACCESS = RESOURCETYPE_DIR Or &H1 Public Const RESOURCEOPERATION_DIR_CREATEFILE = RESOURCETYPE_DIR Or &H2 Public Const RESOURCEOPERATION_DIR_ENUM = RESOURCETYPE_DIR Or &H3 Public Const RESOURCEOPERATION_DIR_DELETE = RESOURCETYPE_DIR Or &H4 Public Const RESOURCEOPERATION_DIR_GETATTRIBUTES = RESOURCETYPE_DIR Or &H5 Public Const RESOURCEOPERATION_DIR_SETATTRIBUTES = RESOURCETYPE_DIR Or &H6 Public Const SCW_RESOURCEOPERATION_DIR_ACCESS = RESOURCETYPE_DIR Or &H1 Public Const SCW_RESOURCEOPERATION_DIR_CREATEFILE = RESOURCETYPE_DIR Or &H2 Public Const SCW_RESOURCEOPERATION_DIR_ENUM = RESOURCETYPE_DIR Or &H3 Public Const SCW_RESOURCEOPERATION_DIR_DELETE = RESOURCETYPE_DIR Or &H4 Public Const SCW_RESOURCEOPERATION_DIR_GETATTRIBUTES = RESOURCETYPE_DIR Or &H5 Public Const SCW_RESOURCEOPERATION_DIR_SETATTRIBUTES = RESOURCETYPE_DIR Or &H6 '* resourceOperation on any resource * Public Const RESOURCEOPERATION_SETACL = RESOURCETYPE_ANY Or &H1D Public Const RESOURCEOPERATION_GETACL = RESOURCETYPE_ANY Or &H1E Public Const RESOURCEOPERATION_ANY = RESOURCETYPE_ANY Or &H1F Public Const SCW_RESOURCEOPERATION_SETACL = RESOURCETYPE_ANY Or &H1D Public Const SCW_RESOURCEOPERATION_GETACL = RESOURCETYPE_ANY Or &H1E Public Const SCW_RESOURCEOPERATION_ANY = RESOURCETYPE_ANY Or &H1F '* Cryptographic Mechanisms * Public Const CM_SHA = &H80 Public Const CM_DES = &H90 Public Const CM_3DES = &HA0 Public Const CM_RSA = &HB0 Public Const CM_RSA_CRT = &HC0 '* Cryptographic Mechanisms properties * Public Const CM_KEY_INFILE = 1 Public Const CM_DATA_INFILE = 2 Public Const CM_SAVE_KEY = 0 'NYI Public Const CM_REUSE_KEY = 0 'NYI '* DES/Triple DES modes * Public Const DES_ENCRYPT = &H0 Public Const DES_DECRYPT = &H20 Public Const DES_ECB = &H0 Public Const DES_MAC = &H10 Public Const DES_CBC = &H40 Public Const MODE_DES_ENCRYPT = &H0 Public Const MODE_DES_DECRYPT = &H20 Public Const MODE_DES_ECB = &H0 Public Const MODE_DES_MAC = &H10 Public Const MODE_DES_CBC = &H40 '* Triple DES specific modes * Public Const MODE_TWO_KEYS_3DES = &H1 Public Const MODE_THREE_KEYS_3DES = &H0 '* RSA modes * Public Const RSA_SIGN = &H0 Public Const RSA_AUTH = &H1 Public Const MODE_RSA_SIGN = &H0 Public Const MODE_RSA_AUTH = &H1 '* Authentication protocols * Public Const SCW_AUTHPROTOCOL_AOK = &H0 Public Const SCW_AUTHPROTOCOL_PIN = &H1 Public Const SCW_AUTHPROTOCOL_DES = &H5 Public Const SCW_AUTHPROTOCOL_3DES = &H6 Public Const SCW_AUTHPROTOCOL_RTE = &H7 Public Const SCW_AUTHPROTOCOL_NEV = &HFF Public Const SCW_AUTHPROTOCOL_INT = &HFF Public Const SCW_AUTHPROTOCOL_GMT = &HFF '* ACL types * Public Const SCW_ACLTYPE_DISJUNCTIVE = 0 Public Const SCW_ACLTYPE_CONJUNCTIVE = 1 '--------------------------------------------------------------------- 'Non-Error Constants '---------- Public Const SCW_S_OK = &H0 Public Const SCW_S_FALSE = &H1 '--------------------------------------------------------------------- 'System Error Constants '---------- Public Const SCW_E_NOTIMPLEMENTED = &H80 Public Const SCW_E_OUTOFRANGE = &H81 Public Const SCW_E_READFAILURE = &H82 Public Const SCW_E_WRITEFAILURE = &H83 Public Const SCW_E_PARTITIONFULL = &H84 Public Const SCW_E_INVALIDPARAM = &H85 Public Const SCW_E_DIRNOTFOUND = &H86 Public Const SCW_E_FILENOTFOUND = &H87 Public Const SCW_E_BADDIR = &H88 Public Const SCW_E_INITFAILED = &H89 Public Const SCW_E_MEMORYFAILURE = &H8A Public Const SCW_E_ACCESSDENIED = &H8B Public Const SCW_E_ALREADYEXISTS = &H8C Public Const SCW_E_BUFFERTOOSMALL = &H8D Public Const SCW_E_DIRNOTEMPTY = &H8E Public Const SCW_E_NOTAUTHORIZED = &H8F Public Const SCW_E_TOOMANYACLS = &H90 Public Const SCW_E_NOTAUTHENTICATED = &H91 Public Const SCW_E_UNAVAILABLECRYPTOGRAPHY = &H92 Public Const SCW_E_INCORRECTPADDING = &H93 Public Const SCW_E_TOOMANYOPENFILES = &H94 Public Const SCW_E_ACCESSVIOLATION = &H95 Public Const SCW_E_BADFILETYPE = &H96 Public Const SCW_E_NOMOREFILES = &H97 Public Const SCW_E_NAMETOOLONG = &H98 Public Const SCW_E_BADACLFILE = &H99 Public Const SCW_E_BADKPFILE = &H9A Public Const SCW_E_FILEALREADYOPEN = &H9B Public Const SCW_E_BACKUPFAILURE = &H9C Public Const SCW_E_TOOMANYREFERENCES = &H9D Public Const SCW_E_VMSTKOVRFLOW = &HE0 Public Const SCW_E_VMSTKUNDRFLOW = &HE1 Public Const SCW_E_VMBADINSTRUCTION = &HE2 Public Const SCW_E_VMREADVARFAILED = &HE3 Public Const SCW_E_VMWRITEVARFAILED = &HE4 Public Const SCW_E_VMMATHSTKOVRFLOW = &HE5 Public Const SCW_E_VMMATHSTKUNDRFLOW = &HE6 Public Const SCW_E_VMMATHOVRFLOW = &HE7 Public Const SCW_E_VMNOMEMORY = &HE8 Public Const SCW_E_VMWRONGVERSION = &HE9 Public Const SCW_E_UNKNOWNPRINCIPAL = &HA1 Public Const SCW_E_UNKNOWNRESOURCETYPE = &HA2 Public Const SCW_INVALID_PRINCIPALUID = -1 Public Const SCW_INVALID_CRYPTOMECHANISM = -1 Public Const SCW_INVALID_OFFSET = -1 Public Const SCW_INVALID_HFILE = -1 '--------------------------------------------------------------------- ' VB Error Constants '-------------- Public Const NoException = &H0 Public Const DivideByZero = &H1 Public Const MathOverflow = &H2 Public Const MathUnderflow = &H3 Public Const CodeOutOfRange = &H4 Public Const DataOutOfRange = &H5 Public Const ScratchOutOfRange = &H6 Public Const IOPointerOutOfRange = &H7 Public Const MathStackOverflow = &H8 Public Const MathStackUnderflow = &H9 Public Const CallStackOverflow = &HA Public Const CallStackUnderflow = &HB Public Const NoSuchInstruction = &HC Public Const FSException = &HD Public Const ReentrancyDetected = &HE Public Const ArrayOutOfBounds = &HF Public Const AssignmentOverflow = &H10 ' ' Note: All Scw routines with parameters of type String will also accept Byte arrays. ' These are Unicode strings, so the array elements must be Unicode characters ' (one Unicode character is two Bytes) and the string must be terminated with a ' Unicode NULL (two Bytes set to zero). ' Public Enum ScwBitOperationType BITWISE_AND = 0 BITWISE_OR = 1 BITWISE_NOT = 2 BITWISE_XOR = 3 SWAP_BYTE_ORDER = 4 SHIFT_RIGHT = 5 SHIFT_LEFT = 6 COMPARE_BYTES = 7 SMSPACK_STRING = 8 SMSUNPACK_STRING = 9 End Enum Public Type ExecuteROMInfo ROMTableIndex As Byte P1 As Byte P2 As Byte Lc As Byte End Type Public Enum ScwOSParam CURRENT_CLA = 0 CURRENT_INS = 1 CURRENT_P1 = 2 CURRENT_P2 = 3 CURRENT_LC = 4 CURRENT_FILE_HANDLE = 5 CURRENT_DIRECTORY_HANDLE = 6 End Enum '-------------------------- 'Byte Array Helper Routines '-------------------------- Public Declare Sub InitializeStaticArray Lib "sys" (StaticArray() As Any, VarArgs As Any) Public Declare Sub ScwBitOperation Lib "sys" (ByVal Operation As ScwBitOperationType, Source() As Byte, ByVal SourceIndex As Byte, Destination() As Byte, ByVal DestinationIndex As Byte, ByVal Count As Byte) Public Declare Sub ScwByteCopy Lib "sys" (Source() As Byte, ByVal SourceIndex As Byte, Destination() As Byte, ByVal DestinationIndex As Byte, ByVal Count As Byte) Public Declare Function ScwByteCompare Lib "sys" (Bytes1() As Byte, ByVal Bytes1Index As Byte, Bytes2() As Byte, ByVal Bytes2Index As Byte, ByVal Count As Byte) As Byte '--------------------------------------------------------------------- ' Communication '--------------- ' Note on type Any: Can pass constant, simple variable, array, structure, or string (Unicode) Public Declare Sub ScwSendComm Lib "sys" (SendData As Any) Public Declare Sub ScwSendCommBytes Lib "sys" (ByteData() As Byte, ByVal offset As Byte, ByVal Count As Byte) Public Declare Sub ScwSendCommByte Lib "sys" (ByVal Value As Byte) Public Declare Sub ScwSendCommInteger Lib "sys" (ByVal Value As Integer) Public Declare Sub ScwSendCommLong Lib "sys" (ByVal Value As Long) ' Note on type Any: Can pass simple variable, array, and structure (no constant or string) Public Declare Sub ScwGetComm Lib "sys" (GetData As Any) Public Declare Sub ScwGetCommBytes Lib "sys" (ByteData() As Byte, ByVal offset As Byte, ByVal Count As Byte) Public Declare Function ScwGetCommByte Lib "sys" () As Byte Public Declare Function ScwGetCommInteger Lib "sys" () As Integer Public Declare Function ScwGetCommLong Lib "sys" () As Long '--------------------------------------------------------------------- ' File System '------------- Public Declare Function ScwCreateFile Lib "sys" (ByVal FileName As String, ByVal ACLFileName As String, FileHandle As Byte) As Byte Public Declare Function ScwCreateDir Lib "sys" (ByVal DirName As String, ByVal ACLFileName As String) As Byte Public Declare Function ScwDeleteFile Lib "sys" (ByVal FileName As String) As Byte Public Declare Function ScwCloseFile Lib "sys" (ByVal FileHandle As Byte) As Byte ' Note on type Any: Can pass simple variable, array, or structure (no constant or string) Public Declare Function ScwReadFile Lib "sys" (ByVal FileHandle As Byte, ReadData As Any, ByVal RequestedBytes As Byte, ActualBytes As Byte) As Byte ' Note on type Any: Can pass constant, simple variable, array, or structure (no string) Public Declare Function ScwWriteFile Lib "sys" (ByVal FileHandle As Byte, WriteData As Any, ByVal RequestedBytes As Byte, ActualBytes As Byte) As Byte Public Declare Function ScwGetFileLength Lib "sys" (ByVal FileHandle As Byte, Size As Integer) As Byte Public Declare Function ScwSetFileLength Lib "sys" (ByVal FileHandle As Byte, ByVal Size As Integer) As Byte Public Declare Function ScwGetFileAttributes Lib "sys" (ByVal FileName As String, Value As Integer) As Byte Public Declare Function ScwSetFileAttributes Lib "sys" (ByVal FileName As String, ByVal Value As Integer) As Byte Public Declare Function ScwSetFilePointer Lib "sys" (ByVal FileHandle As Byte, ByVal Distance As Integer, ByVal Mode As Byte) As Byte Public Declare Function ScwSetFileACL Lib "sys" (ByVal FileName As String, ByVal ACLFileName As String) As Byte Public Declare Function ScwGetFileACLHandle Lib "sys" (ByVal FileName As String, FileHandle As Byte) As Byte Public Declare Function ScwSetDispatchTable Lib "sys" (ByVal FileName As String) As Byte '--------------------------------------------------------------------- ' Access Control '---------------- Public Declare Function ScwGetPrincipalUID Lib "sys" (ByVal Name As String, UID As Byte) As Byte ' Note on type Any: Can pass byte array or constant 0 to indicate no support data Public Declare Function ScwAuthenticateName Lib "sys" (ByVal Name As String, SupportData As Any, ByVal SupportDataLength As Byte) As Byte Public Declare Function ScwDeAuthenticateName Lib "sys" (ByVal Name As String) As Byte Public Declare Function ScwIsAuthenticatedName Lib "sys" (ByVal Name As String) As Byte ' Note on type Any: Can pass byte array or constant 0 to indicate no support data Public Declare Function ScwAuthenticateUID Lib "sys" (ByVal UID As Byte, SupportData As Any, ByVal SupportDataLength As Byte) As Byte Public Declare Function ScwDeAuthenticateUID Lib "sys" (ByVal UID As Byte) As Byte Public Declare Function ScwIsAuthenticatedUID Lib "sys" (ByVal UID As Byte) As Byte Public Declare Function ScwIsAuthorized Lib "sys" (ByVal ResourceName As String, ByVal Operation As Byte) As Byte '--------------------------------------------------------------------- ' CryptoGraphy '-------------- Public Declare Function ScwCryptoInitialize Lib "sys" (ByVal CryptoMechanism As Byte, KeyMaterial() As Byte) As Byte Public Declare Function ScwCryptoAction Lib "sys" (DataIn() As Byte, ByVal DataInLength As Byte, DataOut() As Byte, DataOutLength As Byte) As Byte Public Declare Function ScwCryptoUpdate Lib "sys" (DataIn() As Byte, ByVal DataInLength As Byte) As Byte Public Declare Function ScwCryptoFinalize Lib "sys" (DataOut() As Byte, DataOutLength As Byte) As Byte Public Declare Function ScwGenerateRandom Lib "sys" (DataOut() As Byte, ByVal DataOutLength As Byte) As Byte '--------------------------------- ' Execution '---------- 'Note, in order to send data to the application being executed, use ScwSendComm.... 'in order to receive bytes returned from the application being executed, use ScwGetComm.... Public Declare Sub ScwExecuteInROM Lib "sys" (ROMInfo As ExecuteROMInfo) 'Note, in order to send data to the application being executed, use ScwSendComm.... 'Once this sub routine is called, it will never return, it is similar to calling Exit Public Declare Sub ScwChainRTEApplet Lib "sys" (RTEFile As String, DataFile As String) Public Declare Function ScwGetOSParam Lib "sys" (ByVal OSParam As ScwOSParam) As Byte '--------------------------------------------------------------------- ' Simulator Debug Output (Debug only) '--------------------------------------------------------------------- ' Note on type Any: Can pass constant, simple variable, or string (no array or structure) Public Declare Sub ScwDebugOut Lib "sys" (message As Any) '-------------- ' GSM support '-------------- '--------------------------------- ' Proactive Command Return Values '--------------------------------- Public Const GSM_E_COMMAND_SUCCESSFUL = 0 Public Const GSM_E_ABORTED_BY_USER = 10 Public Const GSM_E_BACKWARD = 11 Public Const GSM_E_NO_RESPONSE = 12 Public Const GSM_E_HELP_REQUIRED = 13 Public Const GSM_E_USSD_ABORTED_BY_USER = 14 '---------------------------------- ' GSM User Defined Types '---------------------------------- Public Enum GsmTimeUnit GSM_MINUTES = &H0 GSM_SECONDS = &H1 GSM_TENTHS_OF_SECONDS = &H2 End Enum Public Type GsmTimeInterval timeUnit As Byte 'One of GsmTimeUnit enumerations timeInterval As Byte End Type Public Type GsmTimerValue hours As Byte minutes As Byte seconds As Byte End Type '-------------------- ' Proactive Commands '-------------------- 'MMI management 'Public Declare Function GsmDisplayText Lib "GSM" (ByVal text As String, ByVal dcs As GsmDataCodingScheme, ByVal options As GsmDisplayTextOptions, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption, ByVal immediateResponse As Boolean) As Byte Public Declare Function GsmDisplayText Lib "GSM" (ByVal text As String, ByVal dcs As GsmDataCodingScheme, ByVal options As GsmDisplayTextOptions, ByVal immediateResponse As Boolean) As Byte Public Declare Function GsmDisplayTextWithIcon Lib "GSM" (ByVal text As String, ByVal dcs As GsmDataCodingScheme, ByVal options As GsmDisplayTextOptions, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption, ByVal immediateResponse As Boolean) As Byte Public Declare Function GsmDisplayTextEx Lib "GSM" (text() As Byte, ByVal textStartIndex As Byte, ByVal textLength As Byte, ByVal dcs As GsmDataCodingScheme, ByVal options As GsmDisplayTextOptions, ByVal iconIdentifier As Byte, iconOptions As GsmIconOption, ByVal immediateResponse As Boolean) As Byte 'Public Declare Function GsmGetInKey Lib "GSM" (text As String, ByVal dcs As GsmDataCodingScheme, ByVal options As GsmGetInKeyOptions, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption, dcsOut As GsmDataCodingScheme, byteOut As Byte) As Byte Public Declare Function GsmGetInKey Lib "GSM" (text As String, ByVal dcs As GsmDataCodingScheme, ByVal options As GsmGetInKeyOptions, dcsOut As Byte, byteOut As Byte) As Byte Public Declare Function GsmGetInKeyWithIcon Lib "GSM" (text As String, ByVal dcs As GsmDataCodingScheme, ByVal options As GsmGetInKeyOptions, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption, dcsOut As Byte, byteOut As Byte) As Byte Public Declare Function GsmGetInKeyEx Lib "GSM" (text() As Byte, ByVal textStartIndex As Byte, ByVal textLength As Byte, ByVal dcs As GsmDataCodingScheme, ByVal options As GsmGetInKeyOptions, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption, dcsOut As Byte, byteOut As Byte) As Byte 'Public Declare Function GsmGetInput Lib "GSM" (message As String, ByVal dcs As GsmDataCodingScheme, ByVal options As GsmGetInputOptions, defaultReply As String, ByVal defaultReplyDcs As GsmDataCodingScheme, ByVal minimumResponseLength As Byte, ByVal maximumResponseLength As Byte, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption, dcsOut As Byte, msgOut() As Byte, MsgOutLength As Byte) As Byte Public Declare Function GsmGetInput Lib "GSM" (message As String, ByVal dcs As GsmDataCodingScheme, ByVal options As GsmGetInputOptions, defaultReply As String, ByVal defaultReplyDcs As GsmDataCodingScheme, ByVal minimumResponseLength As Byte, ByVal maximumResponseLength As Byte, dcsOut As Byte, msgOut() As Byte, MsgOutLength As Byte) As Byte Public Declare Function GsmGetInputWithIcon Lib "GSM" (message As String, ByVal dcs As GsmDataCodingScheme, ByVal options As GsmGetInputOptions, defaultReply As String, ByVal defaultReplyDcs As GsmDataCodingScheme, ByVal minimumResponseLength As Byte, ByVal maximumResponseLength As Byte, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption, dcsOut As Byte, msgOut() As Byte, MsgOutLength As Byte) As Byte Public Declare Function GsmGetInputEx Lib "GSM" (message() As Byte, ByVal messageStartIndex As Byte, ByVal messageLength As Byte, ByVal dcs As GsmDataCodingScheme, ByVal options As GsmGetInputOptions, defaultReply() As Byte, ByVal defaultReplyStartIndex As Byte, ByVal defaultReplyLength As Byte, ByVal defaultReplyDcs As GsmDataCodingScheme, ByVal minimumResponseLength As Byte, ByVal maximumResponseLength As Byte, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption, dcsOut As Byte, msgOut() As Byte, MsgOutLength As Byte) As Byte Public Declare Function GsmPlayTone Lib "GSM" (displayText As String, ByVal tone As GsmTone, ByVal unit As GsmTimeUnit, ByVal duration As Byte) As Byte Public Declare Function GsmPlayToneEx Lib "GSM" (displayText() As Byte, ByVal displayTextStartIndex As Byte, ByVal displayTextLength As Byte, ByVal tone As GsmTone, ByVal unit As GsmTimeUnit, ByVal duration As Byte) As Byte Public Declare Sub GsmSelectItem Lib "GSM" (title As String, ByVal options As GsmSelectItemOptions) Public Declare Sub GsmSelectItemEx Lib "GSM" (title() As Byte, ByVal titleStartIndex As Byte, ByVal titleLength As Byte, ByVal options As GsmSelectItemOptions) Public Declare Sub GsmAddItem Lib "GSM" (itemText As String, ByVal itemIdentifier As Byte) Public Declare Sub GsmAddItemEx Lib "GSM" (itemText() As Byte, ByVal itemTextStartIndex As Byte, ByVal itemTextLength As Byte, ByVal itemIdentifier As Byte) Public Declare Function GsmEndSelectItem Lib "GSM" (selectedItem As Byte) As Byte Public Declare Function GsmEndSelectItemWithIcon Lib "GSM" (ByVal defaultItem As Byte, ByVal iconIndex As Byte, ByVal iconOptions As GsmIconOption, selectedItem As Byte) As Byte 'Public Declare Function GsmEndSelectItemEx Lib "GSM" (ByVal defaultItem As Byte, ByVal iconIndex As Byte, ByVal iconOptions As GsmIconOption, selectedItem As Byte) As Byte 'Supplementary card reader management Public Declare Function GsmGetReaderStatus Lib "GSM" (ByVal ReaderID As Byte, Status As Byte) As Byte Public Declare Function GsmPerformCardAPDU Lib "GSM" (ByVal ReaderID As Byte, apdu() As Byte, ByVal startIndex As Byte, ByVal length As Byte, response() As Byte, responseLength As Byte) As Byte Public Declare Function GsmPowerOffCard Lib "GSM" (ByVal ReaderID As Byte) As Byte Public Declare Function GsmPowerOnCard Lib "GSM" (ByVal ReaderID As Byte, ATR() As Byte, ATRlength As Byte) As Byte 'Network services Public Declare Function GsmProvideLocalInformation Lib "GSM" (ByVal options As GsmProvideLocalInformationOptions, localInformation() As Byte) As Byte 'Public Declare Function GsmSendShortMessage Lib "GSM" (title As String, ByVal TONandNPI As GsmTypeOfNumberAndNumberingPlanIdentifier, address As String, sms As String, ByVal options As GsmSendShortMessageOptions, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption) As Byte Public Declare Function GsmSendShortMessage Lib "GSM" (title As String, ByVal TONandNPI As GsmTypeOfNumberAndNumberingPlanIdentifier, address As String, sms As String, ByVal options As GsmSendShortMessageOptions) As Byte Public Declare Function GsmSendShortMessageWithIcon Lib "GSM" (title As String, ByVal TONandNPI As GsmTypeOfNumberAndNumberingPlanIdentifier, address As String, sms As String, ByVal options As GsmSendShortMessageOptions, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption) As Byte Public Declare Function GsmSendShortMessageEx1 Lib "GSM" (title As String, ByVal TONandNPI As GsmTypeOfNumberAndNumberingPlanIdentifier, address() As Byte, ByVal addressStartIndex As Byte, ByVal addressLength As Byte, sms() As Byte, ByVal smsStartIndex As Byte, ByVal smsLength As Byte, ByVal options As GsmSendShortMessageOptions, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption) As Byte Public Declare Function GsmSendShortMessageEx2 Lib "GSM" (title() As Byte, ByVal titleStartIndex As Byte, titleLength As Byte, ByVal TONandNPI As GsmTypeOfNumberAndNumberingPlanIdentifier, address() As Byte, ByVal addressStartIndex As Byte, ByVal addressLength As Byte, sms() As Byte, ByVal smsStartIndex As Byte, ByVal smsLength As Byte, ByVal options As GsmSendShortMessageOptions, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption) As Byte 'Public Declare Function GsmSendSS Lib "GSM" (title As String, ByVal TONandNPI As GsmTypeOfNumberAndNumberingPlanIdentifier, SSString As String, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption) As Byte Public Declare Function GsmSendSS Lib "GSM" (title As String, ByVal TONandNPI As GsmTypeOfNumberAndNumberingPlanIdentifier, SSString As String) As Byte Public Declare Function GsmSendSSWithIcon Lib "GSM" (title As String, ByVal TONandNPI As GsmTypeOfNumberAndNumberingPlanIdentifier, SSString As String, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption) As Byte Public Declare Function GsmSendSSEx1 Lib "GSM" (title As String, ByVal TONandNPI As GsmTypeOfNumberAndNumberingPlanIdentifier, SSString() As Byte, ByVal SSStringStartIndex As Byte, ByVal SSStringlength As Byte, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption) As Byte Public Declare Function GsmSendSSEx2 Lib "GSM" (title() As Byte, ByVal titleStartIndex As Byte, ByVal titleLength As Byte, ByVal TONandNPI As GsmTypeOfNumberAndNumberingPlanIdentifier, SSString() As Byte, ByVal SSStringStartIndex As Byte, ByVal SSStringlength As Byte, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption) As Byte 'Public Declare Function GsmSendUSSD Lib "GSM" (title As String, message As String, ByVal messageDcs As GsmUSSDDataCoding, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption, dcsOut As Byte, msgOut() As Byte, MsgOutLength As Byte) As Byte Public Declare Function GsmSendUSSD Lib "GSM" (title As String, message As String, ByVal messageDcs As GsmUSSDDataCoding, dcsOut As Byte, msgOut() As Byte, MsgOutLength As Byte) As Byte Public Declare Function GsmSendUSSDWithIcon Lib "GSM" (title As String, message As String, ByVal messageDcs As GsmUSSDDataCoding, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption, dcsOut As Byte, msgOut() As Byte, MsgOutLength As Byte) As Byte Public Declare Function GsmSendUSSDEx1 Lib "GSM" (title As String, message() As Byte, ByVal messageStartIndex As Byte, ByVal messageLength As Byte, ByVal messageDcs As GsmUSSDDataCoding, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption, dcsOut As Byte, msgOut() As Byte, MsgOutLength As Byte) As Byte Public Declare Function GsmSendUSSDEx2 Lib "GSM" (title() As Byte, ByVal titleStartIndex As Byte, ByVal titleLength As Byte, message() As Byte, ByVal messageStartIndex As Byte, ByVal messageLength As Byte, ByVal messageDcs As GsmUSSDDataCoding, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption, dcsOut As Byte, msgOut() As Byte, MsgOutLength As Byte) As Byte 'Public Declare Function GsmSetupCall Lib "GSM" (callSetupMessage As String, ByVal TONandNPI As GsmTypeOfNumberAndNumberingPlanIdentifier, dialingNumber As String, ByVal options As GsmSetupCallOptions, ByVal callSetupIconIdentifier As Byte, ByVal callSetupIconOptions As GsmIconOption) As Byte Public Declare Function GsmSetupCall Lib "GSM" (callSetupMessage As String, ByVal TONandNPI As GsmTypeOfNumberAndNumberingPlanIdentifier, dialingNumber As String, ByVal options As GsmSetupCallOptions) As Byte Public Declare Function GsmSetupCallWithIcon Lib "GSM" (callSetupMessage As String, ByVal TONandNPI As GsmTypeOfNumberAndNumberingPlanIdentifier, dialingNumber As String, ByVal options As GsmSetupCallOptions, ByVal callSetupIconIdentifier As Byte, ByVal callSetupIconOptions As GsmIconOption) As Byte Public Declare Function GsmSetupCallEx1 Lib "GSM" (callSetupMessage As String, ByVal TONandNPI As GsmTypeOfNumberAndNumberingPlanIdentifier, dialingNumber() As Byte, ByVal dialingNumberStartIndex As Byte, ByVal dialingNumberLength As Byte, ByVal options As GsmSetupCallOptions, ByVal callSetupIconIdentifier As Byte, ByVal callSetupIconOptions As GsmIconOption) As Byte Public Declare Function GsmSetupCallEx2 Lib "GSM" (callSetupMessage() As Byte, ByVal messageStartIndex As Byte, ByVal messageLength As Byte, ByVal TONandNPI As GsmTypeOfNumberAndNumberingPlanIdentifier, dialingNumber() As Byte, ByVal dialingNumberStartIndex As Byte, ByVal dialingNumberLength As Byte, ByVal options As GsmSetupCallOptions, ByVal callSetupIconIdentifier As Byte, ByVal callSetupIconOptions As GsmIconOption) As Byte 'Timer management Public Declare Function GsmGetTimer Lib "GSM" () As Byte Public Declare Function GsmFreeTimer Lib "GSM" (ByVal timerID As Byte) As Byte Public Declare Function GsmStartTimer Lib "GSM" (ByVal timerID As Byte, ByVal timerInitHour As Byte, ByVal timerInitMinute As Byte, ByVal timerInitSecond As Byte) As Byte Public Declare Function GsmGetTimerValue Lib "GSM" (ByVal timerID As Byte, timerValue As GsmTimerValue) As Byte 'Other Public Declare Function GsmMoreTime Lib "GSM" () As Byte 'Public Declare Function GsmRunATCommand Lib "GSM" (message As String, command As String, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption, response() As Byte, responseLength As Byte) As Byte Public Declare Function GsmRunATCommand Lib "GSM" (message As String, command As String, response() As Byte, responseLength As Byte) As Byte Public Declare Function GsmRunATCommandWithIcon Lib "GSM" (message As String, command As String, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption, response() As Byte, responseLength As Byte) As Byte Public Declare Function GsmRunATCommandEx1 Lib "GSM" (message As String, command() As Byte, ByVal commandStartIndex As Byte, ByVal commandLength As Byte, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption, response() As Byte, responseLength As Byte) As Byte Public Declare Function GsmRunATCommandEx2 Lib "GSM" (message() As Byte, ByVal messageStartIndex As Byte, ByVal messageLength As Byte, command() As Byte, ByVal commandStartIndex As Byte, ByVal commandLength As Byte, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption, response() As Byte, responseLength As Byte) As Byte 'Public Declare Function GsmSendDTMF Lib "GSM" (message As String, DTMFString As String, ByVal iconIndex As Byte, ByVal iconOptions As GsmIconOption) As Byte Public Declare Function GsmSendDTMF Lib "GSM" (message As String, DTMFString As String) As Byte Public Declare Function GsmSendDTMFWithIcon Lib "GSM" (message As String, DTMFString As String, ByVal iconIndex As Byte, ByVal iconOptions As GsmIconOption) As Byte Public Declare Function GsmPollInterval Lib "GSM" (ByVal unit As GsmTimeUnit, ByVal interval As Byte, actualIntervalOut As GsmTimeInterval) As Byte Public Declare Function GsmPollingOff Lib "GSM" () As Byte 'Note result bytes has to be an array of at least 8 bytes in length Public Declare Function GsmCipherFile Lib "GSM" (ByVal FileName As String, startOffset As Byte, ResultBytes() As Byte) As Byte Public Declare Function GsmUpdateRegistry Lib "GSM" (activationString As String, ByVal entryIdentifier As Byte, ByVal setupByte As Byte) As Byte Public Declare Function GsmUpdateMenu Lib "GSM" (activationString As String, ByVal entryIdentifier As Byte, ByVal iconIndex As Byte, ByVal setupByte As Byte) As Byte Public Declare Function GsmRefresh Lib "GSM" () As Byte 'In order to get the response Public Declare Sub GsmExecuteProactive Lib "GSM" (command() As Byte, ByVal startIndex, ByVal commandLength As Byte) 'Public Declare Function GsmSetupIdleModeText Lib "GSM" (text As String, ByVal dcs As GsmDataCodingScheme, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption) As Byte Public Declare Function GsmSetupIdleModeText Lib "GSM" (text As String, ByVal dcs As GsmDataCodingScheme) As Byte Public Declare Function GsmSetupIdleModeTextWithIcon Lib "GSM" (text As String, ByVal dcs As GsmDataCodingScheme, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption) As Byte Public Declare Function GsmSetupIdleModeTextEx Lib "GSM" (text() As Byte, ByVal startIndex As Byte, ByVal length As Byte, ByVal dcs As GsmDataCodingScheme, ByVal iconIdentifier As Byte, ByVal iconOptions As GsmIconOption) As Byte Public Declare Sub GsmBlockProactiveCommands Lib "GSM" () Public Declare Sub GsmUnblockProactiveCommands Lib "GSM" () Public Declare Function GsmGetExtendedError Lib "GSM" () As Byte '-------------------------- ' Parameter Enumerations '-------------------------- Public Enum GsmDataCodingScheme SMS_PACKED = &H24 SMS_UNPACKED = &H4 SMS_UNICODE = &H8 End Enum 'Note: There are a variety of possible data coding schemes for USSD messages, this list ' only contains some common encodings, for a full list see the GSM 03.38 [section 5]. Public Enum GsmUSSDDataCoding USSD_PACKED = &H64 USSD_UNPACKED = &H44 USSD_UNICODE = &H48 End Enum Public Enum GsmDisplayTextOptions NORMAL_PRIORITY_AUTO_CLEAR = &H0 NORMAL_PRIORITY_USER_CLEAR = &H80 HIGH_PRIORITY_AUTO_CLEAR = &H1 HIGH_PRIORITY_USER_CLEAR = &H81 End Enum Public Enum GsmGetInKeyOptions YES_NO_OPTION_NO_HELP = &H4 YES_NO_OPTION_WITH_HELP = &H84 DIGITS_ONLY_NO_HELP = &H0 DIGITS_ONLY_WITH_HELP = &H80 SMS_CHARACTER_NO_HELP = &H1 SMS_CHARACTER_WITH_HELP = &H81 UCS2_CHARACTER_NO_HELP = &H3 UCS2_CHARACTER_WITH_HELP = &H83 End Enum Public Enum GsmGetInputOptions PACKED_DIGITS_ONLY_NO_HELP = &H8 PACKED_DIGITS_ONLY_WITH_HELP = &H88 PACKED_DIGITS_ONLY_NO_ECHO_NO_HELP = &HC PACKED_DIGITS_ONLY_NO_ECHO_WITH_HELP = &H8C UNPACKED_DIGITS_ONLY_NO_HELP = &H0 UNPACKED_DIGITS_ONLY_WITH_HELP = &H80 UNPACKED_DIGITS_ONLY_NO_ECHO_NO_HELP = &H4 UNPACKED_DIGITS_ONLY_NO_ECHO_WITH_HELP = &H84 PACKED_SMS_ALPHABET_NO_HELP = &H9 PACKED_SMS_ALPHABET_WITH_HELP = &H89 PACKED_SMS_ALPHABET_NO_ECHO_NO_HELP = &HD PACKED_SMS_ALPHABET_NO_ECHO_HELP = &H8D UNPACKED_SMS_ALPHABET_NO_HELP = &H1 UNPACKED_SMS_ALPHABET_WITH_HELP = &H81 UNPACKED_SMS_ALPHABET_NO_ECHO_NO_HELP = &H5 UNPACKED_SMS_ALPHABET_NO_ECHO_WITH_HELP = &H85 UCS2_ALPHABET_NO_HELP = &H3 UCS2_ALPHABET_WITH_HELP = &H83 UCS2_ALPHABET_NO_ECHO_NO_HELP = &H7 UCS2_ALPHABET_NO_ECHO_WITH_HELP = &H87 End Enum Public Enum GsmSelectItemOptions PRESENT_AS_DATA_VALUES_NO_HELP = &H1 PRESENT_AS_DATA_VALUES_WITH_HELP = &H81 PRESENT_AS_NAVIGATION_OPTIONS_NO_HELP = &H3 PRESENT_AS_NAVIGATION_OPTIONS_WITH_HELP = &H83 DEFAULT_STYLE_NO_HELP = &H0 DEFAULT_STYLE_WITH_HELP = &H80 End Enum Public Enum GsmProvideLocalInformationOptions LOCAL_INFORMATION = &H0 IMEI_OF_THE_PHONE = &H1 NETWORK_MEASUREMENTS = &H2 DATE_TIME_AND_TIME_ZONE = &H3 End Enum Public Enum GsmSendShortMessageOptions PACKING_NOT_REQUIRED = &H0 PACKING_BY_THE_PHONE_REQUIRED = &H1 End Enum Public Enum GsmSetupCallOptions CALL_ONLY_IF_NOT_BUSY = &H0 CALL_ONLY_IF_NOT_BUSY_WITH_REDIAL = &H1 CALL_AND_PUT_CURRENT_CALL_ON_HOLD = &H2 CALL_AND_PUT_CURRENT_CALL_ON_HOLD_WITH_REDIAL = &H3 CALL_AND_DISCONNECT_CURRENT_CALL = &H4 CALL_AND_DISCONNECT_CURRENT_CALL_WITH_REDIAL = &H5 End Enum Public Enum GsmTone DIAL_TONE = &H1 CALLER_BUSY = &H2 CONGESTION = &H3 RADIO_PATH_ACKNOWLEDGE = &H4 CALL_DROPPED = &H5 SPECIAL_INFORMATION_OR_ERROR = &H6 CALL_WAITING_TONE = &H7 RINGING_TONE = &H8 GENERAL_BEEP = &H10 POSITIVE_ACKNOWLEDGE_TONE = &H11 NEGATIVE_ACKNOWLEDGE_TONE = &H12 NO_TONE = &HFF End Enum Public Enum GsmIconOption NO_ICON = &HFF SHOW_WITHOUT_TEXT = &H0 SHOW_WITH_TEXT = &H1 End Enum Public Const ICON_ID_NO_ICON = &HFF Public Enum GsmTypeOfNumberAndNumberingPlanIdentifier TON_UNKNOWN_AND_NPI_UNKNOWN = &H0 TON_INTERNATIONAL_AND_NPI_UNKNOWN = &H10 TON_NATIONAL_AND_NPI_UNKNOWN = &H20 TON_NETWORK_AND_NPI_UNKNOWN = &H30 TON_SUBSCRIBER_AND_NPI_UNKNOWN = &H40 TON_UNKNOWN_AND_NPI_TELEPHONE = &H1 TON_INTERNATIONAL_AND_NPI_TELEPHONE = &H11 TON_NATIONAL_AND_NPI_TELEPHONE = &H21 TON_NETWORK_AND_NPI_TELEPHONE = &H31 TON_SUBSCRIBER_AND_NPI_TELEPHONE = &H41 TON_UNKNOWN_AND_NPI_DATA = &H3 TON_INTERNATIONAL_AND_NPI_DATA = &H13 TON_NATIONAL_AND_NPI_DATA = &H23 TON_NETWORK_AND_NPI_DATA = &H33 TON_SUBSCRIBER_AND_NPI_DATA = &H43 TON_UNKNOWN_AND_NPI_TELEX = &H4 TON_INTERNATIONAL_AND_NPI_TELEX = &H14 TON_NATIONAL_AND_NPI_TELEX = &H24 TON_NETWORK_AND_NPI_TELEX = &H34 TON_SUBSCRIBER_AND_NPI_TELEX = &H44 TON_UNKNOWN_AND_NPI_NATIONAL = &H8 TON_INTERNATIONAL_AND_NPI_NATIONAL = &H18 TON_NATIONAL_AND_NPI_NATIONAL = &H28 TON_NETWORK_AND_NPI_NATIONAL = &H38 TON_SUBSCRIBER_AND_NPI_NATIONAL = &H48 TON_UNKNOWN_AND_NPI_PRIVATE = &H9 TON_INTERNATIONAL_AND_NPI_PRIVATE = &H19 TON_NATIONAL_AND_NPI_PRIVATE = &H29 TON_NETWORK_AND_NPI_PRIVATE = &H39 TON_SUBSCRIBER_AND_NPI_PRIVATE = &H49 TON_UNKNOWN_AND_NPI_ERMES = &HA TON_INTERNATIONAL_AND_NPI_ERMES = &H1A TON_NATIONAL_AND_NPI_ERMES = &H2A TON_NETWORK_AND_NPI_ERMES = &H3A TON_SUBSCRIBER_AND_NPI_ERMES = &H4A End Enum
'//+---------------------------------------------------------------------------- '// '// File: wait.bas '// '// Module: pbadmin.exe '// '// Synopsis: Wrapper functions to launch a process and wait for it to return. '// '// Copyright (c) 1997-1999 Microsoft Corporation '// '// Author: quintinb Created Header 09/02/99 '// '//+---------------------------------------------------------------------------- Attribute VB_Name = "wait" Option Explicit Private Const PROCESS_QUERY_INFORMATION = &H400 Private Const STILL_ACTIVE = &H103 Private Declare Function OpenProcess& Lib "kernel32" (ByVal _ dwDesiredAccess&, ByVal bInheritHandle&, ByVal dwProcessId&) Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal _ hProcess As Long, lpExitCode As Long) As Long Private Const IDC_UPARROW = 32516& ' GetWindow() Constants Public Const GW_HWNDFIRST = 0 Public Const GW_HWNDLAST = 1 Public Const GW_HWNDNEXT = 2 Public Const GW_HWNDPREV = 3 Public Const GW_OWNER = 4 Public Const GW_CHILD = 5 Public Const GW_MAX = 5 Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long Declare Function GetDesktopWindow Lib "user32" () As Long Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long Public Function WaitForApp(sCmd As String) As Long Dim hApp As Long Dim hProc As Long Dim lExitCode As Long On Error GoTo WaitErr 'hApp = Shell(sCmd, vbNormalFocus) 'hApp = Shell(sCmd, vbHide) hApp = Shell(sCmd, vbMinimizedNoFocus) hProc = OpenProcess(PROCESS_QUERY_INFORMATION, False, hApp) Do GetExitCodeProcess hProc, lExitCode DoEvents Loop While lExitCode = STILL_ACTIVE WaitForApp = lExitCode Exit Function WaitErr: Exit Function End Function Public Function GetWindowHandleFromProcessID(hProcessIDToFind As Long) As Long Dim hWindow As Long Dim bFoundIt As Boolean Dim hProcessIDToTest As Long Dim lRet As Long hWindow = GetWindow(GetDesktopWindow(), GW_CHILD) While hWindow <> 0 hProcessIDToTest = 0 lRet = GetWindowThreadProcessId(hWindow, hProcessIDToTest) If hProcessIDToTest = hProcessIDToFind Then bFoundIt = True GetWindowHandleFromProcessID = hWindow Exit Function End If hWindow = GetWindow(hWindow, GW_HWNDNEXT) DoEvents Wend GetWindowHandleFromProcessID = 0 GetWindowHandleFromProcessID = -1 End Function
Function Multiply(lngMcand As Long, lngMplier As Long) As Long Multiply = lngMcand * lngMplier End Function
'******************************************************************** '* '* File: PS.VBS '* Created: July 1998 '* Version: 1.0 '* '* Main Function: Lists all jobs currently running on a machine. '* Usage: 1. PS.VBS [/S:server] [/P:property1[:width1] [/P:property2[:width2]]...] '* [/D:width] [/SORT:A | D[:num] | N] [/O:outputfile] '* [/U:username] [/W:password] [/ALL] [/F] [/O] [/Q] '* 2. PS.VBS [/S:server] [/O:outputfile] [/U:username] [/W:password] '* [/P] [/Q]" '* '* Copyright (C) 1998 Microsoft Corporation '* '******************************************************************** OPTION EXPLICIT ON ERROR RESUME NEXT 'Define constants CONST CONST_ERROR = 0 CONST CONST_WSCRIPT = 1 CONST CONST_CSCRIPT = 2 CONST CONST_SHOW_USAGE = 3 CONST CONST_PROCEED = 4 CONST CONST_SORT_NO = 5 CONST CONST_SORT_ASCENDING = 6 CONST CONST_SORT_DESCENDING = 7 'Declare variables Dim strOutputFile, intOpMode, blnAll, blnListProperties, blnFlush, blnOwner, blnQuiet, i Dim strServer, strUserName, strPassword, intSortOrder, intSortProperty, intWidth ReDim strArgumentArray(0), strProperties(1), intWidths(1) 'Initialize variables strServer = "" strUserName = "" strPassword = "" strOutputFile = "" blnAll = False blnQuiet = False blnListProperties =False blnFlush = False blnOwner = False 'Do not show the owner of a process intSortOrder = CONST_SORT_ASCENDING 'Sort-ascending by default. intSortProperty = 1 'Sort according to the first property. intWidth = 15 strArgumentArray(0) = "" strProperties(0) = "processid" 'Default properties to get intWidths(0) = intWidth strProperties(1) = "name" intWidths(1) = intWidth 'Get the command line arguments For i = 0 to Wscript.arguments.count - 1 ReDim Preserve strArgumentArray(i) strArgumentArray(i) = Wscript.arguments.Item(i) Next 'Check whether the script is run using CScript Select Case intChkProgram() Case CONST_CSCRIPT 'Do Nothing Case CONST_WSCRIPT WScript.Echo "Please run this script using CScript." & vbCRLF & _ "This can be achieved by" & vbCRLF & _ "1. Using ""CScript PS.VBS arguments"" for Windows 95/98 or" & vbCRLF & _ "2. Changing the default Windows Scripting Host setting to CScript" & vbCRLF & _ " using ""CScript //H:CScript //S"" and running the script using" & vbCRLF & _ " ""PS.VBS arguments"" for Windows NT." WScript.Quit Case Else WScript.Quit End Select 'Parse the command line intOpMode = intParseCmdLine(strArgumentArray, strServer, strProperties, intWidths, _ intWidth, intSortOrder, intSortProperty, strOutputFile, strUserName, _ strPassword, blnAll, blnListProperties, blnFlush, blnOwner, blnQuiet) If Err.Number then Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred in parsing the command line." If Err.Description <> "" Then Print "Error description: " & Err.Description & "." End If WScript.Quit End If Select Case intOpMode Case CONST_SHOW_USAGE Call ShowUsage() Case CONST_PROCEED Call ListJobs(strServer, strProperties, intWidths, _ intWidth, intSortOrder, intSortProperty, strOutputFile, _ strUserName, strPassword, blnAll, blnListProperties, blnFlush, blnOwner) Case CONST_ERROR 'Do nothing. Case Else 'Default -- should never happen Print "Error occurred in passing parameters." End Select '******************************************************************** '* '* Function intChkProgram() '* Purpose: Determines which program is used to run this script. '* Input: None '* Output: intChkProgram is set to one of CONST_ERROR, CONST_WSCRIPT, '* and CONST_CSCRIPT. '* '******************************************************************** Private Function intChkProgram() ON ERROR RESUME NEXT Dim strFullName, strCommand, i, j 'strFullName should be something like C:\WINDOWS\COMMAND\CSCRIPT.EXE strFullName = WScript.FullName If Err.Number then Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred." If Err.Description <> "" Then If Err.Description <> "" Then Print "Error description: " & Err.Description & "." End If End If intChkProgram = CONST_ERROR Exit Function End If i = InStr(1, strFullName, ".exe", 1) If i = 0 Then intChkProgram = CONST_ERROR Exit Function Else j = InStrRev(strFullName, "\", i, 1) If j = 0 Then intChkProgram = CONST_ERROR Exit Function Else strCommand = Mid(strFullName, j+1, i-j-1) Select Case LCase(strCommand) Case "cscript" intChkProgram = CONST_CSCRIPT Case "wscript" intChkProgram = CONST_WSCRIPT Case Else 'should never happen Print "An unexpected program is used to run this script." Print "Only CScript.Exe or WScript.Exe can be used to run this script." intChkProgram = CONST_ERROR End Select End If End If End Function '******************************************************************** '* '* Function intParseCmdLine() '* Purpose: Parses the command line. '* Input: strArgumentArray an array containing input from the command line '* Output: strServer a machine name '* strProperties an array containing names of properties to be retrieved '* intWidths an array containing the width of columns used to display '* values of the corresponding properties '* intWidth the default column width '* intSortOrder specifies the sort order (ascend/descend/none) '* intSortProperty specifies a property according to which the results '* will be sorted '* strOutputFile an output file name '* strUserName the current user's name '* strPassword the current user's password '* blnAll specifies whether to list all properties '* blnListProperties lists properties available '* blnFlush specifies whether to use flush output '* blnOwner specifies whether to show the owner of a process '* blnQuiet specifies whether to suppress messages '* intParseCmdLine is set to one of CONST_ERROR, CONST_SHOW_USAGE, CONST_PROCEED. '* '******************************************************************** Private Function intParseCmdLine(strArgumentArray, strServer, strProperties, intWidths, _ intWidth, intSortOrder, intSortProperty, strOutputFile, strUserName, strPassword, _ blnAll, blnListProperties, blnFlush, blnOwner, blnQuiet) ON ERROR RESUME NEXT Dim strFlag, i, j, intColon, strSort strFlag = strArgumentArray(0) If strFlag = "" then 'No arguments have been received intParseCmdLine = CONST_PROCEED Exit Function End If If (strFlag="help") OR (strFlag="/h") OR (strFlag="\h") OR (strFlag="-h") _ OR (strFlag = "\?") OR (strFlag = "/?") OR (strFlag = "?") OR (strFlag="h") Then intParseCmdLine = CONST_SHOW_USAGE Exit Function End If j = 0 For i = 0 to UBound(strArgumentArray) strFlag = LCase(Left(strArgumentArray(i), InStr(1, strArgumentArray(i), ":")-1)) If Err.Number Then 'An error occurs if there is no : in the string Err.Clear Select Case LCase(strArgumentArray(i)) Case "/all" blnAll = True blnOwner = True Case "/f" blnFlush = True Case "/o" blnOwner = True Case "/p" blnListProperties = True Case "/q" blnQuiet = True Case Else Print strArgumentArray(i) & " is not a valid input." Print "Please check the input and try again." intParseCmdLine = CONST_ERROR Exit Function End Select Else Select Case strFlag Case "/s" strServer = Right(strArgumentArray(i), Len(strArgumentArray(i))-3) Case "/d" intWidth = CInt(Right(strArgumentArray(i), Len(strArgumentArray(i))-3)) If Err.Number Then Print "Please enter an integer for the width of a column." Err.Clear intParseCmdLine = CONST_ERROR Exit Function End If Case "/p" ReDim Preserve strProperties(j), intWidths(j) 'Get the string to the right of : strProperties(j) = Right(strArgumentArray(i), Len(strArgumentArray(i))-3) intColon = InStr(1, strProperties(j), ":") If intColon <> 0 Then 'There is a : in strProperties(j) intWidths(j) = CInt(Right(strProperties(j), Len(strProperties(j))-intColon)) If Err.Number Then Print Right(strProperties(j), Len(strProperties(j))-intColon) & _ " is not an integer!" Print "Please check the input and try again." Err.Clear intParseCmdLine = CONST_ERROR Exit Function End If strProperties(j) = Left(strProperties(j), intColon-1) Else 'There is no colon in the string. intWidths(j) = intWidth 'The default. End If j = j + 1 Case "/sort" 'Get the string to the right of /sort: strSort = Right(strArgumentArray(i), Len(strArgumentArray(i))-6) intColon = InStr(1, strSort, ":") If intColon <> 0 Then 'There is a colon in the string. intSortProperty = CInt(Right(strSort, Len(strSort)-intColon)) If Err.Number Then Print Right(strSort, Len(strSort)-intColon) & " is not an integer!" Print "Please check the input and try again." Err.Clear intParseCmdLine = CONST_ERROR Exit Function End If strSort = LCase(Left(strSort, intColon-1)) End If Select Case strSort Case "a" intSortOrder = CONST_SORT_ASCENDING Case "d" intSortOrder = CONST_SORT_DESCENDING Case "n" intSortOrder = CONST_SORT_NO Case Else Print "Invalid sorting option: " & strSort & "." Print "Please check the input and try again." intParseCmdLine = CONST_ERROR Exit Function End Select Case "/o" strOutputFile = Right(strArgumentArray(i), Len(strArgumentArray(i))-3) Case "/u" strUserName = Right(strArgumentArray(i), Len(strArgumentArray(i))-3) Case "/w" strPassword = Right(strArgumentArray(i), Len(strArgumentArray(i))-3) Case else Print "Invalid flag " & """" & strFlag & ":""" & "." Print "Please check the input and try again." intParseCmdLine = CONST_ERROR Exit Function End Select End If Next intParseCmdLine = CONST_PROCEED End Function '******************************************************************** '* '* Sub ShowUsage() '* Purpose: Shows the correct usage to the user. '* Input: None '* Output: Help messages are displayed on screen. '* '******************************************************************** Private Sub ShowUsage() Wscript.Echo "" Wscript.Echo "Lists all jobs currently running on a machine." & vbCRLF Wscript.Echo "1. PS.VBS [/S:server] [/P:property1[:width1]" Wscript.Echo " [/P:property2[:width2]]...] /D:width] [/SORT:A | D[:num] | N]" Wscript.Echo " [/O:outputfile] [/U:username] [/W:password] [/ALL] [/F] [/Q]" Wscript.Echo "2. PS.VBS [/S:server] [/O:outputfile] [/U:username] [/W:password]" Wscript.Echo " [/P] [/Q]" Wscript.Echo " /S, /P, /SORT, /O, /D, /U, /W" Wscript.Echo " Parameter specifiers." Wscript.Echo " server A machine name." Wscript.Echo " property1, property2 ..." Wscript.Echo " Names of properties to be retrieved." Wscript.Echo " width1, width2..." Wscript.Echo " Widths of columns used to display values of the " Wscript.Echo " corresponding properties." Wscript.Echo " width Default column width." Wscript.Echo " A | D | N A ascending D descending N no sorting." Wscript.Echo " num An integer. For example, 1 specifies sorting results" Wscript.Echo " according to the first property specified using /P:" Wscript.Echo " outputfile The output file name." Wscript.Echo " username The current user's name." Wscript.Echo " password Password of the <PASSWORD>." Wscript.Echo " /P Lists the names of all available properties of a job." Wscript.Echo " /ALL Lists the values of all properties of each job." Wscript.Echo " /F Flush output. Output strings are truncated if needed." Wscript.Echo " /Q Suppresses all output messages." & vbCRLF Wscript.Echo "EXAMPLE:" Wscript.Echo "1. PS.VBS /S:MyMachine2 /P:Name:10 /P:ProcessId:10 /SORT:A:2" Wscript.Echo " lists the names and process ids of all jobs currently running on" Wscript.Echo " MyMachine2 and sorts the result so the process ids are" Wscript.Echo " listed in an ascending order." Wscript.Echo "2. PS.VBS /S:MyMachine2 /P" Wscript.Echo " lists the names of all available properties of jobs(win32_process)." End Sub '******************************************************************** '* '* Sub ListJobs() '* Purpose: Lists all jobs currently running on a machine. '* Input: strServer a machine name '* strProperties an array containing names of properties to be retrieved '* intWidths an array containing the width of columns used to display '* values of the corresponding properties '* intWidth the default column width '* intSortOrder specifies the sort order (ascend/descend/none) '* intSortProperty specifies a property according to which the results '* will be sorted '* strOutputFile an output file name '* strUserName the current user's name '* strPassword <PASSWORD> '* blnAll specifies whether to list all properties '* blnListProperties lists properties available '* blnFlush specifies whether to use flush output '* blnOwner specifies whether to show the owner of a process '* Output: Results are either printed on screen or saved in strOutputFile. '* '******************************************************************** Private Sub ListJobs(strServer, strProperties, intWidths, intWidth, intSortOrder, _ intSortProperty, strOutputFile, strUserName, strPassword, _ blnAll, blnListProperties, blnFlush, blnOwner) ON ERROR RESUME NEXT Dim objFileSystem, objOutputFile, objService, strQuery, strMessage, i, j ReDim strPropertyTypes(0) If strOutputFile = "" Then objOutputFile = "" Else 'Create a file object set objFileSystem = CreateObject("Scripting.FileSystemObject") If Err.Number then Print "Error 0x" & CStr(Hex(Err.Number)) & " opening a filesystem object." If Err.Description <> "" Then Print "Error description: " & Err.Description & "." End If Exit Sub End If 'Open the file for output set objOutputFile = objFileSystem.OpenTextFile(strOutputFile, 8, True) If Err.Number then Print "Error 0x" & CStr(Hex(Err.Number)) & " opening file " & strOutputFile If Err.Description <> "" Then Print "Error description: " & Err.Description & "." End If Exit Sub End If End If 'Establish a connection with the server. If blnConnect(objService, strServer, "root\cimv2", strUserName, strPassword) Then Exit Sub End If If blnListProperties or blnAll Then 'Get all available properties Call blnGetAllProperties(objService, strProperties, strPropertyTypes) strQuery = "Select * From Win32_Process" 'List all available properties Call blnGetAvailableProperties(objService, strQuery, strProperties, 0) Else strQuery = "Select * From Win32_Process" 'delete unavailable properties from the array Call blnGetAvailableProperties(objService, strQuery, strProperties, 1) End If If blnListProperties Then 'Print the available properties on screen strMessage = vbCRLF & "Available properties of Win32_Process:" WriteLine strMessage & vbCRLF, objOutputFile strMessage = strPackString("PROPERTY NAME", 30, 1, 0) strMessage = strMessage & strPackString("CIMTYPE", 20, 1, 0) WriteLine strMessage & vbCRLF, objOutputFile For i = 0 To UBound(strProperties) strMessage = strPackString(strProperties(i), 30, 1, 0) strMessage = strMessage & strPackString(strPropertyTypes(i), 20, 1, 0) WriteLine strMessage, objOutputFile Next Else If blnAll Then 'Expand intWidths j = UBound(strProperties) ReDim intWidths(j) For i = 0 To j intWidths(i) = intWidth Next End If 'Set the query string. strQuery = "Select " For i = 0 To UBound(strProperties) strQuery = strQuery & LCase(strProperties(i)) & ", " Next strQuery = Left(strQuery, Len(strQuery)-2) 'Get rid off the last ", " strQuery = strQuery & " From Win32_Process" If blnOwner Then j = UBound(strProperties)+1 ReDim Preserve strProperties(j), intWidths(j) strProperties(j) = "owner" intWidths(j) = intWidth End If 'Check intSortProperty If (intSortProperty > UBound(strProperties)+1) Then Print intSortProperty & " is larger than the number of properties to be retrieved." Print "Only " & UBound(strProperties)+1 & " properties are available." Print "Please check the input and try again." Exit Sub End If 'Now execute the query. Call ExecuteQuery(objService, strQuery, strProperties, intWidths, _ intSortProperty, intSortOrder, blnFlush, objOutputFile) End If If strOutputFile <> "" Then objOutputFile.Close Wscript.Echo "Results are saved in file " & strOutputFile & "." End If End Sub '******************************************************************** '* '* Function blnConnect() '* Purpose: Connects to machine strServer. '* Input: strServer a machine name '* strNameSpace a namespace '* strUserName name of the current user '* strPassword <PASSWORD> '* Output: objService is returned as a service object. '* '******************************************************************** Private Function blnConnect(objService, strServer, strNameSpace, strUserName, strPassword) ON ERROR RESUME NEXT Dim objLocator blnConnect = False 'There is no error. ' Create Locator object to connect to remote CIM object manager Set objLocator = CreateObject("WbemScripting.SWbemLocator") If Err.Number then Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred in creating a locator object." If Err.Description <> "" Then Print "Error description: " & Err.Description & "." End If Err.Clear blnConnect = True 'An error occurred Exit Function End If ' Connect to the namespace which is either local or remote Set objService = objLocator.ConnectServer (strServer, strNameSpace, _ strUserName, strPassword) ObjService.Security_.impersonationlevel = 3 If Err.Number then Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred in connecting to server " _ & strServer & "." If Err.Description <> "" Then Print "Error description: " & Err.Description & "." End If Err.Clear blnConnect = True 'An error occurred End If End Function '******************************************************************** '* '* Function blnGetAllProperties() '* Purpose: Gets all possible properties of a job. '* Input: objService a service object '* Output: strProperties an array containing all possible properties of a job '* strPropertyTypes an array containing CIM Types of all possible '* properties of a job '* '******************************************************************** Private Function blnGetAllProperties(objService, strProperties, strPropertyTypes) ON ERROR RESUME NEXT Dim objClass, objWbemProperty, i blnGetAllProperties = False Set objClass = objService.Get("win32_process") If Err.Number then Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred in getting a class object." If Err.Description <> "" Then Print "Error description: " & Err.Description & "." End If blnGetAllProperties = True Err.Clear Exit Function End If i = -1 For Each objWbemProperty in objClass.Properties_ i = i + 1 ReDim Preserve strProperties(i), strPropertyTypes(i) strProperties(i) = objWbemProperty.Name strPropertyTypes(i) = strCIMType(objWbemProperty.CIMType) If Err.Number Then blnGetAllProperties = True End If Next End Function '******************************************************************** '* '* Function GetAvailableProperties() '* Purpose: Queries a server to determine which properties or processes are available. '* Input: objService a service object '* strQuery a query string '* strProperties an array containing names of properties to be retrieved '* blnPrint specifies whether to print out not available properties '* Output: strProperties contains the available properties '* blnGetAvailableProperties is set to True is an error occurred and False otherwise. '* '******************************************************************** Private Function blnGetAvailableProperties(objService, strQuery, strProperties, blnPrint) ON ERROR RESUME NEXT Dim objEnumerator, objInstance, intUBound, i, strTemp blnGetAvailableProperties = False 'No error intUBound = UBound(strProperties) Set objEnumerator = objService.ExecQuery(strQuery) If Err.Number Then Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred during the query." If Err.Description <> "" Then Print "Error description: " & Err.Description & "." End If Err.Clear Exit Function End If For Each objInstance in objEnumerator If objInstance is nothing Then blnGetAvailableProperties = True Exit Function End If i = 0 Do While i < (intUBound +1) strTemp = CStr(objInstance.properties_(strProperties(i))) If Err.Number Then 'Property not available If blnPrint Then Print "Property " & strProperties(i) & " is not available." End If Call blnDeleteOneElement(i, strProperties) intUBound = intUBound - 1 i = i -1 Err.Clear End If i = i + 1 Loop Exit For Next End Function '******************************************************************** '* '* Sub ExecuteQuery() '* Purpose: Queries a server for processes currently running. '* Input: objService a service object '* strQuery a query string '* strProperties an array containing names of properties to be retrieved '* intWidths an array containing the width of columns used to display '* values of the corresponding properties '* intSortOrder specifies the sort order (ascend/descend/none) '* intSortProperty specifies a property according to which the results '* will be sorted '* blnFlush specifies whether to use flush output '* objOutputFile an output file object '* Output: Results of the query are either printed on screen or saved in objOutputFile. '* '******************************************************************** Private Sub ExecuteQuery(objService, strQuery, strProperties, intWidths, _ intSortProperty, intSortOrder, blnFlush, objOutputFile) ON ERROR RESUME NEXT Dim objEnumerator, objInstance, strMessage, i, j, k, intUBound intUBound = UBound(strProperties) 'Need to use redim so the last dimension can be resized ReDim strResults(intUBound, 0), intOrder(0), strArray(0) Set objEnumerator = objService.ExecQuery(strQuery) If Err.Number Then Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred during the query." If Err.Description <> "" Then Print "Error description: " & Err.Description & "." End If Err.Clear Exit Sub End If 'Read properties of processes into arrays. i = 0 For Each objInstance in objEnumerator If objInstance is nothing Then Exit For End If ReDim Preserve strResults(intUBound, i), intOrder(i), strArray(i) For j = 0 To intUBound Select Case LCase(strProperties(j)) Case "processid" strResults(j, i) = objInstance.properties_(strProperties(j)) If strResults(j, i) < 0 Then '4294967296 is 0x10000000. strResults(j, i) = CStr(strResults(j, i) + 4294967296) End If Case "owner" Dim strDomain, strUser Call objInstance.GetOwner(strUser, strDomain) strResults(j, i) = strDomain & "\" & strUser Case Else strResults(j, i) = CStr(objInstance.properties_(strProperties(j))) End Select If Err.Number Then Err.Clear strResults(j, i) = "(null)" End If Next intOrder(i) = i 'Copy the property values to be sorted. strArray(i) = strResults(intSortProperty-1, i) i = i + 1 If Err.Number Then Err.Clear End If Next 'Check the data type of the property to be sorted k = CDbl(strArray(0)) If Err.Number Then 'not a number Err.Clear Else 'a number 'Pack empty spaces at the begining of each number For j = 0 To UBound(strArray) 'Assume the longest number would be less than 40 digits. strArray(j) = strPackString(strArray(j), 40, 0, 0) Next End If If i > 0 Then 'Print the header strMessage = vbCRLF & Space(2) For j = 0 To intUBound strMessage = strMessage & UCase(strPackString(strProperties(j), _ intWidths(j), 1, blnFlush)) Next WriteLine strMessage & vbCRLF, objOutputFile 'Sort strArray Select Case intSortOrder Case CONST_SORT_NO 'Do nothing Case CONST_SORT_ASCENDING Call SortArray(strArray, 1, intOrder, 0) Case CONST_SORT_DESCENDING Call SortArray(strArray, 0, intOrder, 0) Case Else Print "Error occurred in passing parameters." Exit Sub End Select If intSortOrder <> CONST_SORT_NO Then For j = 0 To intUBound 'First copy results to strArray and change the order of elements. For k = 0 To i-1 'i is number of instances retrieved. strArray(k) = strResults(j, intOrder(k)) Next 'Now copy results back to strResults. For k = 0 To i-1 'i is number of instances retrieved. strResults(j, k) = strArray(k) Next Next End If For k = 0 To i-1 strMessage = Space(2) For j = 0 To intUBound strMessage = strMessage & strPackString(strResults(j, k), _ intWidths(j), 1, blnFlush) Next WriteLine strMessage, objOutputFile Next End If End Sub '******************************************************************** '* '* Function blnDeleteOneElement() '* Purpose: Deletes one element from an array. '* Input: i the index of the element to be deleted '* strArray the array to work on '* Output: strArray the array with the i-th element deleted '* blnDeleteOneElement is set to True if an error occurred and False otherwise. '* '******************************************************************** Private Function blnDeleteOneElement(ByVal i, strArray) ON ERROR RESUME NEXT Dim j, intUbound blnDeleteOneElement = False 'No error If Not IsArray(strArray) Then blnDeleteOneElement = True Exit Function End If intUbound = UBound(strArray) If i > intUBound Then Print "Array index out of range!" blnDeleteOneElement = True Exit Function ElseIf i < intUBound Then For j = i To intUBound - 1 strArray(j) = strArray(j+1) Next j = j - 1 Else 'i = intUBound If intUBound = 0 Then 'There is only one element in the array strArray(0) = "" 'set it to empty j = 0 Else 'Need to delete the last element (i-th element) j = intUBound - 1 End If End If ReDim Preserve strArray(j) End Function '******************************************************************** '* '* Sub SortArray() '* Purpose: Sorts an array and arrange another array accordingly. '* Input: strArray the array to be sorted '* blnOrder True for ascending and False for descending '* strArray2 an array that has exactly the same number of elements as strArray '* and will be reordered together with strArray '* blnCase indicates whether the order is case sensitive '* Output: The sorted arrays are returned in the original arrays. '* Note: Repeating elements are not deleted. '* '******************************************************************** Private Sub SortArray(strArray, blnOrder, strArray2, blnCase) ON ERROR RESUME NEXT Dim i, j, intUbound If IsArray(strArray) Then intUbound = UBound(strArray) Else Print "Argument is not an array!" Exit Sub End If blnOrder = CBool(blnOrder) blnCase = CBool(blnCase) If Err.Number Then Print "Argument is not a boolean!" Exit Sub End If i = 0 Do Until i > intUbound-1 j = i + 1 Do Until j > intUbound If blnCase Then 'Case sensitive If (strArray(i) > strArray(j)) and blnOrder Then Swap strArray(i), strArray(j) 'swaps element i and j Swap strArray2(i), strArray2(j) ElseIf (strArray(i) < strArray(j)) and Not blnOrder Then Swap strArray(i), strArray(j) 'swaps element i and j Swap strArray2(i), strArray2(j) ElseIf strArray(i) = strArray(j) Then 'Move element j to next to i If j > i + 1 Then Swap strArray(i+1), strArray(j) Swap strArray2(i+1), strArray2(j) End If End If Else 'Not case sensitive If (LCase(strArray(i)) > LCase(strArray(j))) and blnOrder Then Swap strArray(i), strArray(j) 'swaps element i and j Swap strArray2(i), strArray2(j) ElseIf (LCase(strArray(i)) < LCase(strArray(j))) and Not blnOrder Then Swap strArray(i), strArray(j) 'swaps element i and j Swap strArray2(i), strArray2(j) ElseIf LCase(strArray(i)) = LCase(strArray(j)) Then 'Move element j to next to i If j > i + 1 Then Swap strArray(i+1), strArray(j) Swap strArray2(i+1), strArray2(j) End If End If End If j = j + 1 Loop i = i + 1 Loop End Sub '******************************************************************** '* '* Sub Swap() '* Purpose: Exchanges values of two strings. '* Input: strA a string '* strB another string '* Output: Values of strA and strB are exchanged. '* '******************************************************************** Private Sub Swap(ByRef strA, ByRef strB) Dim strTemp strTemp = strA strA = strB strB = strTemp End Sub '******************************************************************** '* '* Function strCIMType() '* Purpose: Finds the namd of CIMType corresponding to an integer. '* Input: intCIMType an integer corresponding to a CIM type '* Output: strCIMType is returned as the name of the CIM type. '* '******************************************************************** Private Function strCIMType(intCIMType) Select Case intCIMType Case 2 strCIMType = "CIM_SINT16" Case 3 strCIMType = "CIM_SINT32" Case 4 strCIMType = "CIM_REAL32" Case 5 strCIMType = "CIM_REAL64" Case 8 strCIMType = "CIM_STRING" Case 11 strCIMType = "CIM_BOOLEAN" Case 13 strCIMType = "CIM_OBJECT" Case 17 strCIMType = "CIM_UINT8" Case 18 strCIMType = "CIM_UINT16" Case 19 strCIMType = "CIM_UINT32" Case 20 strCIMType = "CIM_SINT64" Case 21 strCIMType = "CIM_UINT64" Case 101 strCIMType = "CIM_DATETIME" Case 102 strCIMType = "CIM_REFERENCE" Case 103 strCIMType = "CIM_CHAR16" Case Else strCIMType = CStr(intCIMType) End Select End Function '******************************************************************** '* '* Function strPackString() '* Purpose: Attaches spaces to a string to increase the length to intWidth. '* Input: strString a string '* intWidth the intended length of the string '* blnAfter specifies whether to add spaces after or before the string '* blnTruncate specifies whether to truncate the string or not if '* the string length is longer than intWidth '* Output: strPackString is returned as the packed string. '* '******************************************************************** Private Function strPackString(strString, ByVal intWidth, blnAfter, blnTruncate) ON ERROR RESUME NEXT intWidth = CInt(intWidth) blnAfter = CBool(blnAfter) blnTruncate = CBool(blnTruncate) If Err.Number Then Print "Argument type is incorrect!" Err.Clear Wscript.Quit End If If IsNull(strString) Then strPackString = "null" & Space(intWidth-4) Exit Function End If strString = CStr(strString) If Err.Number Then Print "Argument type is incorrect!" Err.Clear Wscript.Quit End If If intWidth > Len(strString) Then If blnAfter Then strPackString = strString & Space(intWidth-Len(strString)) Else strPackString = Space(intWidth-Len(strString)) & strString & " " End If Else If blnTruncate Then strPackString = Left(strString, intWidth-1) & " " Else strPackString = strString & " " End If End If End Function '******************************************************************** '* '* Sub WriteLine() '* Purpose: Writes a text line either to a file or on screen. '* Input: strMessage the string to print '* objFile an output file object '* Output: strMessage is either displayed on screen or written to a file. '* '******************************************************************** Sub WriteLine(ByRef strMessage, ByRef objFile) If IsObject(objFile) then 'objFile should be a file object objFile.WriteLine strMessage Else Wscript.Echo strMessage End If End Sub '******************************************************************** '* '* Sub Print() '* Purpose: Prints a message on screen if blnQuiet = False. '* Input: strMessage the string to print '* Output: strMessage is printed on screen if blnQuiet = False. '* '******************************************************************** Sub Print(ByRef strMessage) If Not blnQuiet then Wscript.Echo strMessage End If End Sub '******************************************************************** '* * '* End of File * '* * '******************************************************************** '******************************************************************** '* '* Procedures calling sequence: PS.VBS '* '* intParseCmdLine '* ShowUsage '* ListJobs '* blnConnect '* ExecuteQuery '* strPackString '* SortArray '* Swap '* WriteLine '* '******************************************************************** '******************************************************************** '* '* Sub Debug() '* Purpose: Prints a debug message and the error condition. '* Input: i an integer '* strMessage a message string '* Output: A message is printed on screen. '* '******************************************************************** Sub Debug(i, strMessage) If Err.Number then Wscript.echo "Error 0X" & Hex(Err.Number) & " occurred." Wscript.echo "Error description " & i & " " & Err.Description Wscript.echo strMessage ' Err.Clear Else Wscript.echo "No problem " & i Wscript.echo strMessage End If End Sub '******************************************************************** '* '* Sub PrintArray() '* Purpose: Prints all elements of an array on screen. '* Input: strArray an array name '* Output: All elements of the array are printed on screen. '* '******************************************************************** Sub PrintArray(strArray) Dim i For i = 0 To UBound(strArray) Wscript.echo strArray(i) Next End Sub
<reponame>LaudateCorpus1/RosettaCodeData Option Explicit Sub Main() Dim myArr() As Variant, i As Long myArr = Remove_Duplicate(Array(1.23456789101112E+16, True, False, True, "Alpha", 1, 235, 4, 1.25, 1.25, "Beta", 1.23456789101112E+16, "Delta", "Alpha", "Charlie", 1, 2, "Foxtrot", "Foxtrot", "Alpha", 235)) 'return : For i = LBound(myArr) To UBound(myArr) Debug.Print myArr(i) Next End Sub Private Function Remove_Duplicate(Arr As Variant) As Variant() Dim myColl As New Collection, Temp() As Variant, i As Long, cpt As Long ReDim Temp(UBound(Arr)) For i = LBound(Arr) To UBound(Arr) On Error Resume Next myColl.Add CStr(Arr(i)), CStr(Arr(i)) If Err.Number > 0 Then On Error GoTo 0 Else Temp(cpt) = Arr(i) cpt = cpt + 1 End If Next i ReDim Preserve Temp(cpt - 1) Remove_Duplicate = Temp End Function
set path = CreateObject("WbemScripting.SWbemObjectPath") path.Path = "//server/root/default:Fred.N1=10,N2=""Hello""" for each key in path.Keys WScript.Echo key.Name, key.Value next
'Set the string comparison method to Binary. Option Compare Binary ' That is, "AAA" is less than "aaa". ' Set the string comparison method to Text. Option Compare Text ' That is, "AAA" is equal to "aaa".
dim a1 dim cb set cb = new callback cb.rule = "ucase(p1)" a1 = split("my dog has fleas", " " ) cb.applyTo a1 wscript.echo join( a1, " " ) cb.rule = "p1 ^ p1" a1 = array(1,2,3,4,5,6,7,8,9,10) cb.applyto a1 wscript.echo join( a1, ", " )
Attribute VB_Name = "Module1" ' This first line is the declaration from win32api.txt ' Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpfilename As String) As Long Declare Function GetPrivateProfileStringByKeyName& Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName$, _ ByVal lpszKey$, ByVal lpszDefault$, ByVal lpszReturnBuffer$, ByVal cchReturnBuffer&, ByVal lpszFile$) Declare Function GetPrivateProfileStringKeys& Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName$, _ ByVal lpszKey&, ByVal lpszDefault$, ByVal lpszReturnBuffer$, ByVal cchReturnBuffer&, ByVal lpszFile$) Declare Function GetPrivateProfileStringSections& Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName&, _ ByVal lpszKey&, ByVal lpszDefault$, ByVal lpszReturnBuffer$, ByVal cchReturnBuffer&, ByVal lpszFile$) ' This first line is the declaration from win32api.txt ' Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, lpKeyName As Any, lpString As Any, ByVal lplFileName As String) As Long Declare Function WritePrivateProfileStringByKeyName& Lib "kernel32" Alias "WritePrivateProfileStringA" _ (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lplFileName As String) Declare Function WritePrivateProfileStringToDeleteKey& Lib "kernel32" Alias "WritePrivateProfileStringA" _ (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As Long, ByVal lplFileName As String) Declare Function WritePrivateProfileStringToDeleteSection& Lib "kernel32" Alias "WritePrivateProfileStringA" _ (ByVal lpApplicationName As String, ByVal lpKeyName As Long, ByVal lpString As Long, ByVal lplFileName As String) Declare Function GetWindowsDirectory& Lib "kernel32" Alias _ "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) Public fMainForm As frmMain Public HexNum As String Public PreNum As String Public PostNum As String Public CleanNum As String Const Delim As String = "," Public Const H As String = "&H" Public SBCount As Integer Sub Main() Set fMainForm = New frmMain Load fMainForm fMainForm.Show End Sub Public Sub HideAll() If fMainForm.Visible = True Then fMainForm.ActiveForm.Visible = False End If End Sub Public Sub Clean(Num As String) While Left$(Num, 1) = " " Num = Mid(Num, 2, Len(Num) - 1) Wend If Len(Num) > 2 Then Num = Left$(Num, 2) ElseIf Len(Num) = 1 Then Num = 0 & Num End If CleanNum = Num End Sub Public Sub HexCon(Number As String) Dim First, Second, Third, Fourth As String HexNum = "" If Number = "" Then Number = 0 End If HexNum = Hex(Number) HexNum = "00000000" & HexNum HexNum = Right(HexNum, 8) First = Mid(HexNum, 1, 2) Second = Mid(HexNum, 3, 2) Third = Mid(HexNum, 5, 2) Fourth = Mid(HexNum, 7, 2) HexNum = Fourth & Delim & Third & Delim & Second & Delim & First End Sub Public Sub PreVert(Number As String) Dim First, Second, Third, Fourth As String PreNum = "" If Number = "" Then Number = 0 End If First = Mid(Number, 1, 2) Second = Mid(Number, 4, 2) Third = Mid(Number, 7, 2) Fourth = Mid(Number, 10, 2) PreNum = Fourth & Third & Second & First End Sub Public Sub PostVert(Number As String) Dim First, Second, Third, Fourth As String PostNum = "" If Number = "" Then Number = 0 End If First = Mid(Number, 1, 2) Second = Mid(Number, 3, 2) Third = Mid(Number, 5, 2) Fourth = Mid(Number, 7, 2) PostNum = Fourth & Delim & Third & Delim & Second & Delim & First End Sub Function VBGetPrivateProfileString(Section$, key$, File$) As String Dim KeyValue$ Dim characters As Long KeyValue$ = String$(2048, 0) characters = GetPrivateProfileStringByKeyName(Section$, key$, "", KeyValue$, 2047, File$) If characters > 1 Then KeyValue$ = Left$(KeyValue$, characters) End If VBGetPrivateProfileString = KeyValue$ End Function Function ModemCallback(ByVal lMsg As Long, ByVal lParam As Long, _ ByVal lUserParam As Long) As Long If lMsg = 1 Then SBCount = SBCount + 1 frmUnimodemId.ProgressBar1.Value = SBCount End If ModemCallback = 0 End Function
rem this test will run offline test Dim Classy Set fso = CreateObject("Scripting.FileSystemObject") Set a = fso.CreateTextFile("filter.log", True) Set Locator = CreateObject("WbemScripting.SWbemLocator") ' Note that Locator.ConnectServer can be used to connect to remote computers Set Service = Locator.ConnectServer (, "root\cimv2") Service.Security_.ImpersonationLevel=3 sub ClearAndRunTest(BaseName, SystemElement, SettingRef) Dim Collection Dim InstancePaths() Dim InstanceCount Dim ResultRef Set Collection = Service.InstancesOf (BaseName & "_DiagTest") InstanceCount = 0 Err.Clear for each Instance in Collection if Err.Number = 0 Then InstanceCount = InstanceCount + 1 ReDim Preserve InstancePaths(InstanceCount) Set ObjectPath = Instance.Path_ InstancePaths(InstanceCount) = ObjectPath.Path End If next 'Instance if InstanceCount = 0 Then MsgBox "No instances available for this class" Else CurrentInstanceIndex = 1 End if Err.Clear Set Instance = Service.Get(InstancePaths(CurrentInstanceIndex)) if Err.Number = 0 Then rem don't clear ' Err.Clear ' RetVal = Instance.ClearResults(SystemElement, NotCleared) ' if Err.Number = 0 Then ' a.Writeline(BaseName & " Clear Results Method Execution Succeeded -> " & RetVal & " " & NotCleared) ' Else ' a.Writeline(BaseName & " Clear Result Method Execution Failed " & Err.Description) ' end if ' RetVal = Instance.RunTest (SystemElement, SettingRef, ResultRef) if Err.Number = 0 Then a.Writeline(BaseName & " Run Test Method Execution Succeeded -> " & RetVal) a.Writeline(" " & ResultRef) Set Instance2 = Service.Get(ResultRef) Set ObjectPath2 = Instance2.Path_ a.WriteLine(" ** " & ObjectPath2.Path) Set Instance3 = Service.Get(ResultRef) Set ObjectPath3 = Instance3.Path_ a.WriteLine(" *3 " & ObjectPath3.Path) Set Instance4 = Service.Get(ResultRef) Set ObjectPath4 = Instance4.Path_ a.WriteLine(" *4 " & ObjectPath4.Path) Else a.Writeline(BaseName & " Run Test Method Execution Failed " & Err.Description) End if End if end sub a1 = "Sample_Offline" b1 = "Win32_USBController.DeviceID=""PCI\\VEN_8086&DEV_7112&SUBSYS_00000000&REV_01\\2&EBB567F&0&3A""" c1 = a1 & "_DiagSetting.SettingID=""" & a1 & "_DiagTest_0_2""" ClearAndRunTest a1, b1, c1
Function largestint(list) nums = Split(list,",") Do Until IsSorted = True IsSorted = True For i = 0 To UBound(nums) If i <> UBound(nums) Then a = nums(i) b = nums(i+1) If CLng(a&b) < CLng(b&a) Then tmpnum = nums(i) nums(i) = nums(i+1) nums(i+1) = tmpnum IsSorted = False End If End If Next Loop For j = 0 To UBound(nums) largestint = largestint & nums(j) Next End Function WScript.StdOut.Write largestint(WScript.Arguments(0)) WScript.StdOut.WriteLine
<reponame>mullikine/RosettaCodeData<gh_stars>1-10 Public lastsquare As Long Public nextsquare As Long Public lastcube As Long Public midcube As Long Public nextcube As Long Private Sub init() lastsquare = 1 nextsquare = -1 lastcube = -1 midcube = 0 nextcube = 1 End Sub Private Function squares() As Long lastsquare = lastsquare + nextsquare nextsquare = nextsquare + 2 squares = lastsquare End Function Private Function cubes() As Long lastcube = lastcube + nextcube nextcube = nextcube + midcube midcube = midcube + 6 cubes = lastcube End Function Public Sub main() init cube = cubes For i = 1 To 30 Do While True square = squares Do While cube < square cube = cubes Loop If square <> cube Then Exit Do End If Loop If i > 20 Then Debug.Print square; End If Next i End Sub
<filename>admin/pchealth/authtools/prodtools/applets/preparehhcsforloc/main.bas<gh_stars>10-100 Attribute VB_Name = "Main" Option Explicit Private Const HHC_C As String = "hhc" Private Const HTML_CLOSE_C As String = "</HTML>" Private Const QUOTED_NAME_C As String = """Name""" Private Const QUOTE_C As String = """" Private Const QUOTE_GT_C As String = """>" Private Const NOLOCENUTITLE_C As String = "<param name=""Comment"" value=""NoLocEnuTitle: " Public Sub MainFunction( _ ByVal i_strFolder As String, _ ByVal i_blnRecurse As Boolean _ ) On Error GoTo LError Dim FSO As Scripting.FileSystemObject Dim Folder As Scripting.Folder Dim File As Scripting.File Dim FolderSub As Scripting.Folder Set FSO = New Scripting.FileSystemObject If (Not FSO.FolderExists(i_strFolder)) Then Err.Raise E_FAIL, , "Folder " & i_strFolder & " does not exist" End If Set Folder = FSO.GetFolder(i_strFolder) For Each File In Folder.Files If (LCase$(FSO.GetExtensionName(File.Path)) = HHC_C) Then frmMain.Output "Processing " & File.Name, LOGGING_TYPE_NORMAL_E p_Process File, i_strFolder End If Next If (i_blnRecurse) Then For Each FolderSub In Folder.SubFolders MainFunction FolderSub.Path, i_blnRecurse Next End If LEnd: Exit Sub LError: frmMain.Output Err.Description, LOGGING_TYPE_ERROR_E Err.Raise Err.Number End Sub Private Sub p_Process( _ ByVal i_File As Scripting.File, _ ByVal i_strFolder As String _ ) Dim Tokenizer As Tokenizer Dim arr() As String Dim str As String Dim strMatch As String Dim strNoLocEnuTitle As String str = FileRead(i_File.Path) str = p_ClearNoLocEnuTitle(str) Set Tokenizer = New Tokenizer Tokenizer.Init str ReDim arr(1) arr(0) = HTML_CLOSE_C arr(1) = QUOTED_NAME_C Tokenizer.NormalizeTokens arr str = "" Do str = str & Tokenizer.GetUpToClosestMatch(arr, strMatch) If (Len(strMatch) = 0 Or strMatch = HTML_CLOSE_C) Then Exit Do End If str = str & Tokenizer.GetUpTo(QUOTE_C) strNoLocEnuTitle = Tokenizer.GetUpTo(QUOTE_C, False) str = str & strNoLocEnuTitle & Tokenizer.GetUpTo(QUOTE_GT_C) & vbCrLf str = str & NOLOCENUTITLE_C & strNoLocEnuTitle & QUOTE_GT_C Loop If (Not FileWrite(i_strFolder & "\" & i_File.Name, str)) Then Err.Raise E_FAIL, , "File " & i_File.Name & " could not be saved" End If End Sub Function p_ClearNoLocEnuTitle( _ ByVal i_str As String _ ) As String Dim Tokenizer As Tokenizer Dim arr() As String Dim strChunk As String Dim strOutHhc As String Dim strMatch As String Dim intPosition As Long strOutHhc = "" Set Tokenizer = New Tokenizer Tokenizer.Init i_str ReDim arr(1) arr(0) = NOLOCENUTITLE_C arr(1) = HTML_CLOSE_C Tokenizer.NormalizeTokens arr Do strChunk = Tokenizer.GetUpToClosestMatch(arr, strMatch, False) strOutHhc = strOutHhc & strChunk If (Len(strChunk) = 0) Then strOutHhc = strOutHhc & HTML_CLOSE_C Exit Do End If Tokenizer.GetUpTo ">" Loop strOutHhc = Replace$(strOutHhc, vbCrLf & vbCrLf, vbCrLf) p_ClearNoLocEnuTitle = strOutHhc End Function
text = "I need more coffee!!!" Set regex = New RegExp regex.Global = True regex.Pattern = "\s" If regex.Test(text) Then WScript.StdOut.Write regex.Replace(text,vbCrLf) Else WScript.StdOut.Write "No matching pattern" End If
Sub Main() Dim i&, c&, j#, s$ Const N& = 1000000 s = "values for n in the range 1 to 22 : " For i = 1 To 22 s = s & ns(i) & ", " Next For i = 1 To N j = Sqr(ns(i)) If j = CInt(j) Then c = c + 1 Next Debug.Print s Debug.Print c & " squares less than " & N End Sub Private Function ns(l As Long) As Long ns = l + Int(1 / 2 + Sqr(l)) End Function
<filename>Task/Repeat-a-string/VBA/repeat-a-string-2.vba Public Function RepeatString(stText As String, iQty As Integer) As String RepeatString = Replace(String(iQty, "x"), "x", stText) End Function
<reponame>npocmaka/Windows-Server-2003 ' Windows Installer script viewer for use with Windows Scripting Host CScript.exe only ' For use with Windows Scripting Host, CScript.exe or WScript.exe ' Copyright (c) Microsoft Corporation. All rights reserved. ' Demonstrates the use of the special database processing mode for viewing script files ' Option Explicit Const msiOpenDatabaseModeListScript = 5 ' Check arg count, and display help if argument not present or contains ? Dim argCount:argCount = Wscript.Arguments.Count If argCount > 0 Then If InStr(1, Wscript.Arguments(0), "?", vbTextCompare) > 0 Then argCount = 0 If argCount = 0 Then Wscript.Echo "Windows Installer Script Viewer for Windows Scripting Host (CScript.exe)" &_ vbNewLine & " Argument is path to installer execution script" &_ vbNewLine &_ vbNewLine & "Copyright (C) Microsoft Corporation. All rights reserved." Wscript.Quit 1 End If ' Cannot run with GUI script host, as listing is performed to standard out If UCase(Mid(Wscript.FullName, Len(Wscript.Path) + 2, 1)) = "W" Then Wscript.Echo "Cannot use WScript.exe - must use CScript.exe with this program" Wscript.Quit 2 End If Dim installer, view, database, record, fieldCount, template, index, field On Error Resume Next Set installer = CreateObject("WindowsInstaller.Installer") : CheckError Set database = installer.Opendatabase(Wscript.Arguments(0), msiOpenDatabaseModeListScript) : CheckError Set view = database.Openview("") view.Execute : CheckError Do Set record = view.Fetch If record Is Nothing Then Exit Do fieldCount = record.FieldCount template = record.StringData(0) index = InstrRev(template, "[") + 1 If (index > 1) Then field = Int(Mid(template, index, InstrRev(template, "]") - index)) If field < fieldCount Then template = Left(template, Len(template) - 1) While field < fieldCount field = field + 1 template = template & ",[" & field & "]" Wend record.StringData(0) = template & ")" End If End If Wscript.Echo record.FormatText Loop Wscript.Quit 0 Sub CheckError Dim message, errRec If Err = 0 Then Exit Sub message = Err.Source & " " & Hex(Err) & ": " & Err.Description If Not installer Is Nothing Then Set errRec = installer.LastErrorRecord If Not errRec Is Nothing Then message = message & vbNewLine & errRec.FormatText End If Wscript.Echo message Wscript.Quit 2 End Sub
Option Explicit '---------------------------------------------------------------------------- ' ADMT Scripting Notes '---------------------------------------------------------------------------- ' 1 - this template shows all the migration objects and all of the properties ' and methods of the various migration objects even though a normal ' script would not use all of the objects and properties ' 2 - optional properties are commented out with the default value shown ' being assigned ' 3 - service account enumeration would normally occur before user account ' migration so that services may be updated during user account migration '---------------------------------------------------------------------------- ' ADMT Scripting Constants '---------------------------------------------------------------------------- ' RenameOption constants Const admtDoNotRename = 0 Const admtRenameWithPrefix = 1 Const admtRenameWithSuffix = 2 ' PasswordOption constants Const admtPasswordFromName = 0 Const admtComplexPassword = 1 Const admtCopyPassword = 2 ' ConflictOptions constants Const admtIgnoreConflicting = &H0000 Const admtReplaceConflicting = &H0001 Const admtRenameConflictingWithPrefix = &H0002 Const admtRenameConflictingWithSuffix = &H0003 Const admtRemoveExistingUserRights = &H0010 Const admtRemoveExistingMembers = &H0020 Const admtMoveReplacedAccounts = &H0040 ' DisableOption constants Const admtEnableTarget = 0 Const admtDisableSource = 1 Const admtDisableTarget = 2 Const admtTargetSameAsSource = 4 ' SourceExpiration constant Const admtNoExpiration = -1 ' Translation Option Const admtTranslateReplace = 0 Const admtTranslateAdd = 1 Const admtTranslateRemove = 2 ' Report Type Const admtReportMigratedAccounts = 0 Const admtReportMigratedComputers = 1 Const admtReportExpiredComputers = 2 Const admtReportAccountReferences = 3 Const admtReportNameConflicts = 4 ' Option constants Const admtNone = 0 Const admtData = 1 Const admtFile = 2 Const admtDomain = 3 Const admtRecurse = &H0100 Const admtFlattenHierarchy = &H0000 Const admtMaintainHierarchy = &H0200 '---------------------------------------------------------------------------- ' Declarations '---------------------------------------------------------------------------- Dim objMigration Dim objUserMigration Dim objGroupMigration Dim objComputerMigration Dim objSecurityTranslation Dim objServiceAccountEnumeration '---------------------------------------------------------------------------- ' ADMT Migration Class ' ' TestMigration Property ' - specifies whether a test migration will be performed ' - optional, the default value is false ' ' IntraForest Property ' - specifies whether the migration is intra-forest or inter-forest ' - the default is inter-forest migration ' ' SourceDomain Property ' - specifies the source domain name ' - the source domain may be specified in either DNS or Flat format ' - eg. DNS "mydomain.mycompany.com" or Flat "MYDOMAIN" ' - the source domain must be specified ' ' SourceOU Property ' - specifies the source organizational unit (OU) ' - this property is only applicable for up-level domains (Windows 2000 or later) ' - the OU must be specified in relative canonical format ' - eg. "West/Sales" ' ' TargetDomain Property ' - specifies the target domain name ' - the target domain may be specified in either DNS or Flat format ' - eg. DNS "mydomain.mycompany.com" or Flat "MYDOMAIN" ' - the target domain must be specified ' ' TargetOU Property ' - specifies the target organizational unit (OU) ' - the OU must be specified in relative canonical format ' - eg. "West/Sales" ' ' RenameOption Property ' - specifies how migrated accounts are to be renamed ' - optional, default is admtDoNotRename ' ' RenamePrefixOrSuffix Property ' - specifies the prefix or suffix to be added to account names ' - applicable only if RenameOption is admtRenameWithPrefix or ' admtRenameWithSuffix ' ' PasswordOption Property ' - specifies how to generate passwords for migrated accounts ' - applicable only for inter-forest user migrations and inter-forest group ' migrations when migrating member users ' - optional, default is admtComplexPassword ' ' PasswordServer Property ' - specifies the server that is to be used for copying passwords ' - applicable only for inter-forest user migrations and inter-forest group ' migrations when migrating member users ' - only applicable if password option specifies copying ' ' PasswordFile Property ' - specifies the path of the password file to be created ' - applicable only for inter-forest user migrations and inter-forest group ' migrations when migrating member users ' - optional, default path is the 'Logs' folder in the ADMT installation ' directory ' ' ConflictOptions Property ' - specifies how to handle accounts being migrated that have a naming ' conflict with a target domain account ' - the following are the allowable values ' admtIgnoreConflicting ' admtReplaceConflicting ' admtReplaceConflicting + admtRemoveExistingUserRights ' admtReplaceConflicting + admtRemoveExistingMembers ' admtReplaceConflicting + admtRemoveExistingUserRights + admtRemoveExistingMembers ' admtRenameConflictingWithPrefix ' admtRenameConflictingWithSuffix ' - optional, default is admtIgnoreConflicting ' ' ConflictPrefixOrSuffix Property ' - specifies the prefix or suffix to be added to migrated account names ' that have a naming conflict with a target domain account ' - applicable only if ConflictOptions is admtRenameConflictingWithPrefix or ' admtRenameConflictingWithSuffix ' ' UserPropertiesToExclude ' - specifies user properties that are not to be copied from source to target. ' - note that the asterisk character '*' may be used to exclude all properties ' ' InetOrgPersonPropertiesToExclude ' - specifies inetOrgPerson properties that are not to be copied from source to target. ' - note that the asterisk character '*' may be used to exclude all properties ' ' GroupPropertiesToExclude ' - specifies group properties that are not to be copied from source to target. ' - note that the asterisk character '*' may be used to exclude all properties ' ' ComputerPropertiesToExclude ' - specifies computer properties that are not to be copied from source to target. ' - note that the asterisk character '*' may be used to exclude all properties ' ' SystemPropertiesToExclude ' - specifies system properties that are not to be copied from source to target for any objects ' - the default system properties that are excluded are 'mail' and 'proxyAddresses' ' - note that the system properties to be excluded are saved in the database and therefore this ' property only needs to be set once ' ' CreateUserMigration Method ' - creates an instance of a user migration object ' ' CreateGroupMigration Method ' - creates an instance of a group migration object ' ' CreateComputerMigration Method ' - creates an instance of a computer migration object ' ' CreateSecurityTranslation Method ' - creates an instance of a security translation object ' ' CreateServiceAccountEnumeration Method ' - creates an instance of a service account enumeration object ' ' CreateReportGeneration Method ' - creates an instance of a report generation object '---------------------------------------------------------------------------- ' create instance of migration object Set objMigration = CreateObject("ADMT.Migration") ' set options 'objMigration.TestMigration = False 'objMigration.IntraForest = False objMigration.SourceDomain = "MYSOURCEDOMAIN" 'objMigration.SourceOU = "" objMigration.TargetDomain = "mytargetdomain.mycompany.com" objMigration.TargetOU = "Users" 'objMigration.RenameOption = admtDoNotRename 'objMigration.RenamePrefixOrSuffix = "" 'objMigration.PasswordOption = admtComplexPassword 'objMigration.PasswordServer = "" 'objMigration.PasswordFile = "C:\Program Files\Active Directory Migration Tool\Logs\Password.txt" 'objMigration.ConflictOptions = admtIgnoreConflicting 'objMigration.ConflictPrefixOrSuffix = "" 'objMigration.UserPropertiesToExclude = "" 'objMigration.InetOrgPersonPropertiesToExclude = "" 'objMigration.GroupPropertiesToExclude = "" 'objMigration.ComputerPropertiesToExclude = "" 'objMigration.SystemPropertiesToExclude = "mail,proxyAddresses" '---------------------------------------------------------------------------- ' UserMigration Class ' ' DisableOption Property ' - specifies whether to disable source or target account ' - applicable only for inter-forest migration ' - optional, default is admtEnableTarget ' ' SourceExpiration Property ' - specifies the expiration period of the source account in days ' - a value of admtNoExpiration specifies no source account expiration ' - applicable only for inter-forest migration ' - optional, default is admtNoExpiration ' ' MigrateSIDs Property ' - specifies whether to migrate security identifiers to the target domain ' - applicable only for inter-forest migration ' - optional, default is false ' ' TranslateRoamingProfile Property ' - specifies whether to perform security translation on roaming profiles ' - optional, default is false ' ' UpdateUserRights Property ' - specifies whether to update user rights in the domain ' - optional, default is false ' ' MigrateGroups Property ' - specifies whether to migrate groups that have as members accounts being ' migrated ' - optional, default is false ' ' UpdatePreviouslyMigratedObjects Property ' - specifies whether previously migrated accounts should be re-migrated ' - applicable only for inter-forest migration ' - optional, default is false ' ' FixGroupMembership Property ' - specifies whether group memberships will be re-established for migrated ' accounts ' - optional, default is true ' ' MigrateServiceAccounts Property ' - specifies whether to migrate service accounts ' - optional, default is false ' ' Migrate Method ' - migrate specified user accounts ' - the first parameter specifies whether the names are directly specified or ' the names are contained in the specified file or the names are to be ' enumerated from the specified domain or ou ' - the second parameter specifies the account names to be included ' - the third parameter optionally specifies names which are to be excluded ' ' - Note: Only the specified source OU will be used whether names are ' directly specified or specified in a file or the domain is ' searched. If no source OU is specified than the root of the domain ' is used. '---------------------------------------------------------------------------- ' create instance of user migration object Set objUserMigration = objMigration.CreateUserMigration ' set options 'objUserMigration.DisableOption = admtEnableTarget 'objUserMigration.SourceExpiration = admtNoExpiration 'objUserMigration.MigrateSIDs = False 'objUserMigration.TranslateRoamingProfile = False 'objUserMigration.UpdateUserRights = False 'objUserMigration.MigrateGroups = False 'objUserMigration.UpdatePreviouslyMigratedObjects = False 'objUserMigration.FixGroupMembership = True 'objUserMigration.MigrateServiceAccounts = False ' migrate user accounts ' the following are some examples of specifying the names and exclude names objUserMigration.Migrate admtData, "CN=User1" objUserMigration.Migrate admtData, Array("/Users/User3","\User4") objUserMigration.Migrate admtFile, "C:\Users.txt", Array("begins_with*","*contains*","*ends_with") objUserMigration.Migrate admtDomain, , "C:\ExcludeNames.txt" '---------------------------------------------------------------------------- ' GroupMigration Class ' ' UpdateGroupRights Property ' - specifies whether to update group domain rights ' - optional, default is false ' ' UpdatePreviouslyMigratedObjects Property ' - specifies whether previously migrated accounts should be re-migrated ' - applicable only for inter-forest migration ' - optional, default is false ' ' FixGroupMembership Property ' - specifies whether group memberships will be re-established for migrated ' accounts ' - optional, default is true ' ' MigrateSIDs Property ' - specifies whether to migrate security identifiers to the target domain ' - applicable only for inter-forest migration ' - optional, default is false ' ' MigrateMembers Property ' - specifies whether to migrate members of groups during migration ' - optional, default is false ' ' DisableOption Property ' - specifies whether to disable source user accounts or target user accounts ' when copying members ' - applicable only if copying members in an inter-forest migration ' - optional, default is admtEnableTarget ' ' SourceExpiration Property ' - specifies the expiration period of source user accounts in days when ' copying members ' - a value of admtNoExpiration specifies no source user account expiration ' - applicable only if copying members in an inter-forest migration ' - optional, default is admtNoExpiration ' ' TranslateRoamingProfile Property ' - specifies whether to perform security translation on roaming profiles ' - applicable only if copying members in an inter-forest migration ' - optional, default is false ' ' Migrate Method ' - migrate specified group accounts ' - the first parameter specifies whether the names are directly specified or ' the names are contained in the specified file or the names are to be ' enumerated from the specified domain or ou ' - the second parameter specifies the account names to be included ' - the third parameter optionally specifies names which are to be excluded ' ' - Note: Only the specified source OU will be used whether names are ' directly specified or specified in a file or the domain is ' searched. If no source OU is specified than the root of the domain ' is used. '---------------------------------------------------------------------------- ' create instance of group migration object Set objGroupMigration = objMigration.CreateGroupMigration ' set options 'objGroupMigration.MigrateSIDs = False 'objGroupMigration.UpdateGroupRights = False 'objGroupMigration.UpdatePreviouslyMigratedObjects = False 'objGroupMigration.FixGroupMembership = True 'objGroupMigration.MigrateMembers = False 'objGroupMigration.DisableOption = admtDisableNeither 'objGroupMigration.SourceExpiration = admtNoExpiration 'objGroupMigration.TranslateRoamingProfile = False ' migrate group accounts ' the following are some examples of specifying the names and exclude names objGroupMigration.Migrate admtData, "CN=Group1" objGroupMigration.Migrate admtData, Array("/Users/Group3","\Group4") objGroupMigration.Migrate admtFile, "C:\Groups.txt", Array("begins_with*","*contains*","*ends_with") objGroupMigration.Migrate admtDomain, , "C:\ExcludeNames.txt" '---------------------------------------------------------------------------- ' ComputerMigration Class ' ' - the following translate options specify whether to perform security ' translation on that type of objects during the computer migration ' ' TranslateFilesAndFolders Property ' - specifies whether to perform security translation on files and folders ' - optional, default is false ' ' TranslateLocalGroups Property ' - specifies whether to perform security translation on local groups ' - optional, default is false ' ' TranslatePrinters Property ' - specifies whether to perform security translation on printers ' - optional, default is false ' ' TranslateRegistry Property ' - specifies whether to perform security translation on registry ' - optional, default is false ' ' TranslateShares Property ' - specifies whether to perform security translation on shares ' - optional, default is false ' ' TranslateUserProfiles Property ' - specifies whether to perform security translation on user profiles ' - optional, default is false ' ' TranslateUserRights Property ' - specifies whether to perform security translation on user rights ' - optional, default is false ' ' RestartTime Property ' - specifies the time in minutes to wait before re-booting the computers ' after migrating ' - the valid range is 1 to 10 minutes ' - optional, default is 5 minutes ' ' Migrate Method ' - migrate specified computer accounts ' - the first parameter specifies whether the names are directly specified or ' the names are contained in the specified file or the names are to be ' enumerated from the specified domain or ou ' - the second parameter specifies the account names to be included ' - the third parameter optionally specifies names which are to be excluded ' ' - Note: Only the specified source OU will be used whether names are ' directly specified or specified in a file or the domain is ' searched. If no source OU is specified than the root of the domain ' is used. '---------------------------------------------------------------------------- ' create instance of computer migration object Set objComputerMigration = objMigration.CreateComputerMigration ' set options 'objComputerMigration.TranslationOption = admtTranslateAdd 'objComputerMigration.TranslateFilesAndFolders = False 'objComputerMigration.TranslateLocalGroups = False 'objComputerMigration.TranslatePrinters = False 'objComputerMigration.TranslateRegistry = False 'objComputerMigration.TranslateShares = False 'objComputerMigration.TranslateUserProfiles = False 'objComputerMigration.TranslateUserRights = False 'objComputerMigration.RestartDelay = 1 ' migrate computer accounts ' the following are some examples of specifying the names and exclude names objComputerMigration.Migrate admtData, "CN=Computer1" objComputerMigration.Migrate admtData, Array("/Computers/Computer3","\Computer4") objComputerMigration.Migrate admtFile, "C:\Computers.txt", Array("begins_with*","*contains*","*ends_with") objComputerMigration.Migrate admtDomain, , "C:\ExcludeNames.txt" '---------------------------------------------------------------------------- ' SecurityTranslation Class ' ' TranslationOption ' - specifies whether to add, replace or remove entries from access control lists ' ' TranslateFilesAndFolders Property ' - specifies whether to perform security translation on files and folders ' - optional, default is false ' ' TranslateLocalGroups Property ' - specifies whether to perform security translation on local groups ' - optional, default is false ' ' TranslatePrinters Property ' - specifies whether to perform security translation on printers ' - optional, default is false ' ' TranslateRegistry Property ' - specifies whether to perform security translation on registry ' - optional, default is false ' ' TranslateShares Property ' - specifies whether to perform security translation on shares ' - optional, default is false ' ' TranslateUserProfiles Property ' - specifies whether to perform security translation on user profiles ' - optional, default is false ' ' TranslateUserRights Property ' - specifies whether to perform security translation on user rights ' - optional, default is false ' ' SidMappingFile Property ' - specifies whether to use a mapping of SIDs from specified file ' - if a SID mapping file is not specified, then security translation ' maps SIDs from previously migration objects ' - optional, default is none ' ' Translate Method ' - perform security translation on specified computers ' - the first parameter specifies whether the names are directly specified or ' the names are contained in the specified file or the names are to be ' enumerated from the specified domain or ou ' - the second parameter specifies the account names to be included ' - the third parameter optionally specifies names which are to be excluded ' - if specifying NT4 style names for Windows 2000, or greater, domains the name must be ' preceded with a backslash ' eg. \NT4Name ' ' - Note: The source domain and OU will be used if not explicitly specified '---------------------------------------------------------------------------- ' create instance of security translation object Set objSecurityTranslation = objMigration.CreateSecurityTranslation ' set options 'objSecurityTranslation.TranslationOption = admtTranslateAdd 'objSecurityTranslation.TranslateFilesAndFolders = False 'objSecurityTranslation.TranslateLocalGroups = False 'objSecurityTranslation.TranslatePrinters = False 'objSecurityTranslation.TranslateRegistry = False 'objSecurityTranslation.TranslateShares = False 'objSecurityTranslation.TranslateUserProfiles = False 'objSecurityTranslation.TranslateUserRights = False 'objSecurityTranslation.SidMappingFile = "C:\SidMappingFile.txt" ' translate security on specified computers ' the following are some examples of specifying the names and exclude names objSecurityTranslation.Translate admtData, "CN=Computer2" objSecurityTranslation.Translate admtData, Array("/Computers/Computer3","\Computer4") objSecurityTranslation.Translate admtFile, "C:\Computers.txt", Array("begins_with*","*contains*","*ends_with") objSecurityTranslation.Translate admtDomain, , "C:\ExcludeNames.txt" '---------------------------------------------------------------------------- ' ServiceAccountEnumeration Class ' ' Enumerate Method ' - enumerate service accounts on specified computers ' - the first parameter specifies whether the names are directly specified or ' the names are contained in the specified file or the names are to be ' enumerated from the specified domain or ou ' - the second parameter specifies the account names to be included ' - the third parameter optionally specifies names which are to be excluded ' - if specifying NT4 style names for Windows 2000, or greater, domains the name must be ' preceded with a backslash ' eg. \NT4Name ' ' - Note: The source domain and OU will be used if not explicitly specified '---------------------------------------------------------------------------- ' create instance of service account enumeration object Set objServiceAccountEnumeration = objMigration.CreateServiceAccountEnumeration ' enumerate service accounts on specified computers ' the following are some examples of specifying the names and exclude names objServiceAccountEnumeration.Enumerate admtData, "CN=Computer1" objServiceAccountEnumeration.Enumerate admtData, Array("/Computers/Computer3","\Computer4") objServiceAccountEnumeration.Enumerate admtFile, "C:\Computers.txt", Array("begins_with*","*contains*","*ends_with") objServiceAccountEnumeration.Enumerate admtDomain, , "C:\ExcludeNames.txt" '---------------------------------------------------------------------------- ' ReportGeneration Class ' ' Type Property ' - specifies the type of report to generate ' ' Folder Property ' - specifies the folder where reports will be generated ' - optional, defaults to Reports folder in the ADMT installation folder ' ' Generate Method ' - generate specified report ' - the option should be admtNone for the admtReportMigratedAccounts, ' admtReportMigratedComputers, admtReportExpiredComputers, and ' admtReportNameConflicts reports ' - the option must be admtData, admtFile or admtDomain for the ' admtReportAccountReferences report ' - the include parameter must specify the computers upon which to collect ' account reference information if the admtReportAccountReferences report ' is specified '---------------------------------------------------------------------------- ' create instance of report generation object Set objReportGeneration = objMigration.CreateReportGeneration ' generate report objReportGeneration.Type = admtReportMigratedAccounts 'objReportGeneration.Folder = "C:\Program Files\Active Directory Migration Tool\Reports" objReportGeneration.Generate admtNone 'objReportGeneration.Generate admtDomain + admtRecurse
<filename>admin/pchealth/sr/tools/scripting/disable.vbs Set Args = wscript.Arguments If Args.Count() > 0 Then Drive = Args.item(0) Else Drive = "" End If Set obj = GetObject("winmgmts:{impersonationLevel=impersonate}!root/default:SystemRestore") If (obj.Disable(Drive)) = 0 Then wscript.Echo "Success" Else wscript.Echo "Failed" End If
<filename>admin/pchealth/authtools/prodtools/unused/cabstatistics/frmmain.frm VERSION 5.00 Begin VB.Form frmMain BorderStyle = 1 'Fixed Single Caption = "CabStatistics" ClientHeight = 3855 ClientLeft = 45 ClientTop = 330 ClientWidth = 4710 LinkTopic = "Form1" MaxButton = 0 'False MinButton = 0 'False ScaleHeight = 3855 ScaleWidth = 4710 StartUpPosition = 3 'Windows Default Begin VB.TextBox txtOutput Height = 2775 Left = 120 Locked = -1 'True MultiLine = -1 'True ScrollBars = 2 'Vertical TabIndex = 4 Top = 480 Width = 4455 End Begin VB.CommandButton cmdClose Caption = "Close" Height = 375 Left = 3720 TabIndex = 3 Top = 3360 Width = 855 End Begin VB.TextBox txtCAB Height = 285 Left = 600 TabIndex = 1 Top = 120 Width = 3975 End Begin VB.CommandButton cmdGo Caption = "Go" Height = 375 Left = 2760 TabIndex = 2 Top = 3360 Width = 855 End Begin VB.Label lblCAB Caption = "CAB:" Height = 255 Index = 0 Left = 120 TabIndex = 0 Top = 120 Width = 375 End End Attribute VB_Name = "frmMain" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Private Const PKG_DESC_FILE_C As String = "package_description.xml" Private Const PKG_DESC_HHT_C As String = "HELPCENTERPACKAGE/METADATA/HHT" Private Const HHT_KEYWORD_C As String = "METADATA/TAXONOMY_ENTRIES/TAXONOMY_ENTRY/KEYWORD" Private Const HHT_NODE_C As String = "METADATA/TAXONOMY_ENTRIES//TAXONOMY_ENTRY[string-length(@ENTRY) > 0]" Private Const HHT_TOPIC_C As String = "METADATA/TAXONOMY_ENTRIES//TAXONOMY_ENTRY[string-length(@ENTRY) = 0]" Private FSO As Scripting.FileSystemObject Private WS As IWshShell Private Sub Form_Load() Dim strCAB As String Set FSO = New Scripting.FileSystemObject Set WS = CreateObject("Wscript.Shell") cmdGo.Default = True cmdClose.Cancel = True strCAB = Trim$(Command$) txtCAB = strCAB If (Len(strCAB) <> 0) Then Me.Show False cmdGo_Click End If End Sub Private Sub cmdGo_Click() On Error GoTo LError Dim strCAB As String Dim strFolder As String strCAB = Trim$(txtCAB.Text) If (strCAB = "") Then MsgBox "Please specify the CAB", vbOKOnly Exit Sub End If Me.Enabled = False strFolder = p_Cab2Folder(strCAB) FixPerSe strCAB, strFolder FSO.DeleteFolder strFolder, True LEnd: Me.Enabled = True Exit Sub LError: GoTo LEnd End Sub Private Sub cmdClose_Click() Set FSO = Nothing Set WS = Nothing Unload Me End Sub Private Sub FixPerSe( _ ByVal i_strCAB As String, _ ByVal i_strFolder As String _ ) On Error GoTo LError Dim File As Scripting.File Dim DOMDocPkgDesc As MSXML2.DOMDocument Dim DOMNodeListHHT As MSXML2.IXMLDOMNodeList Dim DOMNodeHHTRef As MSXML2.IXMLDOMNode Dim DOMNodeHHT As MSXML2.DOMDocument Dim DOMNodeList As MSXML2.IXMLDOMNodeList Dim strHhtFile As String Dim intTotalKeywordMatches As Long Dim intTotalNodes As Long Dim intTotalTopics As Long Dim intKeywordMatches As Long Dim intNodes As Long Dim intTopics As Long Set File = FSO.GetFile(i_strCAB) p_Output "CAB file size: " & File.Size p_Output "" Set DOMDocPkgDesc = p_GetPackage(i_strFolder) If (DOMDocPkgDesc Is Nothing) Then GoTo LEnd End If Set DOMNodeListHHT = DOMDocPkgDesc.selectNodes(PKG_DESC_HHT_C) For Each DOMNodeHHTRef In DOMNodeListHHT Set DOMNodeHHT = p_GetHht(DOMNodeHHTRef, i_strFolder, strHhtFile) DOMNodeHHT.setProperty "SelectionLanguage", "XPath" p_Output "File: " & strHhtFile If (Not DOMNodeHHT Is Nothing) Then Set DOMNodeList = DOMNodeHHT.selectNodes(HHT_KEYWORD_C) intKeywordMatches = DOMNodeList.length p_Output " Keyword matches: " & intKeywordMatches intTotalKeywordMatches = intTotalKeywordMatches + intKeywordMatches Set DOMNodeList = DOMNodeHHT.selectNodes(HHT_NODE_C) intNodes = DOMNodeList.length p_Output " Nodes: " & intNodes intTotalNodes = intTotalNodes + intNodes Set DOMNodeList = DOMNodeHHT.selectNodes(HHT_TOPIC_C) intTopics = DOMNodeList.length p_Output " Topics: " & intTopics intTotalTopics = intTotalTopics + intTopics End If Next p_Output "" p_Output "Total Keyword matches: " & intTotalKeywordMatches p_Output "Total Nodes: " & intTotalNodes p_Output "Total Topics: " & intTotalTopics LEnd: Exit Sub LError: MsgBox _ "Error 0x" & Hex(Err.Number) & vbCrLf & _ Err.Description End Sub Private Sub p_Output( _ ByVal i_str As String _ ) If (txtOutput <> "") Then txtOutput = txtOutput & vbCrLf & i_str Else txtOutput = i_str End If End Sub Private Function p_GetPackage( _ ByVal i_strFolder As String _ ) As MSXML2.DOMDocument Dim DOMDocPkg As MSXML2.DOMDocument Dim strPkgFile As String Set DOMDocPkg = New MSXML2.DOMDocument strPkgFile = i_strFolder & "\" & PKG_DESC_FILE_C DOMDocPkg.async = False DOMDocPkg.Load strPkgFile If (DOMDocPkg.parseError <> 0) Then p_DisplayParseError DOMDocPkg.parseError GoTo LEnd End If Set p_GetPackage = DOMDocPkg LEnd: End Function Private Function p_GetHht( _ ByVal i_DOMNodeHHT As MSXML2.IXMLDOMNode, _ ByVal i_strFolder As String, _ ByRef o_strHhtFile As String _ ) As MSXML2.IXMLDOMNode Dim DOMDocHHT As MSXML2.DOMDocument If (i_DOMNodeHHT Is Nothing) Then GoTo LEnd o_strHhtFile = i_DOMNodeHHT.Attributes.getNamedItem("FILE").Text Set DOMDocHHT = New MSXML2.DOMDocument DOMDocHHT.async = False DOMDocHHT.Load i_strFolder + "\" + o_strHhtFile If (DOMDocHHT.parseError <> 0) Then p_DisplayParseError DOMDocHHT.parseError GoTo LEnd End If Set p_GetHht = DOMDocHHT LEnd: End Function Private Function p_Cab2Folder( _ ByVal i_strCabFile As String _ ) As String Dim strFolder As String Dim strCmd As String p_Cab2Folder = "" ' We grab a Temporary Filename and create a folder out of it strFolder = FSO.GetSpecialFolder(TemporaryFolder) + "\" + FSO.GetTempName FSO.CreateFolder strFolder ' We uncab CAB contents into the Source CAB Contents dir. strCmd = "cabarc X " + i_strCabFile + " " + strFolder + "\" WS.Run strCmd, True, True p_Cab2Folder = strFolder End Function Private Sub p_Folder2Cab( _ ByVal i_strFolder As String, _ ByVal i_strCabFile As String _ ) Dim strCmd As String If (FSO.FileExists(i_strCabFile)) Then FSO.DeleteFile i_strCabFile, True End If strCmd = "cabarc -r -s 6144 n """ & i_strCabFile & """ " & i_strFolder & "\*" WS.Run strCmd, True, True End Sub Private Sub p_DisplayParseError( _ ByRef i_ParseError As MSXML2.IXMLDOMParseError _ ) Dim strError As String With i_ParseError strError = "Error: " & .reason & _ "Line: " & .Line & vbCrLf & _ "Linepos: " & .linepos & vbCrLf & _ "srcText: " & .srcText End With MsgBox strError, vbOKOnly, "Error while parsing" End Sub
<filename>ds/security/azroles/tests/outold.vbs Sub DeleteAFile(filespec) Dim fso Set fso = CreateObject("Scripting.FileSystemObject") fso.DeleteFile(filespec) End Sub rem DeleteAFile("abc.xml") Dim pAdminManager Set pAdminManager=CreateObject("AzRoles.AzAdminManager") pAdminManager.Initialize 1, "msxml://abc.xml" pAdminManager.Submit Dim AppHandle1 Set AppHandle1=pAdminManager.CreateApplication("MyApp", 0) AppHandle1.Submit Dim OpHandle1 Set OpHandle1=AppHandle1.CreateOperation("Op1", 0) OpHandle1.Submit OpHandle1.SetProperty 200, CLng(61) OpHandle1.Submit Set OpHandle1=AppHandle1.CreateOperation("Op2", 0) OpHandle1.Submit OpHandle1.SetProperty 200, CLng(62) OpHandle1.Submit Set OpHandle1=AppHandle1.CreateOperation("Op3", 0) OpHandle1.Submit OpHandle1.SetProperty 200, CLng(63) OpHandle1.Submit Set OpHandle1=AppHandle1.CreateOperation("Op4", 0) OpHandle1.Submit OpHandle1.SetProperty 200, CLng(64) OpHandle1.Submit Dim GroupHandleA Set GroupHandleA=AppHandle1.CreateApplicationGroup("GroupWorld", 0) GroupHandleA.SetProperty 400, CLng(2) GroupHandleA.AddPropertyItem 404, CStr("s-1-1-0") GroupHandleA.Submit Set GroupHandleA=AppHandle1.CreateApplicationGroup("GroupNotAMember", 0) GroupHandleA.SetProperty 400, CLng(2) GroupHandleA.AddPropertyItem 404, CStr("S-1-1000-1") GroupHandleA.Submit Set GroupHandleA=AppHandle1.CreateApplicationGroup("GroupAppMember", 0) GroupHandleA.SetProperty 400, CLng(2) GroupHandleA.AddPropertyItem 401, CStr("GroupWorld") GroupHandleA.Submit Set GroupHandleA=AppHandle1.CreateApplicationGroup("GroupAppNonMember", 0) GroupHandleA.SetProperty 400, CLng(2) GroupHandleA.AddPropertyItem 401, CStr("GroupAppMember") GroupHandleA.AddPropertyItem 402, CStr("GroupNotAMember") GroupHandleA.Submit Set GroupHandleA=AppHandle1.CreateApplicationGroup("GroupAppReallyNonMember", 0) GroupHandleA.SetProperty 400, CLng(2) GroupHandleA.AddPropertyItem 401, CStr("GroupAppMember") GroupHandleA.AddPropertyItem 402, CStr("GroupWorld") GroupHandleA.Submit Set GroupHandleA=AppHandle1.CreateApplicationGroup("GroupLdapYes", 0) GroupHandleA.SetProperty 400, CLng(1) GroupHandleA.SetProperty 403, CStr("(userAccountControl=1049088)") GroupHandleA.Submit Set GroupHandleA=AppHandle1.CreateApplicationGroup("GroupLdapNo", 0) GroupHandleA.SetProperty 400, CLng(1) GroupHandleA.SetProperty 403, CStr("(userAccountControl=1049089)") GroupHandleA.Submit Dim ScopeHandle1 Set ScopeHandle1=AppHandle1.CreateScope("MyScopeNoRoles", 0) ScopeHandle1.Submit Set ScopeHandle1=AppHandle1.CreateScope("MyScope", 0) ScopeHandle1.Submit Dim CCHandle Set CCHandle=AppHandle1.InitializeClientContextFromToken(0, 0) Dim RoleHandleA Set RoleHandleA=ScopeHandle1.CreateRole("RoleEveryoneCanOp1", 0) RoleHandleA.Submit Dim Groups RoleHandleA.AddPropertyItem 501, CStr("s-1-1-0") Groups = RoleHandleA.GetProperty( 501, 0 ) rem MsgBox( Groups(0) ) RoleHandleA.AddPropertyItem 502, CStr("Op1") Set RoleHandleA=ScopeHandle1.CreateRole("RoleGroupWorldCanOp2", 0) RoleHandleA.AddPropertyItem 500, CStr("GroupWorld") Groups = RoleHandleA.GetProperty( 500, 0 ) rem MsgBox( Groups(0) ) RoleHandleA.AddPropertyItem 502, CStr("Op2") Set RoleHandleA=ScopeHandle1.CreateRole("RoleGroupCantOp3", 0) RoleHandleA.AddPropertyItem 500, CStr("GroupNotAMember") RoleHandleA.AddPropertyItem 502, CStr("Op3") RoleHandleA.Submit Set ScopeHandle1=AppHandle1.CreateScope("MyScope2", 0) ScopeHandle1.Submit Set RoleHandleA=ScopeHandle1.CreateRole("Role2GroupWorldCanOp2", 0) RoleHandleA.AddPropertyItem 500, CStr("GroupWorld") RoleHandleA.AddPropertyItem 502, CStr("Op2") RoleHandleA.Submit Set RoleHandleA=ScopeHandle1.CreateRole("Role2aGroupWorldCanOp2", 0) RoleHandleA.AddPropertyItem 500, CStr("GroupWorld") RoleHandleA.AddPropertyItem 502, CStr("Op2") RoleHandleA.Submit Set RoleHandleA=ScopeHandle1.CreateRole("Role2GroupCantOp3", 0) RoleHandleA.AddPropertyItem 500, CStr("GroupNotAMember") RoleHandleA.AddPropertyItem 502, CStr("Op3") RoleHandleA.Submit Set RoleHandleA=ScopeHandle1.CreateRole("Role2GroupWorldCanOp3", 0) RoleHandleA.AddPropertyItem 500, CStr("GroupWorld") RoleHandleA.AddPropertyItem 502, CStr("Op3") RoleHandleA.Submit Set RoleHandleA=ScopeHandle1.CreateRole("Role2GroupWorldCanOp4", 0) RoleHandleA.AddPropertyItem 500, CStr("GroupWorld") RoleHandleA.AddPropertyItem 502, CStr("Op4") RoleHandleA.Submit Set RoleHandleA=ScopeHandle1.CreateRole("Role2GroupCantOp4", 0) RoleHandleA.AddPropertyItem 500, CStr("GroupNotAMember") RoleHandleA.AddPropertyItem 502, CStr("Op4") RoleHandleA.Submit Dim TaskHandle1 Set TaskHandle1=AppHandle1.CreateTask("TaskOp1", 0) TaskHandle1.AddPropertyItem 300, CStr("Op1") TaskHandle1.SetProperty 302, CStr("VBScript") TaskHandle1.SetProperty 301, CStr("Dim Amount" & vbCr & "Amount = AccessCheck.GetParameter( " & Chr(34) & "Amount" & Chr(34) & ")" & vbCr & "if Amount < 500 then AccessCheck.BusinessRuleResult = TRUE") TaskHandle1.Submit Set ScopeHandle1=AppHandle1.CreateScope("MyScope6", 0) ScopeHandle1.Submit Set RoleHandleA=ScopeHandle1.CreateRole("RoleEveryoneCanOp1ViaTask1", 0) RoleHandleA.AddPropertyItem 501, CStr("s-1-1-0") RoleHandleA.AddPropertyItem 504, CStr("TaskOp1") Set ScopeHandle1=AppHandle1.CreateScope("MyScopeQ1", 0) ScopeHandle1.Submit Set RoleHandleA=ScopeHandle1.CreateRole("RoleLdapCanOp1", 0) RoleHandleA.AddPropertyItem 500, CStr("GroupLdapYes") RoleHandleA.AddPropertyItem 504, CStr("TaskOp1") Dim Results Dim Names(5) Dim Values(5) Dim Scopes(5) Dim Operations(10) Names(0) = "Amount" Values(0) = 50 Names(1) = "Name" Values(1) = "Bob" Scopes(0) = "MyScopeQ1" Operations(0) = 61 Results=CCHandle.AccessCheck("MyObject", Scopes, Operations, Names, Values ) If Results(0) = 5 Then MsgBox("Broken 1") Else MsgBox("Is OK 1") End if TaskHandle1.SetProperty 301, CStr("AccessCheck.BusinessRuleString = " & Chr(34) & "Fred" & Chr(34) & vbCr & "if AccessCheck.BusinessRuleString = " & Chr(34) & "Fred" & Chr(34) & "then AccessCheck.BusinessRuleResult = TRUE") Results=CCHandle.AccessCheck("MyObject", Scopes, Operations, Names, Values ) If Results(0) = 5 Then MsgBox("Broken 2") Else MsgBox("Is OK 2") End if MsgBox( "Should be fred: " & CCHandle.GetBusinessRuleString ) TaskHandle1.SetProperty 301, CStr("if AccessCheck.BusinessRuleString = " & Chr(34) & Chr(34) & "then AccessCheck.BusinessRuleResult = TRUE") Results=CCHandle.AccessCheck("MyObject", Scopes, Operations, Names, Values ) If Results(0) = 5 Then MsgBox("Broken 3") Else MsgBox("Is OK 3") End if MsgBox( "Should be NULL: " & CCHandle.GetBusinessRuleString )