Running Scripts from the Command Line


cscript service_info.vbs > c:\scripts\services.txt

cscript service_info.vbs >> c:\scripts\services.txt

cscript //nologo service_info.vbs > c:\scripts\services.txt


Table 3.2 Script Host Options

Parameter

Description

//B

Batch mode; suppresses display of user prompts and script errors. For example, if your script includes messages displayed using Wscript.Echo, these messages will not appear when the script runs in Batch mode. Batch mode also suppresses the use of VBScript functions such as Msgbox.

The default is Interactive mode.

//D

Turns on the Microsoft Script Debugger if this program is installed. The Script Debugger ships as part of Windows 2000, although it is not installed by default. The Script Debugger does not ship with Windows XP .

If the Script Debugger is not installed, no error will occur. Instead, the script will simply run.

//E:engine

Executes the script with the specified script engine. Among other things, this allows you to run scripts that use a custom file name extension. Without the //E argument, you can run only scripts that use registered file name extensions. For example, if you try to run this command:

cscript test.admin

You will receive this error message:

Input Error: There is no script engine for file extension ".admin".

To run a script that uses a custom file extension, include the //E argument:

cscript //E:vbscript test.admin

One advantage of using nonstandard file name extensions is that it guards against accidentally double-clicking a script and thus running something you really did not want to run.

This does not create a permanent association between the .admin file name extension and VBScript. Each time you run a script that uses a .admin file name extension, you will need to use the //E argument.

//H:CScript or //H:WScript

Registers Cscript.exe or Wscript.exe as the default application for running scripts. When WSH is initially installed, WScript is set as the default script host.

//I

Interactive mode; allows display of user prompts and script errors. This is the default mode and is the opposite of Batch mode.

//logo

Displays a logo when the script runs under CScript (this is the default setting for WSH). The logo, which appears prior to any of the output from the script, looks like this:Microsoft (R) Windows Script Host Version 5.6Copyright (C) Microsoft Corporation 1996-2000. All rights reserved.

//nologo

Prevents display of the logo at run time (by default, the logo is displayed).

The //nologo option is often used for scripts whose output is redirected to a text file. Suppressing the logo ensures that this information does not appear within the text file. This makes it easier to write scripts that parse the information found in the text file or that import the contents of the file to a database, because these scripts do not have to account for the logo.

//S

Saves the Timeout and Logo options for this user. For example, this command ensures that the logo will be suppressed anytime a script runs under CScript:

cscript //nologo //S

You can also modify these settings by right-clicking a script file and then clicking Properties.

//T:nn

Determines the maximum number of seconds the script can run. (The default is no limit.) The //T parameter prevents excessive execution of scripts by setting a timer. When execution time exceeds the specified value, the script host interrupts the script engine and terminates the process.

//X

Starts the program in the Microsoft Script Debugger. If the Script Debugger is not installed, the script simply runs.

//?

Displays a brief description of command parameters (the usage information). The usage information is similar to the information presented in this table, although with less explanation. For example, here is the usage information for the //E argument://E:engine Use engine for executing script


Posted by n3015m
:

Microsoft Beefs Up VBScript with Regular Expressions



[by n3015m]

Option Explicit


dim bl_num, bl_ip, bl_url, bl_filename, objFSO, objFile, strLine, objArgs, regExIP, regEXURL

Const ForReading = 1

dim chk_ip, chk_url


Set objArgs = WScript.Arguments

Set regExIP = New regExp

Set regExURL = New regExp

regExIP.Pattern = "([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})(.*)?"

regEXURL.pattern= "\??(hxxp:\/\/|hxxps:\/\/|http:\/\/|https:\/\/)?([a-zA-Z0-9\-\.\:]+)(\/.*)?"

if objArgs.Count = 0 then

WScript.Echo "A file-read error has occurred, Filename argument required." & vbCrlf & "- usage : " & Wscript.ScriptName & " [arguments]"

WScript.Quit

else

bl_filename = objArgs(0)

end if


Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.OpenTextFile(bl_filename, ForReading)


Do Until objFile.AtEndOfStream

strLine = objFile.ReadLine

bl_num = trim(split(strline,",")(0))

bl_ip = trim(split(strline,",")(4))

bl_url = trim(split(strline,",")(5))

