SlideShare a Scribd company logo
Sub Wscript1()
' Execute program and
' Read the output into a variable line by line
Dim sKillExcel As String
sKillExcel = "TASKKILL /F /IM plink.exe"
Shell sKillExcel, vbHide
Exit Sub
Dim ObjExec
Dim strFromProc
Set objShell = WScript.CreateObject("WScript.Shell")
Set ObjExec = objShell.Exec("cmd.exe /c dir")
Do
strFromProc = ObjExec.StdOut.ReadLine()
WScript.Echo "Output is: " & strFromProc
Loop While Not ObjExec.StdOut.AtEndOfStream
End Sub
Sub Wscript2()
'Function vFn_Sys_Run_CommandOutput(Command, Wait, Show, OutToFile,
DeleteOutput, NoQuotes)
'Run Command similar to the command prompt, for Wait use 1 or 0. Output returned
and
'stored in a file.
'Command = The command line instruction you wish to run.
'Wait = 1/0; 1 will wait for the command to finish before continuing.
'Show = 1/0; 1 will show for the command window.
'OutToFile = The file you wish to have the output recorded to.
'DeleteOutput = 1/0; 1 deletes the output file. Output is still returned to
variable.
'NoQuotes = 1/0; 1 will skip wrapping the command with quotes, some commands
wont work
' if you wrap them in quotes.
'-------------------------------------------------------------------------------
---------
On Error Resume Next
'On Error Goto 0
Set f_objShell = CreateObject("Wscript.Shell")
Set f_objFso = CreateObject("Scripting.FileSystemObject")
Const ForReading = 1, ForWriting = 2, ForAppending = 8
'VARIABLES
If OutToFile = "" Then OutToFile = "TEMP.TXT"
tCommand = Command
If Left(Command, 1) <> """" And NoQuotes <> 1 Then tCommand = """" &
Command & """"
tOutToFile = OutToFile
If Left(OutToFile, 1) <> """" Then tOutToFile = """" & OutToFile & """"
If Wait = 1 Then tWait = True
If Wait <> 1 Then tWait = False
If Show = 1 Then tShow = 1
If Show <> 1 Then tShow = 0
'RUN PROGRAM
f_objShell.Run tCommand & ">" & tOutToFile, tShow, tWait
'READ OUTPUT FOR RETURN
Set f_objFile = f_objFso.OpenTextFile(OutToFile, 1)
tMyOutput = f_objFile.ReadAll
f_objFile.Close
Set f_objFile = Nothing
'DELETE FILE AND FINISH FUNCTION
If DeleteOutput = 1 Then
Set f_objFile = f_objFso.GetFile(OutToFile)
f_objFile.Delete
Set f_objFile = Nothing
End If
vFn_Sys_Run_CommandOutput = tMyOutput
If Err.number <> 0 Then vFn_Sys_Run_CommandOutput = "<0>"
Err.Clear
On Error GoTo 0
Set f_objFile = Nothing
Set f_objShell = Nothing
End Function
End Sub
Sub Laughable()
WScript.Echo execStdOut("ping google.com")
End Sub
Function execStdOut(cmd)
Dim goWSH: Set goWSH = CreateObject("WScript.Shell")
Dim aRet: Set aRet = goWSH.Exec(cmd)
execStdOut = aRet.StdOut.ReadAll()
End Function
Sub MemE()
Const WshFinished = 1
Const WshFailed = 2
strCommand = "ping.exe 127.0.0.1"
Set WshShell = CreateObject("WScript.Shell")
Set WshShellExec = WshShell.Exec(strCommand)
Select Case WshShellExec.status
Case WshFinished
strOutput = WshShellExec.StdOut.ReadAll
Case WshFailed
strOutput = WshShellExec.StdErr.ReadAll
End Select
MsgBox strOutput
Exit Sub
WScript.StdOut.Write strOutput 'write results to the command line
WScript.Echo strOutput 'write results to default output
MsgBox strOutput
End Sub
Sub lolo()
Dim myCommand
Set myCommand = CreateObject("WScript.Shell")
myCommand.Run "%comspec% /c dir >
C:UsersJthomps182Documentsdts_history_2.log"
End Sub
Sub Cheap()
Set objShell = CreateObject("WScript.Shell")
strErrorCode = objShell.Run ipconfig,0,True
WScript.Echo strErrorCode
Set objShell = CreateObject("WScript.Shell")
Set ObjExec = objShell.Exec("explorer.exe")
Set objShell = CreateObject("WScript.Shell")
comspec = objShell.ExpandEnvironmentStrings("%comspec%")
' ////////////////////////////////////////////////////////
Set ObjExec = objShell.Exec(comspec & " /c ipconfig")
Do
WScript.StdOut.WriteLine (ObjExec.StdOut.ReadLine())
Loop While Not ObjExec.StdOut.AtEndOfStream
WScript.StdOut.WriteLine (ObjExec.StdOut.ReadAll)
End Sub
Sub Shell2()
Function runCMD(strRunCmd)
Set objShell = WScript.CreateObject("WScript.Shell")
Set ObjExec = objShell.Exec(strRunCmd)
strOut = ""
Do While Not ObjExec.StdOut.AtEndOfStream
strOut = strOut & ObjExec.StdOut.ReadLine()
Loop
Set objShell = Nothing
Set ObjExec = Nothing
runCMD = strOut
End Function
Sub sheshe()
WScript.Echo runCMD("ping -t http:www.google/com")
'Function runCMD(strRunCmd)
Set objShell = WScript.CreateObject("WScript.Shell")
Set ObjExec = objShell.Exec(strRunCmd)
strOut = ""
Do While Not ObjExec.StdOut.AtEndOfStream
strOut = strOut & ObjExec.StdOut.ReadLine()
Loop
Set objShell = Nothing
Set ObjExec = Nothing
strOut = "ping -t http:www.google/com"
runCMD = strOut
MsgBox strOut
End Function

