Automation: How to run some program on multiple windows 7 PCs? - windows

I have an program which I need to run on multiple PCs (>100) all in same domain and share the same user and password.
If I run a program manually, it opens a console windows where I can see the logs running. I can remote desktop and still be able to see the console windows open and logs running. It helps in debugging as I can see whats going on. Issue is I want to avoid running it manually on all PCs.
I have following requirement
a. It should be able to run program on multiple pcs remotely
b. program should open in foreground where console logs can be seen.
c. launching PC should launch program on PC1 and then (without wait for the program to finish on PC1) it should launch the program on PC2 and so on.
I explored STAF it needs to be installed on all stations. Its heavyweight, needs complex configuration.
I explored power shell , it needs to be enabled on all stations and also probably (read somewhere) has issue with running tasks in foreground.
psexec can run the program but it does it in background, if I use -i option I need to give session id so only it will show the console for a specific remote desktop session. Another major issue with -i is that it will interactive so it waits until the program exits.
Looked a paexe, its simillar to psexe and doesn't solve the issue I am facing with psexe.
Any help is greatly appreciated.

If you have a server, you can put the program on the server and create a shortcut to it (assuming the program is small/simple enough to run on a network share).
You can use One-Click to deploy the programs, and give each of your users a link.
You can change the program into a website for central access.
You can use group policy to deploy the program when a user logs in, assuming you can create a .msi file from it.

Related

Starting a .EXE in multiple windows sessions

I have a need for starting an .exe program in multiple windows sessions (15) on the same server, whenever the server reboots.
I had a code that used to do that at start-up, but we lost that.
The exe file collects data from a bunch of servers. It needs to be run in multiple windows sessions--I think this way the process works in parallel.
Does anyone know a way to achieve this?
PsExec is a tool primarily used for running code on other servers, but can be pointed at the local machine too. The -i option can specify a session:
Run the program so that it interacts with the desktop of the specified
session on the remote system. If no session is specified the process runs in the console session.

Bach file runs executable as service instead of as App

I have written and compiled an AutoIT script ("BiconNET.exe") which interacts with the user when double-clicked. While running, the taskmanager lists the program as an App.
Now, I would like to remotely start BiconNET.exe. So I installed and configured openSSH, Cygwin and Putty. Server and client run on Windows 8.1.
I create the SSH-connection using the windows login credentials from the server. I start BiconNET.exe through the Putty conmmandline and I see instantly BiconNET.exe pop up as a service in the taskmanager of the server. But no user interaction follows. The service remains silent, and BiconNET.exe doesn't do any of the tasks its supposed to do. What is wrong here?
I guess I need to achieve that BiconNET.exe runs as an App, not as a service!?
This is what I tried so far:
I tried a workaround using a batchfile, but same issue here: Doubleclicking the batch-file on the Server works fine (BiconNET.exe interacts with the user as wished), but running it through Putty BiconNET.exe gets listed as a service, not doing anything.
I also tried to auto-elevate the batch file using this code. No luck.
I excluded BiconNET.exe from the "Data Execution Protection" (DEP) in the advanced system properties of the server. Makes no difference
I would like to understand where the problem comes from, and how to solve it. Thanks for helping.

How can I screen capture a Windows 7 desktop and login screen? (i.e. remote monitoring)

