logo
down
shadow

How to run a file on background using vbscript with launch options


How to run a file on background using vbscript with launch options

By : Guy
Date : November 17 2020, 04:28 AM
I wish did fix the issue. Use a function to quote strings, and - optionally - a sub to map all elements of an array via a manipulator function to build command lines in a structured/well scaling way; use Join() to put the parts together (with automagical space separator):
code :
Option Explicit

Function qq(s) : qq = """" & s & """" : End Function

Sub mapF(a, f)
  Dim i
  For i = LBound(a) To UBound(a)
      a(i) = f(a(i))
  Next
End Sub

Dim sFSpec : sFSpec = "C:\Program Files\Pineapplesoft\Lost computer\lostcomputeraudio.bat"
Dim aParms : aParms = Split("1#/pi:pa po#last parm", "#")
mapF aParms, GetRef("qq")

Dim sCmd : sCmd = Join(Array( _
    qq(sFSpec) _
  , Join(aParms) _
))

WScript.Echo qq(sCmd)
cscript startaudio.vbs
""C:\Program Files\Pineapplesoft\Lost computer\lostcomputeraudio.bat" "1" "/pi:pap po" "last parm""


Share : facebook icon twitter icon
How to unzip a file in VBScript using internal Windows XP options in

How to unzip a file in VBScript using internal Windows XP options in


By : user1075274
Date : March 29 2020, 07:55 AM
This might help you Just set ZipFile = The location of the zip file, and ExtractTo = to the location the zip file should be extracted to.
code :
'The location of the zip file.
ZipFile="C:\Test.Zip"
'The folder the contents should be extracted to.
ExtractTo="C:\Test\"

'If the extraction location does not exist create it.
Set fso = CreateObject("Scripting.FileSystemObject")
If NOT fso.FolderExists(ExtractTo) Then
   fso.CreateFolder(ExtractTo)
End If

'Extract the contants of the zip file.
set objShell = CreateObject("Shell.Application")
set FilesInZip=objShell.NameSpace(ZipFile).items
objShell.NameSpace(ExtractTo).CopyHere(FilesInZip)
Set fso = Nothing
Set objShell = Nothing
How can I run a VBScript file silently in the background?

How can I run a VBScript file silently in the background?


By : Dinesh Dora
Date : March 29 2020, 07:55 AM
wish help you to fix your issue I want to run a VBScript file silently, because it is just a part of a hidden script. , I would use a workaround in both cases.
For example:
code :
. . .
'session.findById("wnd[0]").resizeWorkingPane 132,31,false
session.findById("wnd[0]").iconify
. . .
. . .
'objExcel.Visible = false     
objExcel.WindowState = 2
. . .
unable to launch a program with different options from a .bat file

unable to launch a program with different options from a .bat file


By : forumuser
Date : March 29 2020, 07:55 AM
Hope that helps what program is the program?
do you happen to know any of the variables to launch the program with? usually when you open them in a batch you put the other variables after it such as -t -cd -s43 or something like that. also the program doesnt do it itself or does it only run different reports when you configure it with the arguments?
code :
SET /P _INPUTNAME= Please input:
IF "%_INPUTNAME%"=="1" GOTO :Report1D
IF "%_INPUTNAME%"=="2" GOTO :Report2D
:Report1D
::::::::::::::::::::::::::::::::::::::
:: Selection Menu, Self explanitory ::
:: Each GOTO a specific tag in code ::
::::::::::::::::::::::::::::::::::::::

:Selection
CLS
COLOR 7C
ECHO.
ECHO        Deletion menu.
ECHO    Choose a selection Option:
ECHO.
ECHO   REGULAR USER COMMANDS:
ECHO.
ECHO   V:\ Drive BAK / ERR Files         : 1
ECHO   Y:\ Drive wip/master BAK Files    : 2
ECHO   Y:\ Drive wip/master ERR Files    : 3
ECHO   Y:\ + V:\ .LOG File Removal       : 4
ECHO   Y:\ TMP/BAD/CSV/HTML File Removal : 5
ECHO.
ECHO   To Exit This Program            : Quit
ECHO.
ECHO      ADMINISTRATORS ONLY COMMANDS:
ECHO.
ECHO   Y:\ Drive ALL BAK/ERR FILES     : Admin
ECHO.