if bl_url <> "" then

chk_ip = trim(regExIP.replace(bl_ip,"$1"))

chk_url = trim(regExURL.replace(bl_url,"$2"))

'Wscript.Echo bl_num & vbTab & bl_ip & vbTab & chk_ip & vbTab & bl_url

Wscript.Echo bl_num & vbTab & chk_url 

end if

Loop


objFile.Close



VBScript RegExp Object

PropertiesMethods
PatternTest (search-string)
IgnoreCaseReplace (search-string, replace-string)
GlobalExecute (search-string)


Position Matching

mbolFunction
^Only match the beginning of a string.

"^A" matches first "A" in "An A+ for Anita."
$Only match the ending of a string.

"t$" matches the last "t" in "A cat in the hat"
\bMatches any word boundary

"ly\b" matches "ly" in "possibly tomorrow."
\BMatches any non-word boundary

Literals

SymbolFunction
AlphanumericMatches alphabetical and numerical characters literally.
\nMatches a new line
\fMatches a form feed
\rMatches carriage return
\tMatches horizontal tab
\vMatches vertical tab
\?Matches ?
\*Matches *
\+Matches +
\.Matches .
\|Matches |
\{Matches {
\}Matches }
\\Matches \
\[Matches [
\]Matches ]
\(Matches (
\)Matches )
\xxxMatches the ASCII character expressed by the octal number xxx.
"\50" matches "(" or chr (40).
\xddMatches the ASCII character expressed by the hex number dd.
"\x28" matches "(" or chr (40).
\uxxxxMatches the ASCII character expressed by the UNICODE xxxx.
"\u00A3" matches "£".

Character Classes

SymbolFunction
[xyz]Match any one character enclosed in the character set.

"[a-e]" matches "b" in "basketball".
[^xyz]Match any one character not enclosed in the character set.

"[^a-e]" matches "s" in "basketball".
.Match any character except \n.
\wMatch any word character. Equivalent to [a-zA-Z_0-9].
\WMatch any non-word character. Equivalent to [^a-zA-Z_0-9].
\dMatch any digit. Equivalent to [0-9].
\DMatch any non-digit. Equivalent to [^0-9].
\sMatch any space character. Equivalent to [ \t\r\n\v\f].
\SMatch any non-space character. Equivalent to [^ \t\r\n\v\f].

Repetition

SymbolFunction
{x}Match exactly x occurrences of a regular expression.

"\d{5}" matches 5 digits.
{x,}Match x or more occurrences of a regular expression.

"\s{2,}" matches at least 2 space characters.
{x,y}Matches x to y number of occurrences of a regular expression.

"\d{2,3}" matches at least 2 but no more than 3 digits.
?Match zero or one occurrences. Equivalent to {0,1}.

"a\s?b" matches "ab" or "a b".
*Match zero or more occurrences. Equivalent to {0,}.
+Match one or more occurrences. Equivalent to {1,}.

Alternation & Grouping

SymbolFunction
()Grouping a clause to create a clause. May be nested. "(ab)?(c)" matches "abc" or "c".
|Alternation combines clauses into one regular expression and then matches any of the individual clauses.

"(ab)|(cd)|(ef)" matches "ab" or "cd" or "ef".

BackReferences

SymbolFunction
()\nMatches a clause as numbered by the left parenthesis

"(\w+)\s+\1" matches any word that occurs twice in a row, such as "hubba hubba."



Posted by n3015m
:

BLOG main image
'네오이즘'의 보안LAB 블로그입니다........... n3oism@gmail.com by n3015m

카테고리

분류 전체보기 (228)
[ HappyDevTool ] (29)
[ HappyToolRelease ] (4)
[Book] (6)
[ Security Studies ] (0)
- CII (2)
- BigData (2)
- Web Hacking (10)
- SQL Injection (25)
- Mobile Security (9)
- Network (6)
- OperatingSystem (4)
- Malware & Reversing (4)
- Phishing (5)
- Compliance (0)
- Programming (13)
- Tools (13)
- IoT (6)
- etc (21)
[Pentration Testing] (3)
[OS X] (4)
[ Security Trends ] (16)
[ Fixing Guideline ] (7)
My Way, My Life (34)
About Me (2)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

Total :
Today : Yesterday :