Executing a .CMD script from Control-M is not working - windows

We have a .CMD script that we are triggering from Control-M.
A main.cmd is being called from Control-M. This script is run as 'accnt_svc' service account which we also configured in Control-M. Prior to setting up in Control-M, we testing this running fine when ran from command prompt (as administrator) and via Windows Task Scheduler being run as the 'acct_svc' service account.
When running in Control M, the log shows error saying a subscript (say sub.cmd is being called from main.cmd) saying the sub.cmd is invalid.
We checked the permissions and they both have the same settings.
We tried another script, this time we created a wrapper which 'calls' the main script. This worked fine.
Please check following wrapper:
SET V_CMDDRV=E:
%V_CMDDRV%
CD %V_CMDDIR%
CALL CALL %V_CMDDIR%\main.cmd
When we create a Main_Wrapper.cmd calling the main.cmd this works fine.
May I know why Control-M behaves this way?
Thanks

When issuing a command via Control-M it will by default run from your run as users home directory. From the output you've attached it looks like main.cmd might need to be run from E: instead of the %HOMEPATH% of the acct_svc service account.

Related

Microsoft Azure Backup (MARS) not running from scheduled tasks

We've got several servers running MAR's the lastest version 2.0.9145.0
I can run all backup's manually and its runs without problems. But when i try to run it from scehduled backups it shows in task scheduler that its run but gives this error code:2147942401
If i manually input the arguements into powershell it runs fine. However the task scheduler is not kicking in the backups.
I've altered the permissions to a domain admin, changed PS path to syswow64. So now i'm lost.
Has anyone had similar and any ideas on how to fix it or at least run the commands from a bat file instead?

how to run batch file with task scheduler with option run whether logged on or not

OS: Windows 10
I'm trying to run a batch file on Windows 10 from the Task Scheduler. I can run the batch file fine if I run it from the command prompt.
If I run it from the Task Scheduler to only run when the user is logged in, the task will run without any issues. However, when it runs when the user is not logged in, the Task Scheduler looks like it's running the file but nothing happens.
I've tried changing the batch file to nothing but the following line to ensure it's not because of what's in the batch file
I run it with higher privilege I allowed the user account to log as a batch file in local security policy
I still hours to fix this issue but still the same problem when I run my batch file manually with option (run whether logged on or not) it will run but nothing happens
My configuration:

Running script on Meterpreter in Msfconsole

The purpose of my task is to run a Ruby script, which executes key-logger exe file, and starts working on remote computer. I manage to successfully connect by apache2 server (i.e. my other VM enters a link in the browser and meterpreter starts to work) with PAYLOAD php/meterpreter/reverse_tcp. So when meterpreter starts to work , Im trying to run script: run ruby.rb
https://i.stack.imgur.com/pVEDI.jpg
ruby.rb (with content)
exec("/root/Desktop/time/time/bin/Debug/time.exe")
However, error is occurring and I dont understand why? When I try to execute my time.exe file in WINDOWS it works perfectly. The keylogger is written in c# if someone interested in looking at the code: https://ufile.io/y9n3z
Maybe someone can give my an advice or a workaround?

Is there any way to open the CMD through teamcity so it will open and displayed on the desktop?

I have a batch job that i want to deploy from Teamcity to several servers,
to access several servers i use Winexe tool.
the batch is running but i can't see the session because it's started from teamcity,
but i can see that its running when looking at the process list.
My issue is that sometimes this job is having some errors,
which are being displayed on the cmd window when i run it manualy
but since i'm running it through TeamCity i can't see the CMD window so i can't see the error.
My question is:
Is there any way to open the CMD through teamcity so it will open and displayed on the desktop when i access the server as the same user?
note: bare in mind that i need to deploy it to several servers so i can't install several
agents via ZIP File.
So I found kind of a work-around to solve this problem,
I created a schedule task in windows that will run my batch.
when creating this task you need to set those settings:
1.) Run as: the user name that TeamCity is logging in.
2.) check the Run only if logged on check box.
3.) in the security tab give the user you use full permitions.
In order to run the schedule task you need to run this batch script:
Schtasks.exe /Run /TN name_of_schedule_task

How to run batch file (As administrator) from Window Service

I have created a windows service, its running fine.
Now I would like to run a batch file as Administrator using windows service, because without administrator privileges it doesn't return any output.
So please let me know how can I do that. When I run directly using right click, run as administrator its working fine. Batch file as follows:
Runas.exe /noprofile /user:"Laxmilal Menaria" "lm.exe"
Thanks,
Laxmilal Menaria

Resources