SET /P _INPUTNAME= Please input:
IF "%_INPUTNAME%"=="1" GOTO :DelV_BNE
IF "%_INPUTNAME%"=="2" GOTO :DelY_bak
IF "%_INPUTNAME%"=="3" GOTO :DelY_err
IF "%_INPUTNAME%"=="4" GOTO :Del_log
IF "%_INPUTNAME%"=="5" GOTO :Del_misc
IF "%_INPUTNAME%"=="Q" GOTO :QUIT
IF "%_INPUTNAME%"=="q" GOTO :QUIT
IF "%_INPUTNAME%"=="quit" GOTO :QUIT
IF "%_INPUTNAME%"=="Quit" GOTO :QUIT
IF "%_INPUTNAME%"=="QUIT" GOTO :QUIT
IF "%_INPUTNAME%"=="Admin" GOTO :ADMIN
IF "%_INPUTNAME%"=="ADMIN" GOTO :ADMIN
IF "%_INPUTNAME%"=="admin" GOTO :ADMIN
IF "%_INPUTNAME%"=="a" GOTO :ADMIN
IF "%_INPUTNAME%"=="A" GOTO :ADMIN

CLS

::::::::::::::::::::::::::::::
::   ERROR CODE for MENU    ::
::::::::::::::::::::::::::::::

:END_OF_LINE
CLS
COLOR 0C
ECHO.
ECHO.      
ECHO        IMPROPER  REQUEST 
ECHO          ACCESS DENIED 
ECHO.
PAUSE
GOTO :Selection

::::::::::::::::::::::::::::::::::::::::::::
:: Deletes BAK / ERR Files on the V Drive ::
::::::::::::::::::::::::::::::::::::::::::::

:DelV_BNE
CLS
Echo.
Echo    PROCESS STARTED
ECHO    Deleting .BAK Files
ECHO    This might take a minute...
Echo.
   V:
cd \PPY005\Facilities Management\
del /S /Q /F *.bak
CLS
echo.
ECHO    BAK FILES DELETED
ECHO    Deleting .ERR Files
ECHO    This might take a minute...
Echo.
V:
cd \PPY005\Facilities Management\
del /S /Q /F *.err
CLS
COLOR E3
Echo.
ECHO    FINISHED
ECHO.
Pause
CLS
GOTO :Selection
PAUSE
GOTO :Selection

:::::::::::::::::::::::::::::::::::::::::
:: Self Explanitory, quits the program ::
:::::::::::::::::::::::::::::::::::::::::

:QUIT
EXIT
Not able to launch bat file form VBScript if path contains a space

Not able to launch bat file form VBScript if path contains a space


By : Andrew
Date : March 29 2020, 07:55 AM
will be helpful for those in need I have been trying to launch myFileToRun.bat file from a path for example. , try like this:
How to find file location of running VBScript in background?

How to find file location of running VBScript in background?


By : wei han
Date : August 29 2020, 07:00 PM
I think the issue was by ths following , You should extract their command line to find their locations !
Just copy and paste this code below as Get_CommandLine_Process.bat and execute it by double click and it will extract their paths in order to explore them with your windows explorer.
code :
@echo off
Title Extract CommandLine Of Running Processes by Hackoo 2020
Mode 100,30 & color 0A
Set "ProcessName=wscript.exe"
Set "TmpFile=%~n0_Abs_cmdline.txt"
Set "LogFile=%~n0_cmdline.txt
If Exist "%TmpFile%" Del "%TmpFile%"
If Exist "%LogFile%" Del "%LogFile%"
Set "ProcessCmd="
Set /a "Count=0"
SetLocal EnableDelayedExpansion
@For /f "tokens=2 delims==" %%P in ('wmic process where caption^="%ProcessName%" get commandline /format:list ^| find /I "%ProcessName%" 2^>nul') do (
        Set /a Count+=1
        Set "ProcessCmd[!Count!]=%%P"
)
@for /L %%i in (1,1,%Count%) do (
        echo !ProcessCmd[%%i]!>con
        echo !ProcessCmd[%%i]! >> "%TmpFile%"
)
Timeout /T 1 /NoBreak>nul
If exist "%TmpFile%" Call :Extract "%TmpFile%" "%LogFile%"
@For /f "delims=" %%a in ('Type "%LogFile%"') do (
    Explorer /n, /select, %%a
)
REM If exist "%LogFile%" Start "" "%LogFile%" & Exit
pause & Exit
::********************************************************************************************************
:Extract <InputData> <OutPutData>
(
echo Data = WScript.StdIn.ReadAll
echo Data = Extract(Data,"(^?^!.*(\x22\w^)^)\b.*(\w^).*(\.ps1^|\.hta^|\.vbs^|\.vbe^|\.cmd^|\.bat^|\.lnk^)"^)
echo WScript.StdOut.WriteLine Data
echo '************************************************
echo Function Extract(Data,Pattern^)
echo    Dim oRE,oMatches,Match,Line
echo    set oRE = New RegExp
echo    oRE.IgnoreCase = True
echo    oRE.Global = True
echo    oRE.Pattern = Pattern
echo    set oMatches = oRE.Execute(Data^)
echo    If not isEmpty(oMatches^) then
echo        For Each Match in oMatches  
echo            Line = Line ^& chr(34^) ^& Trim(Match.Value^) ^& chr(34^) ^& vbcrlf
echo        Next
echo        Extract = Line 
echo    End if
echo End Function
echo '************************************************
)>"%tmp%\%~n0.vbs"
cscript /nologo "%tmp%\%~n0.vbs" < "%~1" > "%~2"
If Exist "%tmp%\%~n0.vbs" Del "%tmp%\%~n0.vbs"
exit /b
::****************************************************
Option Explicit
Dim Title,Process,ColProcess
Title = "Find file location of running VBScript in background"
ColProcess = Find_Location("wscript.exe")
For Each Process in ColProcess
    MsgBox Process,vbInformation,Title
    Explorer(Process)