More Related Content

What's hot

Flowchart - Building next gen malware behavioural analysis environment
Flowchart - Building next gen malware behavioural analysis environment Flowchart - Building next gen malware behavioural analysis environment
Flowchart - Building next gen malware behavioural analysis environment
isc2-hellenic
 
lec4.docx
lec4.docxlec4.docx
lec4.docx
ismailaboshatra
 
Unit test
Unit testUnit test
Unit test
David Xie
 
ZF3 introduction
ZF3 introductionZF3 introduction
ZF3 introduction
Vincent Blanchon
 
Metasploit cheat sheet
Metasploit cheat sheetMetasploit cheat sheet
Metasploit cheat sheet
hughpearse
 
Source Code
Source CodeSource Code
Source Code
vijaykantsaini
 
Hacking Mac OSX Cocoa API from Perl
Hacking Mac OSX Cocoa API from PerlHacking Mac OSX Cocoa API from Perl
Hacking Mac OSX Cocoa API from Perl
typester
 
Juju - Google Go in a scalable Environment
Juju - Google Go in a scalable EnvironmentJuju - Google Go in a scalable Environment
Juju - Google Go in a scalable Environment
Frank Müller
 
Linux Awk cheat sheet and examples infographics
Linux Awk cheat sheet and examples infographicsLinux Awk cheat sheet and examples infographics
Linux Awk cheat sheet and examples infographics
abhiphull
 
Jakub Kulhán - ReactPHP + Symfony = PROFIT (1. sraz přátel Symfony v Praze)
Jakub Kulhán - ReactPHP + Symfony = PROFIT (1. sraz přátel Symfony v Praze)Jakub Kulhán - ReactPHP + Symfony = PROFIT (1. sraz přátel Symfony v Praze)
Jakub Kulhán - ReactPHP + Symfony = PROFIT (1. sraz přátel Symfony v Praze)
Péhápkaři
 
The Ring programming language version 1.10 book - Part 28 of 212
The Ring programming language version 1.10 book - Part 28 of 212The Ring programming language version 1.10 book - Part 28 of 212
The Ring programming language version 1.10 book - Part 28 of 212
Mahmoud Samir Fayed
 
Meet up symfony 16 juin 2017 - Les PSR
Meet up symfony 16 juin 2017 -  Les PSRMeet up symfony 16 juin 2017 -  Les PSR
Meet up symfony 16 juin 2017 - Les PSR
Julien Vinber
 
EasyMock 101
EasyMock 101EasyMock 101
EasyMock 101
Matthew McCullough
 
Loss Monitor
Loss MonitorLoss Monitor
Loss Monitor
Jean Pimentel
 
tarea 2 parcial robotica .pdf
tarea 2 parcial robotica .pdftarea 2 parcial robotica .pdf
tarea 2 parcial robotica .pdf
luisgabielnavarro
 
