Making a script to open, configure, and run multiple programs sequentially - windows

While I have experience coding in Java and c++, I have never scripted anything and would like to learn. I want to create a script or a program which:
Opens Avast Virus Scanner
-deep scans
-quits upon being completed
Opens Malwarebytes
-same as above
opens Spybot Search & Destroy
-same as above
Shuts down computer
I honestly don't know where to even start - should I use a batch file or something else? I would appreciate any help. Thanks

This is only a partial answer, but in order to open programs, you can write a batch file. I found this guide: http://www.online-tech-tips.com/computer-tips/create-windows-batch-files/
#echo off
start "Chrome" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
start "Notepad" "C:\Program Files (x86)\Notepad++\notepad++.exe"
start "VS2012" "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe"
start "Outlook" "C:\Program Files (x86)\Microsoft Office\Office14\outlook.exe"

Technically you don't have to touch coding. This can be done through "scheduling" or through some free software. Is it completely necessary to do the coding yourself?

Related

Run a batch file for Windows SAS 9.1

I'm using SAS 9.1 on Windows Server 2003 Standard Edition. I'm trying to run two programs in a batch mode. My .bat file contains exactly two rows:
Start "D:\PROGRAM FILES\SAS\SAS 9.1" -SYSIN "C:\MyFolder\prog1.sas"
Start "D:\PROGRAM FILES\SAS\SAS 9.1" -SYSIN "C:\MyFolder\prog2.sas"
After I double-click on the .bat file icon, the following message appears: "Windows cannot find 'SYSIN'. Make sure you typed the name correctly, and then try again. To search for a file, click the Start button, and then click Search".
How could this be fixed?
Thank you.
Typically you would have your SAS executable be part of the line - not just the folder (and that's likely not the right folder, though I don't recall the 9.1 folder structure - and please, please upgrade from 9.1, that's over a decade old).
Since you don't include anything with a .exe (or .com/etc.) extension, Windows probably is assuming the folder you put there is supposed to be the "Title" argument to the START command.
Include the full path to SAS.EXE including SAS.EXE itself, and see if that does what you need. If not, try removing START as that may be confusing things.
See Batch Processing Under Windows and the first listing under Four ways to schedule SAS tasks for more information.
I guess you want the two programs to run in parallel since you are using START? You need to add a title as the second argument, just insert "SAS" after START like this:
Start "SAS" "D:\PROGRAM FILES\SAS\SAS 9.1" -SYSIN "C:\MyFolder\prog1.sas"
Start "SAS" "D:\PROGRAM FILES\SAS\SAS 9.1" -SYSIN "C:\MyFolder\prog2.sas"
Ah, looking at Joe's answer, you probably need to add sas.exe to the command as well.
Removing leading "Start " and adding ".exe" to the command is sufficient:
"D:\PROGRAM FILES\SAS\SAS 9.1\sas.exe" -SYSIN "C:\MyFolder\prog1.sas"
"D:\PROGRAM FILES\SAS\SAS 9.1\sas.exe" -SYSIN "C:\MyFolder\prog2.sas"
(Thanks to all who answered here and to KurtBremser from the SAS Community.)

Windows BATCH "Can't Find the File Path"

So I was wanting to create a small batch file which runs a command line dialogue and launches various programs when my computer starts up. More for fun then practical uses really. My problem is that windows doesn't seem to be able to find some files despite my opening the file path in command prompt itself and copying the file path. It just gives me a "The system cannot find the file specified error."
Here's the relevant code for the batch file now edited for better readability (sorry about that):
//Works
start "" "C:\Program Files\Rainmeter\Rainmeter.exe"
//Also works
"G:\Steam\Steam.exe"
//Everything below this fails
"C:\Program Files(x86)\Google\Chrome\Application\chrome.exe"
"C:\Program Files(x86)\Razer\Synapse\RzSynapse.exe"
"C:\Program Files(x86)\eclipse\eclipse.exe"
"G:\Steam\steamapps\common\AdVentureCapitalist\adventure-capitalist.exe"
The first two files, rainmeter and steam, open fine, but everything past that fails. I've tried using both "Filepath" and start "" "Filepath", but neither seems to work. despite both working in the code above.
And, just to clarify, I have double and triple checked the file paths to make sure I didn't get something wrong, but it's just not working.
Thanks for any assistance that can be provided.
If you can provide which ones doesn't open it would be great.
"C:\Program Files(x86)\Google\Chrome\Application\chrome.exe"
Just like how people mentioned in your post comment there should be a space in between Program Files and (x86)
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
Feel free to make use of env variables.
%programfiles% ==> C:\Program Files
%programfiles(x86)% ==> C:\Program Files (x86)
"%programfiles(x86)%\Google\Chrome\Application\chrome.exe"

bat script only runs first line?

When I copy/paste the lines below into a cmd window it executes without a problem.
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
msbuild proj\projsln /p:Configuration=Debug
proj\proj\bin\Debug\proj.exe my args
However when I save it as DoStuff.bat I get the message below (which is the text from executing vcvars32.bat), then nothing else. It does not build my project and obviously doesn't run the newly built executable.
Why doesn't it and how do I have it run all three commands?
>"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
Setting environment for using Microsoft Visual Studio 2010 x86 tools.
Use CALL to call another batch file.
Well, there has to be a reason it isn't continuing. Is it that the command is waiting for some input? Thats all that I can think of. Try re-directing the output of the batch file to a log and see what is going on.
Alternatively, split the batch file into separate batch files and put a CALL before each call to the batch file.

Use Console2 for Visual Studio debugging?

Is there a way to use the popular Console2 cmd.exe replacement for Visual Studio debugging? In other words, when I debug a console app under VS, I want it to use Console2 instead of cmd.exe.
Interesting question. I looked into it, there are some options but none are pretty.
Console.exe takes arguments, so it's possible to start it with a specific tab and execute an arbitrary process. However, this process will always be run within it's own cmd.exe; for example if your program is c:\my.exe and you launch Console as console.exe -t tabname -r c:\myexe Console2 internally calls CreateProcess( ... cmd.exe c:\my.exe ... ), as a result you can't even see the output of my.exe. This is easily solved though: launch it as console.exe -t tabname -r "/k c:\myexe": the /k switch makes the cmd.exe stay active and you can see your program's standard output. (I looked through the source but couldn't find a way to 'attach' a tab to a currently running Console instance, so launching with arguments will always create a new instance, not sure this is what you are looking for?
You can easily modify the project's debugging properties to reflect the above:
Command: /path/to/console.exe
Command Arguments: -t tabname -r "/k $(TargetPath)"
When starting your exe from within VS, it will launch your exe witin a Console session. However the debugging won't work as VS will try to debug console.exe, not my.exe since that is now a different process. Putting a DebugBreak(); as first line in your exe's main() will sort of solve this, as it will present you the option to debug your exe. All in all, this may a bit too much of a hassle to achieve what you want, but i don't think there's another way: Console always spawns a new process, so the only way to get it debugged is to attach the debugger to it after that process started.
Scott Hanselman blogged about this.
He suggests using this value for Console Settings > tabs > Main > Shell :
%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86
Sadly for me, This does not appear to work for Visual Studio Express 2010, which lacks a vcvarsall.bat file.

Is there a command line option like devenv.exe /Edit for Sql Server Management Studio

I'm using visual studio's external tools to open .sql scripts in Sql Server Management Studio (SSMS). The problem is, each time I use the external tools command to open a .sql file from visual studio, it opens a new instance of SSMS.
Visual Studio has a switch /Edit that will do this, is there one for SQL Server Management Studio?
Choose to open the file with Explorer[1] instead of SSMS. That way the system will search for any existing instances of SSMS first.
[1] %windir%\explorer.exe
I don't think the problem is with Visual Studio external tool command. Look at SSMS command line options - maybe there is a way to force reusing existing SSMS instance.
The following works for me ( I am SQL Server 2008 though) :
So the real answer I quess is to use cmdow
Edit: After more testing I realized the following :
First open the files with connenction with: ( remove any enters while copying, this is one liner )
"C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\
Common7\IDE\Ssms.exe" "C:\Users\yordgeor\Desktop\Trigger.sql"
"C:\Users\yordgeor\Desktop\Trigger1.sql" -S ysg -d poc_dev -E -nosplash
In this example it opens two files ( but you could open less of course ; )
after which , No matter how many times I run
cmdow /Run "C:\Users\yordgeor\Desktop\Trigger1.sql"
cmdow /Run "C:\Users\yordgeor\Desktop\Trigger2.sql"
cmdow /Run "C:\Users\yordgeor\Desktop\Trigger3.sql"
it opens the same instance of the Microsoft Sql Server Management Studio with the same connection
you could open at once at the command line many files , but I quess you asked for the upper answer.
So you could find the path to the Ssms.exe by:
cd %ProgramFiles%
dir *ssms.exe /s /b
so the syntax of the command is:
pathToTheExe pathToFile1 pathToFile2 -S serverName -d DatabaseToConnectTo -E (toUseWindowsAuthentication) -nosplash
After 20 seconds of googling I cheated from here:
The correct answer is no. The SSMS has a limited set of options, and although it uses the VS framework, does not support the edit command. This could be an interesting feature to add.
I am assuming you need to open these scripts in SSMS to be able to run them as well, otherwise I would suggest pointing them to Visual Studio directly since it does support syntax highlighting. However it will not solve your problem.
If you associate that file extension with Visual Studio, then VS should open it.
If you're finding that VS starts a new instance every time, then you need to specify the /edit command line option.
Take a look at http://stevedunns.blogspot.com/2009/03/programs-that-launch-or-should-launch.html for more information.

Resources