Next
'-------------------------------------------------
Sub Explorer(File)
    Dim ws
    Set ws = CreateObject("Wscript.Shell")
    ws.run "Explorer /n,/select,"& File &""
End Sub
'-------------------------------------------------
Function Find_Location(MyProcess)
    Dim colItems,objItem,CmdLine,ArrProcess
    ArrProcess = Array()
    Set colItems = GetObject("winmgmts:").ExecQuery("Select * from Win32_Process " _
    & "Where Name like '%"& MyProcess &"%' AND NOT commandline like '%" & wsh.scriptname & "%'",,48)
    For Each objItem in colItems
        If objItem.CommandLine <> "" Then
            CmdLine = Extract(objItem.CommandLine,"(?!.*(\x22\w))\b.*(\w).*(\.ps1|\.hta|\.vbs|\.vbe|\.cmd|\.bat|\.lnk)")
            ReDim Preserve ArrProcess(UBound(ArrProcess)+1)
            ArrProcess(UBound(ArrProcess))= CmdLine
        End If
    Next
    Find_Location = ArrProcess
End Function
'-------------------------------------------------
Function Extract(Data,Pattern)
    Dim oRE,oMatches,Match,Line
    set oRE = New RegExp
    oRE.IgnoreCase = True
    oRE.Global = True
    oRE.Pattern = Pattern
    set oMatches = oRE.Execute(Data)
    If not isEmpty(oMatches) then
        For Each Match in oMatches  
            Line = Line & chr(34) & Trim(Match.Value) & chr(34) & vbcrlf
        Next
        Extract = Line 
    End if
End Function
'-------------------------------------------------
For Each ProcessItem In ArrayProcesses
ColProcesses = Find_Location(ProcessItem)
    For Each Process in ColProcesses
        MsgBox Process,vbInformation,Title
        Explorer(Process)
    Next
Next
Option Explicit
Dim Title,ArrayProcesses,ProcessItem,ColProcesses,Process
Title = "Find file location of running Processes in background"
ArrayProcesses = Array("wscript.exe","cscript.exe","mshta.exe","cmd.exe")
For Each ProcessItem In ArrayProcesses
ColProcesses = Find_Location(ProcessItem)
    For Each Process in ColProcesses
        MsgBox Process,vbInformation,Title
        Explorer(Process)
    Next
Next
'-------------------------------------------------
Sub Explorer(File)
    Dim ws
    Set ws = CreateObject("Wscript.Shell")
    ws.run "Explorer /n,/select,"& File &""
End Sub
'-------------------------------------------------
Function Find_Location(MyProcess)
    Dim colItems,objItem,CmdLine,ArrProcess
    ArrProcess = Array()
    Set colItems = GetObject("winmgmts:").ExecQuery("Select * from Win32_Process " _
    & "Where Name like '%"& MyProcess &"%' AND NOT commandline like '%" & wsh.scriptname & "%'",,48)
    For Each objItem in colItems
        If objItem.CommandLine <> "" Then
            CmdLine = Extract(objItem.CommandLine,"(?!.*(\x22\w))\b.*(\w).*(\.ps1|\.hta|\.vbs|\.vbe|\.cmd|\.bat|\.lnk)")
            ReDim Preserve ArrProcess(UBound(ArrProcess)+1)
            ArrProcess(UBound(ArrProcess))= CmdLine
        End If
    Next
    Find_Location = ArrProcess