Example esb flow
Example esb flowExample esb flow
Example esb flow
Antonio Pellegrino
 
ES6 generators
ES6 generatorsES6 generators
ES6 generators
Steven Foote
 
Oracle RDBMS Workshop (Part1)
Oracle RDBMS Workshop (Part1)Oracle RDBMS Workshop (Part1)
Oracle RDBMS Workshop (Part1)
Taras Lyuklyanchuk
 
Introdução a worker 2.0
Introdução a worker 2.0Introdução a worker 2.0
Introdução a worker 2.0
Sérgio Rafael Siqueira
 
Javascript ES6 generators
Javascript ES6 generatorsJavascript ES6 generators
Javascript ES6 generators
Ramesh Nair
 

What's hot (20)

Flowchart - Building next gen malware behavioural analysis environment
Flowchart - Building next gen malware behavioural analysis environment Flowchart - Building next gen malware behavioural analysis environment
Flowchart - Building next gen malware behavioural analysis environment
 
lec4.docx
lec4.docxlec4.docx
lec4.docx
 
Unit test
Unit testUnit test
Unit test
 
ZF3 introduction
ZF3 introductionZF3 introduction
ZF3 introduction
 
Metasploit cheat sheet
Metasploit cheat sheetMetasploit cheat sheet
Metasploit cheat sheet
 
Source Code
Source CodeSource Code
Source Code
 
Hacking Mac OSX Cocoa API from Perl
Hacking Mac OSX Cocoa API from PerlHacking Mac OSX Cocoa API from Perl
Hacking Mac OSX Cocoa API from Perl
 
Juju - Google Go in a scalable Environment
Juju - Google Go in a scalable EnvironmentJuju - Google Go in a scalable Environment
Juju - Google Go in a scalable Environment
 
Linux Awk cheat sheet and examples infographics
Linux Awk cheat sheet and examples infographicsLinux Awk cheat sheet and examples infographics
Linux Awk cheat sheet and examples infographics
 
Jakub Kulhán - ReactPHP + Symfony = PROFIT (1. sraz přátel Symfony v Praze)
Jakub Kulhán - ReactPHP + Symfony = PROFIT (1. sraz přátel Symfony v Praze)Jakub Kulhán - ReactPHP + Symfony = PROFIT (1. sraz přátel Symfony v Praze)
Jakub Kulhán - ReactPHP + Symfony = PROFIT (1. sraz přátel Symfony v Praze)
 
The Ring programming language version 1.10 book - Part 28 of 212
The Ring programming language version 1.10 book - Part 28 of 212The Ring programming language version 1.10 book - Part 28 of 212
The Ring programming language version 1.10 book - Part 28 of 212
 
Meet up symfony 16 juin 2017 - Les PSR
Meet up symfony 16 juin 2017 -  Les PSRMeet up symfony 16 juin 2017 -  Les PSR
Meet up symfony 16 juin 2017 - Les PSR
 
EasyMock 101
EasyMock 101EasyMock 101
EasyMock 101
 
Loss Monitor
Loss MonitorLoss Monitor
Loss Monitor
 
tarea 2 parcial robotica .pdf
tarea 2 parcial robotica .pdftarea 2 parcial robotica .pdf
tarea 2 parcial robotica .pdf
 
Example esb flow
Example esb flowExample esb flow
Example esb flow
 
ES6 generators
ES6 generatorsES6 generators
ES6 generators
 
Oracle RDBMS Workshop (Part1)
Oracle RDBMS Workshop (Part1)Oracle RDBMS Workshop (Part1)
Oracle RDBMS Workshop (Part1)
 
Introdução a worker 2.0
Introdução a worker 2.0Introdução a worker 2.0
Introdução a worker 2.0
 
Javascript ES6 generators
Javascript ES6 generatorsJavascript ES6 generators
Javascript ES6 generators
 

Similar to Wscript

soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coinsoft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch
 
Java 7 JUG Summer Camp
Java 7 JUG Summer CampJava 7 JUG Summer Camp
Java 7 JUG Summer Camp
julien.ponge
 
JAVA SE 7
JAVA SE 7JAVA SE 7
JAVA SE 7
Sajid Mehmood
 
Java 7 at SoftShake 2011
Java 7 at SoftShake 2011Java 7 at SoftShake 2011
Java 7 at SoftShake 2011
julien.ponge
 
