Why WinExe doesnt works when windows starts before user login? - winexe

I'm running tools called winexe on linux to run service on windows from linux. Each time, my apache services is down, that tools will monitor and automatically restart it. It works fine every time, except when Windows just rebooted, winexe cannot access Windows.
I need to login to windows first and do nothing, and winexe can works again.
My question is what's make winexe cannot works, if I'm not login after reboot? Because even if I'm login, I do nothing but winexe can work after that. Is there any services triggered when I'm login after reboot or is there any requirement services before winexe can access windows?
Thanks for any help..

Try run winexe as follows:
winexe -debug-stderr --system -U "domain/admin%pass" //host "cmd /c <command>

Related

How can I launch postgres server headless (without terminal) on Windows?

Using Postgres 9.5 and the libpqxx c++ bindings, I want to launch a copy of postgres that is not installed on the users machine, but is instead packaged up in my application directory.
Currently, I am using pg_ctl.exe to start and stop the server, however when we do this, pg_ctl.exe seems to launch postgres.exe in a new terminal window.
I want it to launch postgres.exe in a headless state, but can't work out how.
I have tried enabling/disabling the logging collector, setting the logging method to a csv file (instead of stdout/stderr), and a couple of other logging related things, but I don't think the issue is the logging.
I have also tried running postgres.exe manually (without pg_ctl) and can get that to run headless by spawning it as a background process and redirecting the logs, but I would prefer to use the "pg_ctl start" api for the "wait for startup" (-w), and "timeout" (-t) options that it provides.
I believe you won't be able to do that with pg_ctl.
It is perfectly fine to start PostgreSQL directly through the server executable postgres.exe. Alternatively, you can use pg_ctl register to create a service and start the service.
In my use case, I was able to resolve the issue by running pg_ctl.exe using
CreateProcess, and providing the dwCreationFlags CREATE_NEW_PROCESS_GROUP | CREATE_NO_WINDOW.
I was originally using CREATE_NEW_PROCESS_GROUP | DETACHED_PROCESS, but DETACHED_PROCESS still allowed a postgres terminal to appear. This is because DETACHED_PROCESS will spawn the pg_ctl without a console, but any process that inherits stdin/stdout from pg_ctl will try to use it's console, and since there isn't one, one will be spawned. CREATE_NO_WINDOW however will launch the process with a conhost.exe, however the console will have no window. When the executables spawned by pg_ctl try to write to the terminal, they will successfully write to the console created by the conhost.exe which has no window.
I am now able to run pg_ctl from code with no console appearing.

Run the Mechanize::Firefox script in VNC server using Net::SSH::perl?

I have done the script with Mechanize::Firefox. I need to run the script in VNC server. I'm working on ubuntu. I have installed krdc software to run the scripts.
Before running the script I'm starting the vnc server by using the following command vncserver.
To connect the server via ssh I have using one password for example sshpassword. When open the krdc software there I'm using the vncpassword.
My problem is, I have trying to run the Mechanize::Firefox script using Net::SSH::perl script it is running but the firefox is not starting. So I cannot crawl the content.
How can I fix this issue.? I don't know from where need to start.

Alternatives for PsExec which works in standard user

I am using psexec to execute commands on remote server. Here is my command,
PsExec.exe" -u user \\server -h run.bat
I am entering the password manually. here I am using standard user account due to security issues. When I run the command I am getting the error,
"Make sure that the default admin$ share is enabled"
I read here that it cannot be done without admin privileges.
But when I test the same command in LAN it works in standard user.
How it works in LAN not in Remote server ?
Is there any alternative tools which will work in standard user ?
Please help me.
As an alternate tool, you can use Powershell and WinRM. Powershell allows you to execute a command, or an interactive session, on the remote windows server.
An example of executing a command is available here:
How to programmatically/remotely execute a program in EC2 Windows instance
If you need an interactive session, look at the Powershll command 'Enter-PSSession': https://technet.microsoft.com/en-us/library/hh849707.aspx

How to uninstall a service on remote machine using powershell?

I am a newbie in powershell script. I want to uninstall a service on remote machine and re-install it again. I am able to stop the service, change the files that service is using and again start it.
But, now I want to completely uninstall it.
One more thing, I will be executing these scripts via TeamCity.
I have tried following ways, but each one is giving trouble:
using wmi class
running installutil command on remote machine. But, cant execute this on remote machine since there is problem in accessing that service.
Using Get-WmiObject command and then calling delete() on retrieved service.
Is there any promising solution ??
Any help will be appreciable..
After playing a lot with TC and many commands, finally I got my answer to uninstall a service on remote computer, and its working properly.
I have made use of "wmic" command and provided the remote computer name, username and password for /node:, /username:, and /password: parameters. And, provided 'installutil.exe' command to be executed remotely. Here, the actual command is..
"wmic /NODE:$serverName /USER:$userName /PASSWORD:$password process call create '$path_to_installutil_exe\installutil /u $exe_location_path_of_service'"

netbeans 6.91 and gdb - attaching to a process run by another user

I am trying to debug a program run as another user, using Netbeans. I can do this manually at the command line, by running sudo gdm and then attaching to the pid.
However, I would like to make use of the Netbeans GUI for easier/quicker/visual debugging. When I select the pid from the list of running processes, I get the error:
GDB failed to attach to process
When I attempt to attach manually (i.e. by running gdb at the command line - without sudo), I get an 'Operation not permitted', so I know Netneans is failing to attach because of permissioning.
Does anyone know how I can attach to processes being run by another user?.
BTW I am running all this on my dev machine at home (Ubuntu), so security is not an issue.
Have you tried running netbeans as the target user?
You can do "sudo -u username netbeans"
With that, you shouldnt have a problem attaching to the process. If the target user is in another computer, I would suggest ssh with X forwarding (ssh -X user#machine).
Actually, if the target (local) user has no password set, you can try changing your gdb command to "sudo -u username gdb" to start the debugger as that user.