End Function
'-------------------------------------------------
Function Extract(Data,Pattern)
    Dim oRE,oMatches,Match,Line
    set oRE = New RegExp
    oRE.IgnoreCase = True
    oRE.Global = True
    oRE.Pattern = Pattern
    set oMatches = oRE.Execute(Data)
    If not isEmpty(oMatches) then
        For Each Match in oMatches  
            Line = Line & chr(34) & Trim(Match.Value) & chr(34) & vbcrlf
        Next
        Extract = Line 
    End if
End Function
'-------------------------------------------------
@echo off
REM Scan_Registry_Run_Keys.bat to get info about your running keys on the registry
REM And extract all their executables paths
Title Scanning Registry Run Keys by Hackoo 2020
Mode con cols=100 lines=5 & color 9E
setlocal ENABLEDELAYEDEXPANSION
Set "TmpFile=%Temp%\TmpFile.txt"
Set "OutPutFile=%~dp0Reg_Paths_EXE.txt"
Set "Files_List2Upload=%~dp0FilesList2Upload.txt"
Set "All_Users=%ProgramData%\Microsoft\Windows\Start Menu\Programs\Startup"
Set "Current_User=%UserProfile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"

Set Keys=^
^ "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" ^
^ "HKLM\Software\Microsoft\Windows\CurrentVersion\Run"

If Exist "%TmpFile%" Del "%TmpFile%"
If Exist "%OutPutFile%" Del "%OutPutFile%"
If Exist "%Files_List2Upload%" Del "%Files_List2Upload%"

For %%K in (%Keys%) Do (  
   cls
   echo;
   Echo             ***************************** Scanning in progress *****************************
   Echo             %%K
   Echo             ********************************************************************************
   Timeout /T 2 /Nobreak>nul
   reg query "%%~K" /s >> "%TmpFile%"
)

(
    Dir /b /s "%All_Users%"
    Dir /b /s "%Current_User%"
)>> "%TmpFile%"

Call :Extract "%TmpFile%" "%OutPutFile%"
If Exist "%TmpFile%" Start "" "%TmpFile%"

For /f "delims=" %%a in ('Type "%OutPutFile%"') do (
    echo "%%~a">>"%Files_List2Upload%"
)

If Exist "%OutPutFile%" Del "%OutPutFile%"
Start "" "%Files_List2Upload%"
Exit
::****************************************************
:Extract <InputData> <OutPutData>
(
echo Data = WScript.StdIn.ReadAll
echo Data = Extract(Data,"(^?^!.*(REG_SZ^|REG_EXPAND_SZ^)^)\b.*(\w^).*(\.exe""^|\.exe^|\.vbs^|\.vbe^|\.cmd^|\.bat^|\.lnk^)"^)
echo WScript.StdOut.WriteLine Data
echo '************************************************
echo Function Extract(Data,Pattern^)
echo    Dim oRE,oMatches,Match,Line
echo    set oRE = New RegExp
echo    oRE.IgnoreCase = True
echo    oRE.Global = True
echo    oRE.Pattern = Pattern
echo    set oMatches = oRE.Execute(Data^)
echo    If not isEmpty(oMatches^) then
echo        For Each Match in oMatches   
echo            Line = Line ^& Trim(Match.Value^) ^& vbcrlf
echo        Next
echo        Extract = Line
echo    End if 
echo End Function
echo '************************************************
)>"%tmp%\%~n0.vbs"
cscript /nologo "%tmp%\%~n0.vbs" < "%~1" > "%~2"
If Exist "%tmp%\%~n0.vbs" Del "%tmp%\%~n0.vbs"
exit /b
::****************************************************
:ExtractTarget <Link>
(
    echo set Ws = CreateObject("WScript.Shell"^)
    echo set Lnk = Ws.Createshortcut(WScript.Arguments(0^)^)
    echo WScript.Echo Lnk.TargetPath
)>Tmp.vbs
cscript //nologo Tmp.vbs "%~1" & Del Tmp.vbs
Exit /b
::****************************************************
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org