반응형

vb스크립트에서 cmd를 사용한 간단한 동작

참고로 주석은 ' 이나 : REM 으로 시작하면된다.

 

 ' 파일지우기 Set WshShell = WScript.CreateObject("WScript.Shell") return = WshShell.Run ("cmd /c del /q /s c:\test\test.txt",0 ,true) 

 

 

 

Dim oShell

 

Set oShell = WScript.CreateObject ("WSCript.shell")

 

If WScript.Arguments.length =0 Then

  Set objShell = CreateObject("Shell.Application")

  'Pass a bogus argument with leading blank space, say [ uac]

  objShell.ShellExecute "wscript.exe", Chr(34) & WScript.ScriptFullName & Chr(34) & " uac", "", "runas", 1

Else

  oShell.Run "install.vbs"

End If

 

 

 

 

 

 

 

' If WScript.Arguments.length =0 Then

'  Set objShell = CreateObject("Shell.Application")

'  'Pass a bogus argument with leading blank space, say [ uac]

'  objShell.ShellExecute "wscript.exe", Chr(34) & _

'  WScript.ScriptFullName & Chr(34) & " uac", "", "runas", 1

'Else

 'Add your code here

 Set oShell = WScript.CreateObject("WScript.Shell")

 

'copy required file'

Return = oShell.Run("cmd /c xcopy c:\test.txt %windir%\system32",0,true)

 

 

 

'install pcscan'

'Return = oShell.Run("cmd /c c:\comtrue\pcscan\extra\ctrinst.exe pcscan", 0, true)

 

'self delete'

'Set oFso = CreateObject("Scripting.FileSystemObject") : oFso.DeleteFile Wscript.ScriptFullName, True

'End If 

 

 

 

 

 

Dim oShell

 

Set oShell = WScript.CreateObject ("WSCript.shell")

 

If WScript.Arguments.length =0 Then

  Set objShell = CreateObject("Shell.Application")

  'Pass a bogus argument with leading blank space, say [ uac]

  objShell.ShellExecute "wscript.exe", Chr(34) & WScript.ScriptFullName & Chr(34) & " uac", "", "runas", 1

Else

  oShell.Run "install.vbs"

End If

 

 

 

 

 

 

 

' If WScript.Arguments.length =0 Then

'  Set objShell = CreateObject("Shell.Application")

'  'Pass a bogus argument with leading blank space, say [ uac]

'  objShell.ShellExecute "wscript.exe", Chr(34) & _

'  WScript.ScriptFullName & Chr(34) & " uac", "", "runas", 1

'Else

 'Add your code here

 Set oShell = WScript.CreateObject("WScript.Shell")

 

'copy required file'

Return = oShell.Run("cmd /c xcopy c:\test.txt %windir%\system32",0,true)

 

 

 

'install pcscan'

'Return = oShell.Run("cmd /c c:\comtrue\pcscan\extra\ctrinst.exe pcscan", 0, true)

 

'self delete'

'Set oFso = CreateObject("Scripting.FileSystemObject") : oFso.DeleteFile Wscript.ScriptFullName, True

'End If 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

파일생성 batch

 

@echo off

SET foo = "test"

for /l %%x in (1, 1, 10) do (

   echo %%x

   echo test > %%x.txt

)

 

 

 

 

 

반응형

+ Recent posts