would like have BAT file that runs set-keys.EXE, launches default.html, and then when user closes html, run set-keys-back.EXE. (they are all in the same directory together). This might be run from a CD, so I might not have ability to write a flag file and then wait to see if it is deleted in order to continue. Have already tried START /WAIT but have seen that WAIT won't actually wait for GUI 32-bit applications. Have considered one batch file calling another one, still no luck. Would prefer not to have PAUSE and user have to come back to CMD just to hit a key - seems clunky. When they close out of HTML, I execute top.window.close(). would be nice if I could put some other code after that, but I think once the window is closed it's closed - no more processing. have not been able to get WShell execute to run. HTML status bar just says error on page - no info. Would love to hear your thoughts...
Update 2: I just figured out that you can launch IE directly without having to use the start command:
#echo off
rem You can use %SCRIPTDIR% to refer to the file to load, if you like
rem Note that %SCRIPTDIR% will contain a trailing slash!
set SCRIPTDIR=%~dp0
echo Testing this script...
C:\PROGRA~1\INTERN~1\iexplore.exe %SCRIPTDIR%foo.html
echo Continuing the script...
This example works for me (Windows XP 32-bit), and waits for me to close the browser window to continue.
Update: Here's an updated code block that launches Internet Explorer. Note that I use the short path to the iexplore.exe executable, and I specify the full path to the file to load:
#echo off
echo Testing this script...
start /wait /min cmd /C "C:\PROGRA~1\INTERN~1\iexplore.exe C:\foo.html"
echo Continuing the script...
Initial Answer: You mentioned trying the start /wait command, but how did you explicitly write it? The following batch script example works for me in Windows 7 x64:
#echo off
echo Testing this script...
start /wait /min cmd /C "%windir%\system32\notepad.exe foo.html"
echo Continuing the script...
In this example, the script does not continue execution until the user closes the Notepad application. The only downside here is that an extra command window pops up, but by using the /min parameter, we can start it minimized.
Related
I'm looking to make a file that when running it constantly kills chrome so you cannot run it (this is just for fun) and I'm trying to make it so it is not possible to just close it by hitting the X button
Would it be possible?
cls
:kill
taskkill /IM chrome.exe
goto kill
Well Windows command prompt don't let you do that.
However another languages like Python can do that.
I have a bash script that finds and exports emacs .org files to html in a given directory. I understand that org-mode makes use of htmlize.el to color the output of text in SRC blocks, which seems to work fine when executed from the command line, both as root and normal user. However, when using systemd timers to automate this task the output is no longer colored.
for i in `find /home/user/dir -name '*.org'`
do
emacs $i --batch -l /home/user/.emacs org-html-export-to-html --kill
done
I previously had problems with getting the syntax highlighting to work when executing the script directly, which was solved when -l /home/user/.emacs was added as shown in the excerpt above (publishNotes.sh).
Everything apart from the syntax highlighting seems to be working fine, which indicates that both the systemd service and the executed script itself runs according to the timer.
Service:
[Unit]
Description=Update website
[Service]
Type=simple
ExecStart=/home/user/bin/publishNotes.sh
Timer:
[Unit]
Description=Run every hour
[Timer]
OnCalendar=hourly
Unit=publishNotes.service
[Install]
WantedBy=multi-user.target
Thanks!
I would guess that this is because something is loading differently when run as root than when run under your user account. Exactly what is hard to say from the information given. However, my first suggestion would be to try running the service as your user. Try adding the User=<username> key to the [Service] section of the service, and check to see if it behaves as you expect.
I was trying to launch PUTTY from web browser while, I was able to achieve this after reading this post " http://johnsofteng.wordpress.com/2009/05/12/launch-putty-from-browser/ " but when i click on any ssh:// link both command prompt(cmd.exe) and putty.exe are opening up.I do not want command prompt(cmd.exe) to openup instead only putty.exe should launch.
The command window runs you batch file, you can achieve what you want with the following:
add start (https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/start.mspx?mfr=true) to the batch file call to start putty, ie:
start /b "C:\Program Files\PuTTY\putty.exe" %extract%
this allows the batch file to close once putty has launched, rather than waiting for it to exit.
To prevent the command window appearing in the first place take a look at this answer https://superuser.com/a/443181 and the thread it is in in general
Use this:
CD C:\Program Files\PuTTY
start putty.exe %extract%
exit
instead of :
"C:\Program Files\PUTTY\putty.exe" %extract% exit
I'm creating a batch to automate setting up new computers and one of the programs is AVAST. When I install avast silently, it installs chrome as well. Chrome isn't a program that I'm wanting to put on and it seems there is no workaround. So now I'm trying to make it uninstall chrome silently after AVAST but it just opens a new cmd window instead of running the exe.
#echo off
CD /d "C:\Program Files (x86)\Google\Chrome\Application"
for /r %%f IN (setup.ex?) DO (
START /WAIT "%%f --uninstall --force-uninstall --multi-install --chrome --system-level"
)
pause
Moving the end quotation to the end of %%f just gives an error that --uninstall isn't an existing file.
I've tried this on multiple PC's.
Not sure your still looking for an answer, but I was able to make your batch work.
CD /d "C:\Program Files (x86)\Google\Chrome\Application"
for /r %%f IN (setup.ex?) DO (
"%%f" --uninstall --force-uninstall --multi-install --chrome --system-level
)
This may not be the answer... but it's too long for a comment! Are you certain that you must instqall Chrome? How did you install AVAST? Can we see the command line? If you used some kind of answer file perhaps it can be modified or perhaps you can pass arguments to your install command. Try doing the command with /? to see if you get choices. According to this you do have a choice. https://blog.avast.com/tag/google-chrome/
"As we get close to our launch date for our new Avast! Free Antivirus, version 5 we have an exciting new agreement with Google to announce. Starting in mid-November, we will be giving our new users an option to install Google Chrome when installing Avast. And to be clear here since I think some readers were reading too much into this entry. We are not forcing Chrome on users. It is entirely up to the user–to download/install is entirely up to the user and nothing is hidden."
I have a .bat file that maps a network drive, runs an MS Access program then deletes the mapped drive and exits. When I run it through Control-M the .bat runs and finishes but the job in Control-M never ends. I have tried multiple things to end the file to send Control-M an exit code but nothing seems to be working. Below is the code:
#echo off
net use w: [path]
"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" "Y:\MSAccess.mdb"
net use w: /delete
After this code I have tried the following commands:
exit
_exit 0
timeout /T 10
No matter what I try Control-M never seems to know that the job has finished. The sysout from Control-M also does not show any kind of exit code being sent back.
Control-M is probably waiting for all the processes started under it to exit before exiting the job itself. In your case, MSACCESS is still running when the end of the BAT is reached, so it prevents Control-M job to finish.
If you have your BAT to wait for MSACCESS to finish,
net use w: [path]
start /b /wait "" "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" "Y:\MSAccess.mdb"
net use w: /delete
this might alleviate (at least stetically) your problem
After some more testing and investigation the issue was happening earlier in the .bat. The MS Access database was never being opened and run. Therefore since it was never starting it was never ending or sending an error code. I am researching why the MS Access database was not running now, which may lead to another question.
I had the same problem. I resolved my problem by adding the following at the end of the bat file:
exit /b %errorlevel%
For Windows batch scrips, add exit /b %errorlevel% at the end of file. This will help to find script has processed properly and control job will end/endnotok.