Java 7 LavaJUG
Java 7 LavaJUGJava 7 LavaJUG
Java 7 LavaJUG
julien.ponge
 
Error and exception in python
Error and exception in pythonError and exception in python
Error and exception in python
junnubabu
 
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
julien.ponge
 
The Ring programming language version 1.7 book - Part 30 of 196
The Ring programming language version 1.7 book - Part 30 of 196The Ring programming language version 1.7 book - Part 30 of 196
The Ring programming language version 1.7 book - Part 30 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 88 of 202
The Ring programming language version 1.8 book - Part 88 of 202The Ring programming language version 1.8 book - Part 88 of 202
The Ring programming language version 1.8 book - Part 88 of 202
Mahmoud Samir Fayed
 
Aprenda Elixir em um final de semana
Aprenda Elixir em um final de semanaAprenda Elixir em um final de semana
Aprenda Elixir em um final de semana
Marcos Brizeno
 
C++ course start
C++ course startC++ course start
C++ course start
Net3lem
 
File & Exception Handling in C++.pptx
File & Exception Handling in C++.pptxFile & Exception Handling in C++.pptx
File & Exception Handling in C++.pptx
RutujaTandalwade
 
The Ring programming language version 1.6 book - Part 29 of 189
The Ring programming language version 1.6 book - Part 29 of 189The Ring programming language version 1.6 book - Part 29 of 189
The Ring programming language version 1.6 book - Part 29 of 189
Mahmoud Samir Fayed
 
Linux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using PipesLinux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using Pipes
RashidFaridChishti
 
35787646 system-software-lab-manual
35787646 system-software-lab-manual35787646 system-software-lab-manual
35787646 system-software-lab-manual
Naveen Kumar
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
ChaAstillas
 
Function C++
Function C++ Function C++
Function C++
Shahzad Afridi
 
C++ loop
C++ loop C++ loop
C++ loop
Khelan Ameen
 
The Ring programming language version 1.8 book - Part 9 of 202
The Ring programming language version 1.8 book - Part 9 of 202The Ring programming language version 1.8 book - Part 9 of 202
The Ring programming language version 1.8 book - Part 9 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 25 of 181
The Ring programming language version 1.5.2 book - Part 25 of 181The Ring programming language version 1.5.2 book - Part 25 of 181
The Ring programming language version 1.5.2 book - Part 25 of 181
Mahmoud Samir Fayed
 

Similar to Wscript (20)

soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coinsoft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
 
Java 7 JUG Summer Camp
Java 7 JUG Summer CampJava 7 JUG Summer Camp
Java 7 JUG Summer Camp
 
JAVA SE 7
JAVA SE 7JAVA SE 7
JAVA SE 7
 
Java 7 at SoftShake 2011
Java 7 at SoftShake 2011Java 7 at SoftShake 2011
Java 7 at SoftShake 2011
 
Java 7 LavaJUG
Java 7 LavaJUGJava 7 LavaJUG
Java 7 LavaJUG
 
Error and exception in python
Error and exception in pythonError and exception in python
Error and exception in python
 
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
 
The Ring programming language version 1.7 book - Part 30 of 196
The Ring programming language version 1.7 book - Part 30 of 196The Ring programming language version 1.7 book - Part 30 of 196
The Ring programming language version 1.7 book - Part 30 of 196
 
The Ring programming language version 1.8 book - Part 88 of 202
The Ring programming language version 1.8 book - Part 88 of 202The Ring programming language version 1.8 book - Part 88 of 202
The Ring programming language version 1.8 book - Part 88 of 202
 
Aprenda Elixir em um final de semana
Aprenda Elixir em um final de semanaAprenda Elixir em um final de semana
Aprenda Elixir em um final de semana
 
C++ course start
C++ course startC++ course start
C++ course start
 
File & Exception Handling in C++.pptx
File & Exception Handling in C++.pptxFile & Exception Handling in C++.pptx
File & Exception Handling in C++.pptx
 
The Ring programming language version 1.6 book - Part 29 of 189
The Ring programming language version 1.6 book - Part 29 of 189The Ring programming language version 1.6 book - Part 29 of 189
The Ring programming language version 1.6 book - Part 29 of 189
 
Linux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using PipesLinux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using Pipes
 
