Automatically Position Application Window Using Command File in Windows - windows

I'm using PuTTY to access my BSD file server and I have several terminal windows open at once. I wrote a simple command file to automate opening the terminal windows and I'd like to know if it is possible to place them at a specific location.
I have two monitors and as it is now, I have to manually drag the terminal windows over to my second monitor.

AFAIK you can't do it directly from a batch file without using some 3rd party software like AutoHotkey.
It makes it incredibly easy to move a window. For example this script would start Calculator and move it to the top-left corner:
Run, calc.exe
WinWait, Calculator
WinMove, 0, 0
You can also easily compile your script into an .exe if you want to share it with other people that don't have AHK installed. It will basically answer all your automation needs, just as it has done mine :)

Related

How to Launch a Metro App from Microsoft Access VBA on Windows 10 Computer

I have a situation in which I wanted to utilize the camera app in Windows 10 from my Microsoft Access program. Normally I could just send a command to execute the program's executable, but with the metro app there is no straightforward executable.
The basic code I use is this:
Shell """" & PthToExe & """", vbNormalFocus
PthToExe is the path name for the executable.
I looked around a decent bit, but was unable to find any simple solutions and ended up coming up with my own. My solution is to make a shortcut link to the camera application and then to launch the link.
In order to make a shortcut link in Windows 10, you can click on the start button, go to "All Apps", find the app you want (in my case "Camera"), and then click and drag it to the desktop.
Now that you have a shortcut, you can launch the shortcut from a command line. (So my shortcut doesn't clutter up my desktop, I dragged it off my desktop and into a folder on the "C" drive.)
Type the path into a command prompt like this and hit enter to test launching your app: C:\GJ\Camera.lnk
So that solves the problem if you wanted to launch from a command line. For some reason, though, Access would not accept that command. The way I got around it was I put the command in a batch file (Edit: Alternatively, see HansUp's comment). To do that, you just need to open notepad, type in the same thing you typed in the command prompt, save the note pad document, and then rename the document to have a .bat extension.
You can then execute the .bat file from Microsoft Access as follows:
Shell "C:\GJ\OpenCamera.bat", vbMinimizedNoFocus
Note that normally, I use vbNormalFocus when running the shell command, but in this case, it is desirable not to see the little command prompt open before the actual program opens.

Windows batch start up script to move windows

I'm experienced with many different programming languages. I decided to expand my horizons and try some simple batch scripts. I have a windows start up script that I'm running.
startupScript.bat
start "" "explorer.exe"
start "" "explorer.exe"
start "" "taskmgr.exe"
start "" "cmd.exe"
start "" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
Works great. I would like to be able to move the windows where I want them though. I'm running 5 monitors, and I want the two explorer windows on my bottom left monitor each taking half the screen. I want the command prompt and task manager in my top left monitor each taking half of the screen, and I want my chrome browser on my bottom right monitor taking up the whole screen.
Chrome remembers where it was, so that isn't a problem. The other windows don't though.
Is there a way for me to run keystrokes after each program is started? I could do "winkey+left", "winkey+left", etc... for each window if that's possible. Otherwise how might I accomplish this?
Also, when the command line is run, the properties go to defaults. Is there a way to use my command line settings so that it is sized right, has quick edit mode enabled, and has the colors that I set it to?
I'd try setting up a shortcut to the application with shortcut/Run=normal window; layout and hues to taste. Then start the shortcut (.lnk file) in your batch. Certainly works for cmd - can't say for the others...
I would have a look at AutoHotKey. I don't remember enough to tell you what your script should look like, but the little I remember tells me all you need is in their toolbox.

Compiled batch file run fullscreen

I have a batchfiles which basicly just "echo"s text into the cmd window. I compiled it to an exe but want it to be in full screen without borders and without taskbar.(Windows 7)
It should work without having to create a shortcut or any other settings like this.
It can be in the Batch code or the exe but it should start in fullscreen when - for example - I download and execute it on another computer without me having to set any settings.
Is that even possible in Batch?
If you mean running cmd.exe in fullscreen in Windows 7, it's basically impossible. Lots of people were complaining about it.
There are plenty "fake" fullscreen command lines.
You can use this one and run the batch there.

Is there any way to run a VBScript file as a screen saver?

Can you execute a VBS file as a screen saver? I have managed to rename cmd.exe to *.scr and this works, but I need to be able to run a VBS file as the screen saver if this is possible.
No, this is not possible.
In Windows, screen savers (*.scr files) are a special type of executable (.exe) file. That is why renaming a program like cmd.exe to cmd.scr causes it to sort of "work" as a screen saver. In particular, screen savers respond to certain command line switches (or parameters), which is how the OS gets them to do things like show the configuration dialog or display a preview.
But you can't compile VBScript files into executables, so there's no way to make this trick work for them.
You might be able to migrate the VBScript code to a VB 6 application, which you could then compile into an executable and run as a screen saver, but I can't imagine that this would be worth the development time. If you're interested in such a thing (and can get your hands on an old copy of VB 6!), you can probably find several how-to guides online, like this one.
But I'm honestly having a hard time imagining why one would ever want to run a VBScript script as a screen saver, or what it would display on the screen. You don't have very much control over what gets displayed on the screen, and you can't call down to native Windows API functions from VBScript. You'd end up relying upon some external library, so you might as well just use that library in the first place.
You can simply write a batch file that starts your vb script:
CD "%SystemRoot%\System32"
Start /Wait Wscript.exe "c:\program files\myscript.vbs"
Exit
Then compile the batch to exe, rename the exe to scr.

Full screen through batch command?

I have a batch script under Windows. When anyone will click on that script I want the command window to become full screen like we do by keyboard shortcut [Alt+Enter].
Can it be done automatically using any command in batch file?
In Windows XP, you need to start your program maximized (but not full screen) via "start /max" as follows:
start "Winow Title" /MAX "C:\batches\myfile.bat"
This command would be inside your original batch file, and call the real bath file.
I don't think there's a way to change the full screen-ness of an executing "cmd" command from within a batch file absent someone writing a special app to do so by emulating sending Alt+Enter to the parent process.
In Windows 7 (and probably Vista) you must run inside XP virtual machine for full screen mode.
There is none. You can write a small program doing so for you, though. There is the SetConsoleDisplayMode function.

Resources