- °øÀ¯ Æú´õ¿¡ »ç¿ëÀÚ Ãß°¡Çϱâ
- ¸ÞÀÏ º¸³»±â
- ÀÏÁ¤ ½Ã°£ Áö³ ÆÄÀÏ »èÁ¦Çϱâ
- ƯÁ¤ ÆÄÀÏ FTP·Î ¾÷·ÎµåÇϱâ
- ¼Ò½º ¹é¾÷Çϱâ
- ½ºÅ©¸³Æ® Ãâ·ÂÀ» Ŭ¸³ º¸µå·Î º¹»çÇϱâ
- GUI ÇüÅ·Π»ç¿ëÀÚ ÀÔ·Â ¹Þ¾ÆµéÀ̱â
- »ç¿îµå(WAV) Ç÷¹ÀÌÇϱâ
- TCP ¼º´É µ¥ÀÌÅÍ ¾ò¾î³»±â
- ¿ø°Ý ÄÄÇ»ÅÍ¿¡¼ ÇÁ·Î±×·¥ ½ÇÇàÇϱâ
- µµ¸ÞÀÎ ¾È¿¡ ÀÖ´Â ¿©·¯ ´ëÀÇ ÄÄÇ»ÅÍ¿¡¼ ƯÁ¤ ¸í·É ¼öÇàÇϱâ
- ƯÁ¤ µð·ºÅ丮 ¹× ÇÏÀ§ µð·ºÅ丮¿¡ Á¸ÀçÇÏ´Â ÆÄÀÏ Ãâ·ÂÇϱâ
- µð½ºÅ© Á¶°¢ ¸ðÀ½ ½ÇÇàÇϱâ
- ³×Æ®¿öÅ© µå¶óÀÌºê ¸ÅÇÎÇϱâ
- ´Ù¸¥ ÇÁ·Î±×·¥ ½ÇÇàÇϱâ
- ÆÄÀϵéÀÇ ¹öÀü ¾Ë¾Æ³»±â
- »ç¿ëÀÚ ·Î±×¿Â/·Î±×¿ÀÇÁ ±â·Ï À̺¥Æ® ·Î±×¿¡ ³²±â±â
- ¸¶Áö¸·À¸·Î ·Î±×¿ÂÇÑ »ç¿ëÀÚ ¾Ë¾Æ³»±â
- ¿©·¯ ÄÄÇ»ÅÍ¿¡ ÀÖ´Â À̺¥Æ® ·Î±× ¸ðÀ¸±â
- ¿©·¯ ÄÄÇ»ÅÍÀÇ ÆäÀÌÁöÆÄÀÏ Å©±â ¹Ù²Ù±â
1 °øÀ¯ Æú´õ¿¡ »ç¿ëÀÚ Ãß°¡Çϱâ
Download adduser.vbs
ÀͽºÇ÷η¯ »ó¿¡¼ Á÷Á¢ ½ÇÇàÇÏ¸é °¢Á¾ ÀμöµéÀ» ÀÔ·ÂÇ϶ó´Â ´ëÈâÀÌ ¶á´Ù. ÀÌ°Ô ½ÈÀ¸¸é Ä¿¸Çµå ¶óÀο¡¼ ´ÙÀ½°ú °°Àº Çü½ÄÀ¸·Î ½ÇÇàÇÑ´Ù.
cscript adduser.vbs /option1:value /option2:value ...
¿É¼ÇÀÇ ¸ñ·ÏÀº ´ÙÀ½°ú °°´Ù.
| ¿É¼Ç | °¡´ÉÇÑ °ª |
| host | ÄÄÇ»ÅÍ À̸§ ¶Ç´Â IP ÁÖ¼Ò |
| share | °øÀ¯ À̸§. °æ·Î°¡ ¾Æ´Ï¶ó °øÀ¯ À̸§ÀÌ´Ï ÁÖÀÇ. |
| domain | µµ¸ÞÀÎ |
| account | °èÁ¤ ¶Ç´Â ±×·ì À̸§ |
| acc_type | user | group |
| ace_type | allow | deny | audit |
| access | read | change | full | none |
| prop | true | false |
2 ¸ÞÀÏ º¸³»±â
Å×½ºÆ®Çغ¸´Ï µÈ´Ù. ¾Æ¿ô·è ¼³Ä¡ ¿©ºÎ´Â ¹«°üÇÏ´Ù. ÆÐ½º¿öµå¸¦ ÀÔ·ÂÇÏÁö ¾Ê´Âµ¥, ¾î¶»°Ô Àü¼ÛµÇ´Â °ÅÁö...? ¾×Ƽºê µð·ºÅ丮 °°Àº °É ÅëÇØ ÀÚµ¿À¸·Î ÀÎÁõÀÌ µÇ´Â ¸ð¾çÀÌ´Ù.
SendMail "smtp.somewhere.co.kr", _
"º¸³»´Â »ç¶÷ <someone@somewhere.co.kr>", _
"À̰ÍÀº Á¦¸ñÀÌÁö¿ä", _
"recipient@somewhere.co.kr", _
"À̰ÍÀº ³»¿ëÀÔ´Ï´Ù", _
""
Function SendMail(SmtpServer, SenderEmail, Subject, Recipient, Message, Attachment)
Dim iMsg
Dim iConf
Dim Flds
'We will use CDO Send Using Port in this example
Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2
'Use COM to create Message and Configuration Objects
set iMsg = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")
'Now Set the field to the configuration objects fields
Set Flds = iConf.Fields
'Set the field namespaces to the relevant variables/constants
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SmtpServer
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
.Update
End With
If Attachment <> "" Then
iMsg.AddAttachment Attachment
End If
' Apply the settings to the message.
With iMsg
Set .Configuration = iConf
.To = Recipient
.From = SenderEmail
.Subject = subject
.HTMLBody = Message
.Send 'Finally Send the message
End With
' Clean up variables.
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
End Function
3 ÀÏÁ¤ ½Ã°£ Áö³ ÆÄÀÏ »èÁ¦Çϱâ
ƯÁ¤ Æú´õ ³»¿¡¼ ÀÏÁ¤ ½Ã°£ÀÌ Áö³ ÆÄÀÏÀ» »èÁ¦ÇÏ´Â ¿¹Á¦´Ù.
Option Explicit
On Error Resume Next
Dim oFSO
Dim sDirectoryPath
Dim oFolder
Dim oFileCollection
Dim oFile
Dim iDaysOld
'Customize values here to fit your needs
iDaysOld = 21
Set oFSO = CreateObject("Scripting.FileSystemObject")
sDirectoryPath = "FolderName here. Can be UNC path like \\MyServer\MyFolder"
set oFolder = oFSO.GetFolder(sDirectoryPath)
set oFileCollection = oFolder.Files
'Walk through each file in this folder collection.
'If it is older than 3 weeks (21) days, then delete it.
For each oFile In oFileCollection
If oFile.DateLastModified < (Date() - iDaysOld) Then
oFile.Delete(True)
End If
Next
'Clean up
Set oFSO = Nothing
Set oFolder = Nothing
Set oFileCollection = Nothing
Set oFile = Nothing
4 ƯÁ¤ ÆÄÀÏ FTP·Î ¾÷·ÎµåÇϱâ
±âº» ftp ÇÁ·Î±×·¥ÀÇ -s ±â´ÉÀ» ÀÌ¿ëÇÑ´Ù. ¾Æ·¡ÀÇ ¿¹Á¦¿¡¼´Â ÆÄÀÏÀÇ À̸§ÀÌ YYYYMMDDData.csv Çü½ÄÀ¸·Î µÇ¾îÀÖ´Ù°í °£ÁÖÇÑ´Ù. ÇØ´ç ÆÄÀÏÀº ½Ã½ºÅÛ ¾îµò°¡¿¡¼ ³¯¸¶´Ù »ý¼ºµÇ´Â ÆÄÀÏÀ̶ó°í »ý°¢ÇÏ¸é µÇ°Ú´Ù.
Option Explicit
Dim objFSO, objMyFile, objShell, strFTPScriptFileName, strFile2Get
Dim strLocalFolderName, strFTPServerName, strLoginID
Dim strPassword, strFTPServerFolder
'Customize code here to fit your needs
strLocalFolderName = "My Folder Name where we put the file to be FTPed"
strFTPServerName = "FTP Server Name"
strLoginID = "FTP Server Login ID"
strPassword = "FTP Login ID Password"
strFTPServerFolder = "Folder Name on FTP server where the file resides"
'The following code converts date to the right format, YYYYMMDD
strFile2Get = DatePart("yyyy",Date)
If DatePart("m",Date) < 10 Then
strFile2Get = strFile2Get & "0"
End If
strFile2Get = strFile2Get & DatePart("m",Date)
If DatePart("d",Date) < 10 Then
strFile2Get = strFile2Get & "0"
End If
strFile2Get = strFile2Get & DatePart("d",Date)
'The following code generates the file name on the FTP server you want to get
strFile2Get = "Data" & strFile2Get & ".csv"
'The follow lines of code generate the FTP script file on the fly,
'because the get file name changes every day
strFTPScriptFileName = strLocalFolderName & "\FTPScript.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If (objFSO.FileExists(strFTPScriptFileName)) Then
objFSO.DeleteFile (strFTPScriptFileName)
End If
Set objMyFile = objFSO.CreateTextFile(strFTPScriptFileName, True)
objMyFile.WriteLine ("open " & strFTPServerName)
objMyFile.WriteLine (strLoginID)
objMyFile.WriteLine (strPassword)
objMyFile.WriteLine ("cd " & strFTPServerFolder)
objMyFile.WriteLine ("ascii")
objMyFile.WriteLine ("lcd " & strLocalFolderName)
objMyFile.WriteLine ("get " & strFile2Get)
objMyFile.WriteLine ("bye")
objMyFile.Close
Set objFSO = Nothing
Set objMyFile = Nothing
'The following code executes the FTP script. It creates a Shell
'object and run FTP program on top of it.
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run ("ftp -s:" & chr(34) & strFTPScriptFileName & chr(34))
Set objShell = Nothing
5 ¼Ò½º ¹é¾÷Çϱâ
ÀÛ¾÷ µð·ºÅ丮(CWD)¿¡ ÁÖÀÇ...
On Error Resume Next
Dim Fso, ExtDic, TempDirDic, Shell
' ÇÊ¿äÇÑ ¿ÀºêÁ§Æ®µé »ý¼º
Set Fso = CreateObject("Scripting.FileSystemObject")
Set ExtDic = CreateObject("Scripting.Dictionary")
Set TempDirDic = CreateObject("Scripting.Dictionary")
Set Shell = CreateObject("WScript.Shell")
' º¯¼ö ÁöÁ¤
DestDirectory = "Anima" ' ÀÌ ºÎºÐ »ó´ë °æ·Î »ç¿ëÁß!
Archiver = """C:\Program Files\WinRar\rar.exe"" a -m5 -r -p -SFX "
BackupFileName = "C:\" & Date() & " Anima.exe"
' »èÁ¦ÇÒ µð·ºÅ丮µéÀ» µî·ÏÇÑ´Ù. (ÀÓ½ÃÀûÀ¸·Î »ý±â´Â ³Ñµé...)
TempDirDic.Add "Anima\Documents\doc\Common", ""
TempDirDic.Add "Anima\Documents\doc\Game"
' »èÁ¦ÇÒ È®ÀåÀÚ¸¦ µî·ÏÇÑ´Ù. ¼Ò¹®ÀÚ¸¸ »ç¿ëÇÒ °Í!
ExtDic.Add "pch", ""
ExtDic.Add "obj", ""
ExtDic.Add "ncb", ""
ExtDic.Add "ilk", ""
ExtDic.Add "pdb", ""
ExtDic.Add "idb", ""
ExtDic.Add "lib", ""
ExtDic.Add "suo", ""
ExtDic.Add "log", ""
ExtDic.Add "tag", ""
ExtDic.Add "pcc", ""
ExtDic.Add "dep", ""
ExtDic.Add "tds", ""
ExtDic.Add "csm", ""
ExtDic.Add "#00", ""
ExtDic.Add "#01", ""
ExtDic.Add "#02", ""
ExtDic.Add "#03", ""
ExtDic.Add "#04", ""
ExtDic.Add "#05", ""
ExtDic.Add "#06", ""
ExtDic.Add "#07", ""
ExtDic.Add "#08", ""
ExtDic.Add "#09", ""
ExtDic.Add "user", ""
ExtDic.Add "manifest", ""
'ExtDic.Add "res", ""
'ExtDic.Add "exe", ""
' ¸ÕÀú ÇÊ¿ä¾ø´Â µð·ºÅ丮¸¦ »èÁ¦ÇÑ ´ÙÀ½, ÇÊ¿ä¾ø´Â ÆÄÀϵéÀ» »èÁ¦ÇÑ´Ù.
directories = TempDirDic.Keys
For i=0 To TempDirDic.Count-1
Fso.DeleteFolder directories(i)
Next
CleanDir DestDirectory, ExtDic
' ÇÊ¿äÇÑ µð·ºÅ丮/ÆÄÀϵéÀ» ¾ÐÃàÇÑ´Ù.
command = Archiver & """" & BackupFileName & """ """ & DestDirectory & """"
Shell.Run command, 1, false
' ÁÖ¾îÁø µð·ºÅ丮¿Í ±× ÇÏÀ§µð·ºÅ丮¸¦ µ¹¸é¼ ƯÁ¤ È®ÀåÀÚ¸¦ °¡Áø ÆÄÀϵéÀ» »èÁ¦ÇÑ´Ù.
Sub CleanDir(path, extDic)
Set folder = Fso.GetFolder(path)
Set files = folder.Files
Set subfolders = folder.SubFolders
For Each file In files
filename = file.Path
extension = GetExtension(file.Name)
If extDic.Exists(extension) Then
Fso.DeleteFile filename
End If
Next
For Each subfolder In subfolders
CleanDir subfolder.Path, extDic
Next
End Sub
' ÆÄÀÏÀÇ È®ÀåÀÚ¸¦ ¹ÝȯÇÑ´Ù.
Function GetExtension(filename)
pos = InStrRev(filename, ".")
If pos <> 0 Then
GetExtension = LCase(Right(filename, Len(filename) - pos))
Else
GetExtension = ""
End If
End Function
6 ½ºÅ©¸³Æ® Ãâ·ÂÀ» Ŭ¸³ º¸µå·Î º¹»çÇϱâ
strCopy = "This text has been copied to the clipboard."
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate("about:blank")
objIE.document.parentwindow.clipboardData.SetData "text", strCopy
objIE.Quit Windows 2000 ¸®¼Ò½ºÅ¶¿¡ clip.exe¶ó´Â ÇÁ·Î±×·¥ÀÌ ÆÄÀÌÇÁ·Î ÀÔ·ÂÀ» ¹Þ¾Æµé¿©, Ŭ¸³º¸µå¿¡´Ù º¹»çÇØÁÖ´Â ±â´ÉÀ» Çß¾ú´Âµ¥, ¿Ö XP ¸®¼Ò½ºÅ¶¿¡¼´Â ¾ø¾îÁø °ÍÀϱî? ¾î·µç clip.exe¸¦ °¡Á®¿À¸é, ¿¡ÄÚ ¹®ÀÚ¿À» ÆÄÀÌÇÁ¸¦ ÅëÇØ¼µµ º¹»çÇÒ ¼ö ÀÖ´Ù.
7 GUI ÇüÅ·Π»ç¿ëÀÚ ÀÔ·Â ¹Þ¾ÆµéÀ̱â
<SCRIPT LANGUAGE="VBScript">
Sub RunScript
If ComputerOption(0).Checked Then
MsgBox "Item 0 Clicked"
End If
If ComputerOption(1).Checked Then
MsgBox "Item 1 Clicked"
End If
If ComputerOption(2).Checked Then
MsgBox "Item 2 Clicked"
End If
If ComputerOption(3).Checked Then
MsgBox "Item 3 Clicked"
End If
Self.Close()
End Sub
Sub CancelScript
Self.Close()
End Sub
</SCRIPT>
<BODY>
<input type="radio" name="ComputerOption" value="atl-ws-01">atl-ws-01<BR>
<input type="radio" name="ComputerOption" value="atl-ws-02">atl-ws-02<BR>
<input type="radio" name="ComputerOption" value="atl-ws-03">atl-ws-03<BR>
<input type="radio" name="ComputerOption" value="atl-ws-04">atl-ws-04<P>
<input id=runbutton class="button" type="button" value="Run Script" name="ok_button"
onClick="RunScript">
<input id=runbutton class="button" type="button" value="Cancel" name="cancel_button"
onClick="CancelScript">
</BODY>
8 »ç¿îµå(WAV) Ç÷¹ÀÌÇϱâ
strSoundFile = "C:\Windows\Media\Notify.wav"
Set objShell = CreateObject("Wscript.Shell")
strCommand = "sndrec32 /play /close " & chr(34) & strSoundFile & chr(34)
objShell.Run strCommand, 0, False
9 TCP ¼º´É µ¥ÀÌÅÍ ¾ò¾î³»±â
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_PerfRawData_Tcpip_TCP",,48)
For Each objItem in colItems
Wscript.Echo "Caption: " & objItem.Caption
Wscript.Echo "ConnectionFailures: " & objItem.ConnectionFailures
Wscript.Echo "ConnectionsActive: " & objItem.ConnectionsActive
Wscript.Echo "ConnectionsEstablished: " & objItem.ConnectionsEstablished
Wscript.Echo "ConnectionsPassive: " & objItem.ConnectionsPassive
Wscript.Echo "ConnectionsReset: " & objItem.ConnectionsReset
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "Frequency_Object: " & objItem.Frequency_Object
Wscript.Echo "Frequency_PerfTime: " & objItem.Frequency_PerfTime
Wscript.Echo "Frequency_Sys100NS: " & objItem.Frequency_Sys100NS
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "SegmentsPersec: " & objItem.SegmentsPersec
Wscript.Echo "SegmentsReceivedPersec: " & objItem.SegmentsReceivedPersec
Wscript.Echo "SegmentsRetransmittedPersec: " & objItem.SegmentsRetransmittedPersec
Wscript.Echo "SegmentsSentPersec: " & objItem.SegmentsSentPersec
Wscript.Echo "Timestamp_Object: " & objItem.Timestamp_Object
Wscript.Echo "Timestamp_PerfTime: " & objItem.Timestamp_PerfTime
Wscript.Echo "Timestamp_Sys100NS: " & objItem.Timestamp_Sys100NS
Next
10 ¿ø°Ý ÄÄÇ»ÅÍ¿¡¼ ÇÁ·Î±×·¥ ½ÇÇàÇϱâ
strComputer = "NameOrIp"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2:Win32_Process")
Error = objWMIService.Create("notepad.exe", null, null, intProcessID)
If Error = 0 Then
Wscript.Echo "Notepad was started with a process ID of " & intProcessID & "."
Else
Wscript.Echo "Notepad could not be started due to error " & Error & "."
End If
11 µµ¸ÞÀÎ ¾È¿¡ ÀÖ´Â ¿©·¯ ´ëÀÇ ÄÄÇ»ÅÍ¿¡¼ ƯÁ¤ ¸í·É ¼öÇàÇϱâ
ExexcuteAll <DomainToTraverse> <ComputerSpecification> <Command> [/Y]
Example:
ExexcuteAll MYDOMAIN WKSATL* "del \\$n\admin$\activitylog.txt"
ExecuteAll.vbs
Option Explicit
Dim oDomain, oService, oItem, oShell
Dim strDomain, strSpec, strCommand, intButton
Dim oArgs, strFinalCommand, oRegEx, boolConfirm
' Prepare to execute commands & do popups
Set oShell = CreateObject("WScript.Shell")
GetArguments
' Access the domain so we can traverse objects
WScript.Echo "Accessing NT Domain " & strDomain
Set oDomain = GetObject("WinNT://" & strDomain)
' Initiate our regular expression support
Set oRegEx = New RegExp
oRegEx.Pattern = strSpec
oRegEx.IgnoreCase = True
' Traverse each computer (WinNT) object in the domain
WScript.Echo "Searching for " & strSpec
oDomain.Filter = Array("Computer") ' only look at computers
For Each oItem In oDomain
If oRegEx.Test(oItem.Name) Then
WScript.Echo " Matched " & oItem.Name
strFinalCommand = Replace(strCommand, "$n", oItem.Name)
intButton = vbNo
If boolConfirm Then
intButton = oShell.Popup("Execute " & strFinalCommand & "?",,_
"System " & oItem.Name, vbYesno + vbQuestion)
End If
If (boolConfirm = False) Or (intButton = vbYes) Then
WScript.Echo " Executing: " & strFinalCommand
execute strFinalCommand
End If
End If
Next
' All done; clean up
Set oItem = Nothing
Set oRegEx = Nothing
Set oDomain = Nothing
Set oShell = Nothing
Set oArgs = Nothing
'
' Get the arguments for our run. Gleam them all from the command line, if provided.
' If any are missing, prompt for the input. A blank input is used to signal an abort.
'
' /Y is an optional last argument
Sub GetArguments
Dim i, strConfirm, intButton
Set oArgs = WScript.Arguments
boolConfirm = True ' assume always confirm
strDomain = "" ' domain to be traversed
strSpec = "" ' name specification to be matched
strCommand = "" ' command to be executed on each match
strConfirm = "" ' track prompting for confirmation setting
' Look for our optional 4th argument
If oArgs.Length = 4 Then
If UCase(oArgs.Item(3)) = "/Y" Then
boolConfirm = False
strConfirm = "/Y" ' don't prompt below
End If
End If
' Look for any specified arguments, in order
If oArgs.Length >= 1 Then strDomain = oArgs(0)
If oArgs.Length >= 2 Then strSpec = oArgs(1)
If oArgs.Length >= 3 Then strCommand = oArgs(2)
' Prompt for any arguments not specified on the command line
If strDomain = "" Then
strDomain = InputBox _
("Enter the name of the NT Domain to be traversed", _
"NT Domain")
End If
If strDomain = "" Then WScript.Quit
strDomain = UCase(strDomain)
If strSpec = "" Then
strSpec = InputBox _
("Enter your name specification for the computer(s) " & _
"that will be matched within the " & strDomain & " Domain." & _
vbCrlf & "Regular Expressions are acceptable.", _
"Name Specification")
End If
If strSpec = "" Then WScript.Quit
If strCommand = "" Then
strCommand = InputBox _
("Enter the command to be executed on each computer matching " & _
strSpec & " within the " & strDomain & " Domain." & _
vbCrlf & "$n will be substituted for the computer name.", _
"Command to Execute")
End If
If strCommand = "" Then WScript.Quit
If strConfirm = "" Then
intButton = oShell.Popup("Confirm each command prior to execution?",,_
"Confirm?", vbYesNo + vbQuestion)
If intButton = vbNo Then
boolConfirm = False
End If
End If
End Sub
' Execute a command. The command is always run under a new instance of the command
' processor. This allows the use of built-in commands and I/O redirection.
'
' We won't wait for command completion.
Sub Execute(strCommand)
Dim RetVal
strCommand = "%COMSPEC% /c " & strCommand
RetVal = oShell.Run(strCommand, 1, False)
End Sub
12 ƯÁ¤ µð·ºÅ丮 ¹× ÇÏÀ§ µð·ºÅ丮¿¡ Á¸ÀçÇÏ´Â ÆÄÀÏ Ãâ·ÂÇϱâ
FileSystemObject¸¦ »ç¿ëÇÏ¸é µÈ´Ù.
On Error Resume Next
Dim FSO
Dim FileDic
Dim DataPath
DataPath = "\\cutieserver\DataBackup\DATA"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set FileDic = CreateObject("Scripting.Dictionary")
GenerateFileDictionary DataPath, FileDic
keys = FileDic.Keys
values = FileDic.Items
For i=0 To FileDic.Count - 1
WScript.Echo keys(i) + "," + values(i)
Next
Sub GenerateFileDictionary(path, dic)
Set folder = FSO.GetFolder(path)
Set files = folder.Files
Set subfolders = folder.SubFolders
For Each file In files
If dic.Exists(file.Name) = false Then
dic.Add file.Name, file.Path
End If
Next
For Each subfolder In subfolders
GenerateFileDictionary subfolder.Path, dic
Next
End Sub
13 µð½ºÅ© Á¶°¢ ¸ðÀ½ ½ÇÇàÇϱâ
C, D µÎ °³ÀÇ µå¶óÀ̺갡 ÀÖ´Â °æ¿ì¸¦ À§ÇÑ ½ºÅ©¸³Æ®´Ù.
On Error Resume Next
Set WshShell = WScript.CreateObject ( "WScript.Shell" )
DefragAppWindowName = "µð½ºÅ© Á¶°¢ ¸ðÀ½"
DefragMsgWindowName = "Á¶°¢ ¸ðÀ½ ¿Ï·á"
' µð½ºÅ© Á¶°¢ ¸ðÀ½À» ½ÇÇàÇÑ´Ù.
WshShell.Run "dfrg.msc"
WScript.Sleep 1000
' ¾ÖÇø®ÄÉÀ̼ÇÀÌ ·ÎµåµÉ ¶§±îÁö ±â´Ù¸°´Ù.
While WshShell.AppActivate(DefragAppWindowName) = FALSE
wscript.sleep 1000
Wend
' µð½ºÅ© Á¶°¢ ¸ðÀ½ âÀ» Ȱ¼ºÈ½ÃŲ´Ù.
WshShell.AppActivate DefragAppWindowName
WScript.Sleep 200
' "µ¿ÀÛ" ¸Þ´º¸¦ Ȱ¼ºÈ½Ã۱â À§ÇØ ALT+A ۸¦ º¸³½´Ù.
WshShell.SendKeys "%A"
WScript.Sleep 200
' "Á¶°¢ ¸ðÀ½" ¸Þ´º¸¦ ½ÇÇàÇϱâ À§ÇØ D ۸¦ º¸³½´Ù.
WshShell.SendKeys "D"
' Á¶°¢ ¸ðÀ½ÀÌ ³¡³¯ ¶§°¡Áö 5Ãʸ¶´Ù Æú¸µÇÏ¸é¼ ±â´Ù¸°´Ù
While WshShell.AppActivate(DefragMsgWindowName) = FALSE
wscript.sleep 5000
Wend
' ¸Þ½ÃÁö ¹Ú½º¸¦ Ȱ¼ºÈ½ÃŲ´Ù.
WshShell.AppActivate DefragMsgWindowName
WScript.Sleep 200
' ´Ý±â ¹öưÀ» Ȱ¼ºÈ½Ã۱â À§ÇØ ÅÇ Å°¸¦ º¸³½´Ù.
WshShell.Sendkeys "{TAB}"
Wscript.Sleep 500
' ¸Þ½ÃÁö ¹Ú½º¸¦ ´Ý´Â´Ù
WshShell.Sendkeys "{ENTER}"
Wscript.Sleep 500
' µð½ºÅ© Á¶°¢ ¸ðÀ½ âÀ» ´Ù½Ã Ȱ¼ºÈ½ÃŲ´Ù.
WshShell.AppActivate DefragAppWindowName
WScript.Sleep 200
' º¼·ý ¸®½ºÆ®·Î Æ÷Ä¿½º¸¦ ¿Å±â±â À§ÇØ ÅÇ Å°¸¦ º¸³½´Ù.
WshShell.Sendkeys "{TAB}"
Wscript.Sleep 500
' D µå¶óÀ̺긦 Ȱ¼ºÈ½Ã۱â À§ÇØ "DOWN" ۸¦ º¸³½´Ù.
WshShell.Sendkeys "{DOWN}"
WScript.Sleep 500
' "µ¿ÀÛ" ¸Þ´º¸¦ Ȱ¼ºÈ½Ã۱â À§ÇØ ALT+A ۸¦ º¸³½´Ù.
WshShell.SendKeys "%A"
WScript.Sleep 200
' "Á¶°¢ ¸ðÀ½" ¸Þ´º¸¦ ½ÇÇàÇϱâ À§ÇØ D ۸¦ º¸³½´Ù.
WshShell.SendKeys "D"
' Á¶°¢ ¸ðÀ½ÀÌ ³¡³¯ ¶§°¡Áö 5Ãʸ¶´Ù Æú¸µÇÏ¸é¼ ±â´Ù¸°´Ù
While WshShell.AppActivate(DefragMsgWindowName) = FALSE
wscript.sleep 5000
Wend
' ¸Þ½ÃÁö ¹Ú½º¸¦ Ȱ¼ºÈ½ÃŲ´Ù.
WshShell.AppActivate DefragMsgWindowName
WScript.Sleep 200
' ´Ý±â ¹öưÀ» Ȱ¼ºÈ½Ã۱â À§ÇØ ÅÇ Å°¸¦ º¸³½´Ù.
WshShell.Sendkeys "{TAB}"
Wscript.Sleep 500
' ¸Þ½ÃÁö ¹Ú½º¸¦ ´Ý´Â´Ù
WshShell.Sendkeys "{ENTER}"
Wscript.Sleep 500
' µð½ºÅ© Á¶°¢ ¸ðÀ½ âÀ» ´Ù½Ã Ȱ¼ºÈ½ÃŲ´Ù.
WshShell.AppActivate DefragAppWindowName
WScript.Sleep 200
' âÀ» ´Ý´Â´Ù.
WshShell.Sendkeys "%{F4}"
' À̺¥Æ® ·Î±×¿¡´Ù ·Î±×¸¦ ³²±ä´Ù.
WshShell.LogEvent 0, "µð½ºÅ© Á¶°¢ ¸ðÀ½ÀÌ ¿Ï·áµÇ¾ú½À´Ï´Ù" ¼Ò½º¸¦ º¸¸é ´ëÃæ ¾Ë ¼ö ÀÖ°ÚÁö¸¸, ¸ÅÅ©·Î ÇÁ·Î±×·¥°ú °°Àº ¹æ½ÄÀ¸·Î 󸮸¦ ÇÑ´Ù. ±×·¯¹Ç·Î µ¿ÀÛ Áß¿¡ ¸¶¿ì½º·Î Æ÷Ä¿½º¸¦ ¿©±âÀú±â ¿Å±ä´Ù´ø°¡ Çϸé Á¦´ë·Î µ¿ÀÛÇÏÁö ¾Ê´Â´Ù. ¾îµð±îÁö³ª »ç¶÷ÀÌ ÄÄÇ»ÅÍ ¾Õ¿¡ ¾É¾ÆÀÖÁö ¾ÊÀ» °æ¿ì¸¦ À§ÇÑ °ÍÀÌ´Ù.
14 ³×Æ®¿öÅ© µå¶óÀÌºê ¸ÅÇÎÇϱâ
Dim net
Set net = CreateObject("WScript.Network")
net.MapNetworkDrive "I:", "\\computer2\public","True" ¸¶Áö¸· ºÒ¸° °ªÀº ÇØ´çÇÏ´Â ³×Æ®¿öÅ© µå¶óÀ̺긦 °è¼Ó À¯ÁöÇÒ °ÍÀΰ¡ÀÇ ¿©ºÎÀÌ´Ù.
15 ´Ù¸¥ ÇÁ·Î±×·¥ ½ÇÇàÇϱâ
WshShell ¿ÀºêÁ§Æ®ÀÇ Run ¸Þ¼µå¸¦ ÀÌ¿ëÇÏ¸é µÈ´Ù.
WshShell.Run(strCommand, [intWindowStyle], [bWaitOnReturn])
- strCommand : ½ÇÇàÇÒ ¸í·É ¹®ÀÚ¿
- intWindowStyle
| intWindowStyle | Description |
| 0 | Hides the window and activates another window. |
| 1 | Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time. |
| 2 | Activates the window and displays it as a minimized window. |
| 3 | Activates the window and displays it as a maximized window. |
| 4 | Displays a window in its most recent size and position. The active window remains active. |
| 5 | Activates the window and displays it in its current size and position. |
| 6 | Minimizes the specified window and activates the next top-level window in the Z order. |
| 7 | Displays the window as a minimized window. The active window remains active. |
| 8 | Displays the window in its current state. The active window remains active. |
| 9 | Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window. |
| 10 | Sets the show-state based on the state of the program that started the application. |
- WaitOnReturn : ½ÇÇàÇÑ ¸í·ÉÀÌ ³¡³¯ ¶§±îÁö ±â´Ù¸®´Â°¡ÀÇ ¿©ºÎ.
»ùÇÃ
Set WshShell = WScript.CreateObject("WScript.Shell")
rvalue = WshShell.Run("notepad " & WScript.ScriptFullName, 1, true) ½ÇÇàÇÑ ÇÁ·Î±×·¥ÀÇ »óŸ¦ °è¼Ó ¸ð´ÏÅ͸µÇÏ¸é¼ ¹º°¡ ÀÛ¾÷Çϱ⸦ ¿øÇÑ´Ù¸é, Exec ¸Þ¼µå¸¦ »ç¿ëÇÏ´Â °ÍÀÌ ÁÁ´Ù. ¾ÈŸ±õ°Ôµµ Ä¿¸Çµå ÇÁ·ÒÇÁÆ® ÇÁ·Î±×·¥¸¸ »ç¿ë °¡´ÉÇÏ´Ù. ÇÏÁö¸¸ ½ºÅÄ´Ùµå ½ºÆ®¸²À» ¾×¼¼½ºÇÒ ¼ö Àֱ⠶§¹®¿¡, Àϰý ÀÛ¾÷¿¡´Â ÀÌÂÊÀÌ ´õ ³´´Ù. ÀÌ¿¡ °üÇÑ »çÇ×Àº
¿©±â¸¦ Âü°í.
WshShell.Exec(strCommand)
»ùÇÃ
Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("calc")
Do While oExec.Status = 0
WScript.Sleep 100
Loop
WScript.Echo oExec.Status
16 ÆÄÀϵéÀÇ ¹öÀü ¾Ë¾Æ³»±â
On Error Resume Next
Dim fso, ext, folder, files, file, ts, filename, version, f, sh, desktop
Set fso = CreateObject("Scripting.FileSystemObject")
Set sh = CreateObject("WScript.Shell")
' %SYSTEM32% Æú´õ ¾ÈÀÇ ÆÄÀÏ ¸ñ·ÏÀ» ¾ò¾î¿Â´Ù.
Set folder = fso.GetSpecialFolder(1)
Set files = folder.files
' µ¥½ºÅ©Å¾ Æú´õÀÇ ÆÐ½º¸¦ ¾ò¾î¿Í Ãâ·Â¿ë ÅØ½ºÆ® ÆÄÀÏÀ» »ý¼ºÇÑ´Ù.
desktop = sh.SpecialFolders("Desktop")
Set ts = fso.CreateTextFile(desktop & "\versions.txt", True)
' ÁøÇàÀ² Ç¥½Ã¸¦ À§ÇØ ÀͽºÇ÷η¯¸¦ ¶ç¿î´Ù
Set objExplorer = WScript.CreateObject _
("InternetExplorer.Application", "IE_")
objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width = 400
objExplorer.Height = 250
objExplorer.Left = 0
objExplorer.Top = 0
objExplorer.Visible = 1
Set objDocument = objExplorer.Document
objDocument.Open
objDocument.Writeln "ÃÑ " & files.Count & " ÆÄÀÏ<BR>"
objDocument.Writeln "°Ë»ç ÁßÀÔ´Ï´Ù.<BR>"
' ÆÄÀϵéÀÇ ¸ñ·ÏÀ» Ⱦ´ÜÇϸé¼,
' È®ÀåÀÚ°¡ DLL ¶Ç´Â OCXÀÎ °æ¿ì, À̸§°ú ÇÔ²² ¹öÀüÀ» ÅØ½ºÆ® ÆÄÀÏ¿¡´Ù ±â·ÏÇÑ´Ù.
for each f in files
file = fso.GetAbsolutePathName(f)
ext = fso.GetExtensionName(file)
if UCase(ext) = "DLL" or UCase(ext) = "OCX" then
version = fso.GetFileVersion(file)
filename = fso.GetFileName(file)
ts.Writeline filename & " " & version
end if
' ÁøÇàÀ² Ç¥½Ã
objDocument.Writeln "*"
next
ts.close
objExplorer.Quit
WScript.Echo "°Ë»ç ¿Ï·á"
Set ts = nothing
Set folder = nothing
Set files = nothing
17 »ç¿ëÀÚ ·Î±×¿Â/·Î±×¿ÀÇÁ ±â·Ï À̺¥Æ® ·Î±×¿¡ ³²±â±â
´ë° ´ÙÀ½°ú °°Àº ½ºÅ©¸³Æ®¸¦ ¸¸µç ´ÙÀ½ ¾îµò°¡¿¡ ÀúÀåÇÑ´Ù.
Set ws = WScript.CreateObject("WScript.Shell")
username = ws.ExpandEnvironmentStrings("%USERNAME%")
ws.LogEvent 0, "User [" & username & "] Logged on " & Date & " " & Time ±× ´ÙÀ½ "MMC -> ±×·ìÁ¤Ã¥ -> »ç¿ëÀÚ ±¸¼º -> Windows ¼³Á¤ -> ½ºÅ©¸³Æ®"¿¡ °¡¼ ½ºÅ©¸³Æ®¸¦ ¼³Á¤ÇÏ¸é µÈ´Ù.
18 ¸¶Áö¸·À¸·Î ·Î±×¿ÂÇÑ »ç¿ëÀÚ ¾Ë¾Æ³»±â
Set LoginProfiles = GetObject("winmgmts:").InstancesOf ("Win32_NetworkLoginProfile")
For Each Profile In LoginProfiles
WScript.Echo Profile.Name
WScript.Echo Profile.LastLogon
Next
19 ¿©·¯ ÄÄÇ»ÅÍ¿¡ ÀÖ´Â À̺¥Æ® ·Î±× ¸ðÀ¸±â
20 ¿©·¯ ÄÄÇ»ÅÍÀÇ ÆäÀÌÁöÆÄÀÏ Å©±â ¹Ù²Ù±â
SeriousMoin v1 (koMoinMoin 1.0a4 Modified)