How can I run a Windows shell script prior to launching an application? - scripting

Is there a way to configure an application shortcut so that a Windows shell script is run prior to kicking off the application? In my case, I want to back-up some files before the application runs.
Thanks!

You could change the application shortcut to actually run the shell script and just add a START command to the end of the script so it runs the program once complete.
IE: change the notepad shortcut from %SYSTEMROOT%\Windows\Notepad.exe to c:\launchNotepad.bat and have launchnotepad.bat be something like
COPY importantfile.txt importantfile.txt.bak
START %SYSTEMROOT%\Windows\Notepad.exe importantfile.txt

Related

CMD window Close automatically after Jenkins build is over

I trying to run Selenium grid and node using Jenkins but the CMD windows always closes after executing the steps
i am running the below code in Jenkins Window Batch Command
cd "C:\TapsiumACSS\Grid3.9"
start Hub.bat
I need the CMD window to be opened
You can create a shortcut of the bat file and under properties in the target section you have to add &PAUSE
This will pause the command prompt until an user input is done.
Just a opinion, Not a good idea to use Jenkins and ask the user to do something as that defeats the whole automation aspect... Instead copy the selenium results into a html or text file which can be viewed later :)
P.S. you will have to refer to this bat file location in Jenkins i.e. the shortcut location
Hope it helps :)

mem_test.bat file does not execute

I am in the middle of designing a schematic in Xilinx ISE 14.7 core generator and I've run into a little problem which I need help with. I need to run mem_edit.bat file in order to run the memory editor application and create a .coe file. Whenever I run the file, command prompt just flashes on the screen without running the commands. How do I run mem_edit.bat to be able to run memory test. I have run the file in a static command prompt session and inserted a pause in the code to no avail. I have also run the commands directly in command prompt and still no success. Please help me as I am on a timeline and I need to finish this fast. I am running on a 64 bit windows10 machine. I am kinda new to Xilinx ISE so please go a bit easy on me. The contents of mem_edit.bat have been quoted below
#echo off
REM Script to launch Xilinx memory editor
set CLASSPATH=
set JAVA_HOME=
"%XILINX%\java\nt64\jre\bin\java" -DXILINX="%XILINX%" -DMYXILINX="%MYXILINX%" -cp "%XILINX%\coregen\lib\encore.jar;%XILINX%\coregen\lib\coreutil.jar;%XILINX%\coregen\lib\sim.jar;%XILINX%\coregen\lib\xcc.jar;%XILINX%\coregen\lib;%XILINX%\coregen\resources" com.xilinx.iputils.memory.editor.CoreGen2RunMemoryEditor 2> NUL
I have managed to solve the issue. I happened to stumble on the directory where the ISE cmd short cut is saved C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Xilinx Design Tools 1\ISE Design Suite 14.7\Accessories. I run the file and Kaboom, the ISE cmd fired up. I entered mem_edit.bat and the application is up and running.

Running a program at login as admin

I have a program I wrote in Visual Basic Express 2013 to put a classification banner at the top of the screen. I set up a scheduled task using ngen.exe which makes it run at login. The problem is that it doesn't run as admin so any non-privileged user can kill the task.
This program is to replace another program called Netbanner because there are a few issues with Netbanner. The program I wrote resolves all of these issues except for the admin issue. Netbanner is implemented exactly the same way (ngen.exe) but it won't let a non-privileged user kill the task.
I don't know if it is something in the program itself or I missed something in the deployment process.
This is the command used to deploy Netbanner which I duplicated to deploy mine:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\ngen.exe install "C:\Program Files\Microsoft\NetBanner\NetBanner.exe"
Also, these are the files in C:\Program Files\Microsoft\NetBanner:
NetBanner.exe
NetBanner.InstallState
NetBanner.pdb
NetBannerSchTask.xml
Any ideas?
Thanks.
You could try to go into the properties->Compatibility->Run this program as an administrator for the application.
Alternatively, you could do the same thing for a batch file that you can schedule to run on startup.

Start program via ssh in Jenkins and using it in Jenkins build

Hello people.
I'm using Jenkins as CI server and I need to run some performance test using Jmeter. I've setup the plugin and configured my workspace and everything works ok, but I have to do some steps manually and I want a bit more of "automation".
Currently i have some small programs in a remote server. These programs make some specific validations, for instance (just to explain): validates e-mail addresses, phone numbers, etc.
So, before I run the build in jenkins, I have to manually start the program (file.sh) I want:
I have to use putty (or any othe ssh client) to conect to the server and then run, for instance, the command
./email_validation.sh
And the Jmeter test runs in a correct way, and when the test is done I have to manually "shut down" the program I started. But what I want is trying to start the program I need in Jenkins configuration (not manually outside Jenkins, but in "execute shell" or "execute remote shell using ssh" build step).
I have tried to start it, but it get stuck, because when Jenkins build finds the command
./email_validation.sh
the build stops, it waits for the command to finish and then it will continue the other build steps, but obviously, I need this step not to finish until the test is executed.
Is there a way to achieve this? Thanks
Run your command as a background process by adding the & symbol at the end of the command and use the nohup command in case the parent process gets a hangup signal, e.g.
nohup /path/to/email_validation.sh &
If the script produces any output, it will go by default to the file nohup.out in the current directory when the script was launched.
You can kill the process at the end of the build by running:
pkill email_validation.sh

Running batch file on parallels vm with command issued from host mac

I am trying to start a selenium grid node on a local vm (running Windows 7) by using a call from the command line on the host Mac.
The call merely tries to run a batch file on the vm.
When I run the batch file from within the vm, it executes correctly and the node starts, so I know that batch file works correctly.
The path I am using is correct, as I can run it from anywhere on the vm.
It is just that I can't seem to call it from the host Mac.
This worked at one point, but I wonder whether a windows security update might have screwed things up?
I've tried to clear every firewall I could find. I am running parallels 8 on a MacBook Air.
Here is the syntax I am using.
prlctl exec {parallels_vm_name} 'C:\Users\{user_name}\Documents\selenium\startIeNode.bat {IP_address_here}'
The quotes around your
'C:\Users\{user_name}\Documents\selenium\startIeNode.bat {IP_address_here}'
should end at after .bat.
The only reason for those quotes is for the path, not for the command itself. It should look more like:
'C:\Users\{user_name}\Documents\selenium\startIeNode.bat' {IP_address_here}
Otherwise the IP address is being set as part of the pathname instead of a parameter.
I have almost the same setup/use case that you describe: Win 7 VM on Parallels 8. I just set my system up to do exactly what you want.
create .bat file verify it works on VM
create windows shortcut to batch file
drag shortcut onto Mac desktop, folder, Dock etc.
launch batch file from Mac shortcut
In coherence mode, VM settings to enable launching Windows Apps from Mac enabled, Parallel tools installed
Because of the way things are passed in prlctl exec, commands need to be executed double-slashed, so it would be:
prlctl exec {parallels_vm_name} "C:\\Scripts\\myScript.cmd"