35787646 system-software-lab-manual
35787646 system-software-lab-manual35787646 system-software-lab-manual
35787646 system-software-lab-manual
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
 
Function C++
Function C++ Function C++
Function C++
 
C++ loop
C++ loop C++ loop
C++ loop
 
The Ring programming language version 1.8 book - Part 9 of 202
The Ring programming language version 1.8 book - Part 9 of 202The Ring programming language version 1.8 book - Part 9 of 202
The Ring programming language version 1.8 book - Part 9 of 202
 
The Ring programming language version 1.5.2 book - Part 25 of 181
The Ring programming language version 1.5.2 book - Part 25 of 181The Ring programming language version 1.5.2 book - Part 25 of 181
The Ring programming language version 1.5.2 book - Part 25 of 181
 

Recently uploaded

Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
abbyasa1014
 
Transformers design and coooling methods
Transformers design and coooling methodsTransformers design and coooling methods
Transformers design and coooling methods
Roger Rozario
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
co23btech11018
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
gray level transformation unit 3(image processing))
gray level transformation unit 3(image processing))gray level transformation unit 3(image processing))
gray level transformation unit 3(image processing))
shivani5543
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
Dr Ramhari Poudyal
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
gerogepatton
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
NATURAL DEEP EUTECTIC SOLVENTS AS ANTI-FREEZING AGENT
NATURAL DEEP EUTECTIC SOLVENTS AS ANTI-FREEZING AGENTNATURAL DEEP EUTECTIC SOLVENTS AS ANTI-FREEZING AGENT
NATURAL DEEP EUTECTIC SOLVENTS AS ANTI-FREEZING AGENT
Addu25809
 
Introduction to AI Safety (public presentation).pptx
Introduction to AI Safety (public presentation).pptxIntroduction to AI Safety (public presentation).pptx
Introduction to AI Safety (public presentation).pptx
MiscAnnoy1
 
Hematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood CountHematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood Count
shahdabdulbaset
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
171ticu
 
International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
gerogepatton
 
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...
amsjournal
 

Recently uploaded (20)

Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
 
Transformers design and coooling methods
Transformers design and coooling methodsTransformers design and coooling methods
Transformers design and coooling methods
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
gray level transformation unit 3(image processing))
gray level transformation unit 3(image processing))gray level transformation unit 3(image processing))
gray level transformation unit 3(image processing))
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
NATURAL DEEP EUTECTIC SOLVENTS AS ANTI-FREEZING AGENT
NATURAL DEEP EUTECTIC SOLVENTS AS ANTI-FREEZING AGENTNATURAL DEEP EUTECTIC SOLVENTS AS ANTI-FREEZING AGENT
NATURAL DEEP EUTECTIC SOLVENTS AS ANTI-FREEZING AGENT
 
Introduction to AI Safety (public presentation).pptx
Introduction to AI Safety (public presentation).pptxIntroduction to AI Safety (public presentation).pptx
Introduction to AI Safety (public presentation).pptx
 
Hematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood CountHematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood Count
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
 
International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
 
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...
 