My company has about 50 - 60 machines that we need to manage remotely.
They are set to automatically login but I'd like to perform the following activities:
Capture screenshot (for diagnostic purposes, if something isn't working)
Start/stop/kill processes
Start/stop/kill services
Reboot machine
This seems simple enough but I'd like to get information on the best approach for doing this. My biggest problem is capturing a screenshot "no matter what is going on". For example, if I write a Windows Service, it can't capture the desktop session screen or the login screen.
EDIT: I've prefer to make this a Windows Service so it can run even if the user isn't logged in (i.e. if a problem occurs with the auto-login) but that doesn't seem possible. Furthermore, I'd also like to capture a screen if somebody RDPs in the machine. Basically, I want to know exactly what is going on with each machine and monitor it remotely.
Remote Capture Screen Shots
Boxcutter will do this (I dont know about the login screen though, however in theory if you run it with PSExec below it should)
Start/stop/kill processes & Start/stop/kill services
PSExec, PSList, PSKill, PSService all part of SysInternals will work here
Reboot machine
run shutdown command via PSExec or run shutdown command with -m flag and the PC name you want to shutdown.
PSTools and remote shutdown do require / prefer the machines be on the same Domain as your PC and you must have admin rights to the PC's in question

How to ask a remote windows machine to automatically launch an application?

I have a windows server 2003 up in the internet.
But sometime I need to restart it.
After restart, I want one of the applications to run.
I want to do this all programatically.
I can now remotely restart the server.
But the question is how can I ask that piece of software to be executed (more precisely, I want to execute a .BAT file to ask a tomcat to run)?
Because I don't want to manually log in to the machine and start that application. That is time consuming. Is there any possible way, once the machine is started, my application will be run as well?
If you're developing an application that should always be running on the server, you probably need to implement it as a Windows service. For C#, see the classes in the System.ServiceProcess namespace -- you will need to inherit from ServiceBase.
Alternatively, you can set the program to be run as a scheduled task on boot. See the Task Scheduler API to do this.
You can install Cygwin and then do it the same way we'd do it on a Linux box: via ssh, using keys.
OpenSSH is not part of the default Cygwin install, so be sure to select it. It's in the Net category.
Then, after you've installed Cygwin and sshd, read /usr/share/doc/Cygwin/openssh.README to learn how to set up sshd as a service, so it will answer requests automatically, without you having to start the ssh daemon manually.
Finally, set up keys, as described in the link above.
Part of the ssh protocol is a way to ask a remote machine to launch a program. Setting it up with keys lets you do it without needing a password.
You could try xCmd, which is a freeware app to run a command on a remote machine.

Run a script on Windows startup without a user logged on

This is a Windows 2003 (or later) machine that gets switched on every morning, but no one logs on until some hours later.
I want to use the time in between to run a backup script c:\script\backup.cmd
How can I start this unattended after the machine has come up?
I tried 2 registry keys, but this resulted in the script being run after a user logs on (which is too late):
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunServices
In the end I used Windows TaskScheduler, who has such an option, but I was wondering if there is another possibility?
Short answer: GPEDIT.MSC (Start, Run, GPEdit.msc)
Windows 2000 and above [1] offer a computer Startup Scripts collection in the policy editor:
Computer Settings -> Windows Settings -> Scripts (Startup/Shutdown)
There's an equivalent logon script area (i.e. after computer startup, when a user logs on) in the User configuration bit.
Longer:
GPEDIT.MSC is the Group Policy editing console, and runs against the local computer's Local Group Policy store when it's used directly, so it's useful for setting local-only parameters. When using Active Directory, a similar interface is used to edit AD Forest-hosted group policy objects (GPOs), so the same settings are available across a bunch of machines.
The computer startup scripts run in the computer context, i.e. as LocalSystem, as you noted, so they often can't access network drives which require a certain user or group membership to work. When domain-member computers access network resources, they generally (with exceptions) authenticate using their MACHINENAME$ account - which lets you set Share/NTFS permissions to allow a computer to access those resources.
A startup script is a quick and easy way of getting a process running when the machine boots.
The computer startup process will be affected by the time it takes to run the program, though, so you might want to ensure you call it with the START command from a batch file, or specifying not to wait for the executable to complete in whatever script language you use. (the key point there is: run the script asynchronously unless it's critical, or doesn't need to be run asynchronously cos it will always take no time at all. Long boots = unhappy users).
Using a Win32 Service is an alternative option - you can use the SRVANY utility from the Resource Kit to "service-ify" pretty much any executable. VS.Net 2002 and later also let you build a managed service directly.
And Task Scheduler gets much more capable as of Vista/2008, able to run scripts at startup, on idle, and/or when Event Logs are generated or certain other conditions are met: it's pretty cool! Scheduled Tasks has the possible advantage of being able to specify the user account under which the task runs, if that's important to you.
Caveat Scriptor:
http://support.microsoft.com/kb/256320
Run Startup Scripts Asynchronously:
http://msdn.microsoft.com/en-us/library/ms811602.aspx
Vista Task Scheduler (what's new):
http://technet.microsoft.com/en-us/appcompat/aa906020.aspx
[1] Windows XP, 2003, Vista/2008, Windows 7/2008R2, Windows 8/2012, Windows 8.1/2012R2, Windows 10/Windows Server 2016. Everything. But NT4 didn't!
You have already outlined a good solution:
Setup a scheduled task to run at Start Up and allow the job to run when the user isn't logged on.
You can run a script at system startup using group policy gpedit.msc
The way you aleady do this seems fine to me; however if you want an alternative approach then services get started when the machine boots so you could write a service that detects if it's a new day (to allow for reboots) and if it is then run your backup.
If I was doing this as a service I'd use TCL because I know it and like it and it has an extension twapi that allows you to run a script as a service. Other scripting languages may well have similar facilities.
There is, if you're using Active Directory. If you can isolate the computer to its own OU or use WMI filtering, you could assign a GPO which has a startup script for the computer. This would ensure that even if someone went in via safe mode and disabled the Task Scheduler, upon startup and connection to the domain, the script would run.

Resources