Wscript

  • 1. Sub Wscript1() ' Execute program and ' Read the output into a variable line by line Dim sKillExcel As String sKillExcel = "TASKKILL /F /IM plink.exe" Shell sKillExcel, vbHide Exit Sub Dim ObjExec Dim strFromProc Set objShell = WScript.CreateObject("WScript.Shell") Set ObjExec = objShell.Exec("cmd.exe /c dir") Do strFromProc = ObjExec.StdOut.ReadLine() WScript.Echo "Output is: " & strFromProc Loop While Not ObjExec.StdOut.AtEndOfStream End Sub Sub Wscript2() 'Function vFn_Sys_Run_CommandOutput(Command, Wait, Show, OutToFile, DeleteOutput, NoQuotes) 'Run Command similar to the command prompt, for Wait use 1 or 0. Output returned and 'stored in a file. 'Command = The command line instruction you wish to run. 'Wait = 1/0; 1 will wait for the command to finish before continuing. 'Show = 1/0; 1 will show for the command window. 'OutToFile = The file you wish to have the output recorded to. 'DeleteOutput = 1/0; 1 deletes the output file. Output is still returned to variable. 'NoQuotes = 1/0; 1 will skip wrapping the command with quotes, some commands wont work ' if you wrap them in quotes. '------------------------------------------------------------------------------- --------- On Error Resume Next 'On Error Goto 0 Set f_objShell = CreateObject("Wscript.Shell") Set f_objFso = CreateObject("Scripting.FileSystemObject") Const ForReading = 1, ForWriting = 2, ForAppending = 8 'VARIABLES If OutToFile = "" Then OutToFile = "TEMP.TXT" tCommand = Command If Left(Command, 1) <> """" And NoQuotes <> 1 Then tCommand = """" & Command & """" tOutToFile = OutToFile If Left(OutToFile, 1) <> """" Then tOutToFile = """" & OutToFile & """" If Wait = 1 Then tWait = True If Wait <> 1 Then tWait = False If Show = 1 Then tShow = 1 If Show <> 1 Then tShow = 0 'RUN PROGRAM f_objShell.Run tCommand & ">" & tOutToFile, tShow, tWait 'READ OUTPUT FOR RETURN Set f_objFile = f_objFso.OpenTextFile(OutToFile, 1) tMyOutput = f_objFile.ReadAll f_objFile.Close
  • 2. Set f_objFile = Nothing 'DELETE FILE AND FINISH FUNCTION If DeleteOutput = 1 Then Set f_objFile = f_objFso.GetFile(OutToFile) f_objFile.Delete Set f_objFile = Nothing End If vFn_Sys_Run_CommandOutput = tMyOutput If Err.number <> 0 Then vFn_Sys_Run_CommandOutput = "<0>" Err.Clear On Error GoTo 0 Set f_objFile = Nothing Set f_objShell = Nothing End Function End Sub Sub Laughable() WScript.Echo execStdOut("ping google.com") End Sub Function execStdOut(cmd) Dim goWSH: Set goWSH = CreateObject("WScript.Shell") Dim aRet: Set aRet = goWSH.Exec(cmd) execStdOut = aRet.StdOut.ReadAll() End Function Sub MemE() Const WshFinished = 1 Const WshFailed = 2 strCommand = "ping.exe 127.0.0.1" Set WshShell = CreateObject("WScript.Shell") Set WshShellExec = WshShell.Exec(strCommand) Select Case WshShellExec.status Case WshFinished strOutput = WshShellExec.StdOut.ReadAll Case WshFailed strOutput = WshShellExec.StdErr.ReadAll End Select MsgBox strOutput Exit Sub WScript.StdOut.Write strOutput 'write results to the command line WScript.Echo strOutput 'write results to default output MsgBox strOutput End Sub Sub lolo() Dim myCommand Set myCommand = CreateObject("WScript.Shell") myCommand.Run "%comspec% /c dir > C:UsersJthomps182Documentsdts_history_2.log" End Sub Sub Cheap() Set objShell = CreateObject("WScript.Shell") strErrorCode = objShell.Run ipconfig,0,True WScript.Echo strErrorCode Set objShell = CreateObject("WScript.Shell") Set ObjExec = objShell.Exec("explorer.exe")
  • 3. Set objShell = CreateObject("WScript.Shell") comspec = objShell.ExpandEnvironmentStrings("%comspec%") ' //////////////////////////////////////////////////////// Set ObjExec = objShell.Exec(comspec & " /c ipconfig") Do WScript.StdOut.WriteLine (ObjExec.StdOut.ReadLine()) Loop While Not ObjExec.StdOut.AtEndOfStream WScript.StdOut.WriteLine (ObjExec.StdOut.ReadAll) End Sub Sub Shell2() Function runCMD(strRunCmd) Set objShell = WScript.CreateObject("WScript.Shell") Set ObjExec = objShell.Exec(strRunCmd) strOut = "" Do While Not ObjExec.StdOut.AtEndOfStream strOut = strOut & ObjExec.StdOut.ReadLine() Loop Set objShell = Nothing Set ObjExec = Nothing runCMD = strOut End Function Sub sheshe() WScript.Echo runCMD("ping -t http:www.google/com") 'Function runCMD(strRunCmd) Set objShell = WScript.CreateObject("WScript.Shell") Set ObjExec = objShell.Exec(strRunCmd) strOut = "" Do While Not ObjExec.StdOut.AtEndOfStream strOut = strOut & ObjExec.StdOut.ReadLine() Loop Set objShell = Nothing Set ObjExec = Nothing strOut = "ping -t http:www.google/com" runCMD = strOut MsgBox strOut End Function