How to run .Bat file in background - windows

I need to print the pdf file from the browser, so I have created a custom URL protocol to trigger the bat file, now I need to prevent the command prompt window from opening, also I need to protect the bat file from editing from the user side.

Open notepad and add the below content to it, then save the file as hidebatch.vbs:
echo Set MyScript = CreateObject("WScript.Shell")
echo MyScript.Run "C:\Path\to\your\batchfile.bat", 0, False
Simply replace C:\Path\to\your\batchfile.bat with the path to your batchfile. Then to launch this, instead of statring up your batchfile, you would run cscript hidebatch.vbs

Related

How to run .qvw (qlikview) file through Jenkins

I want to run .qvw file through Jenkins.
To Run a qlikview file I am using batch file it is working fine ,I am using below command in batch file
"path\qv.exe" /r "path\myapplication.qvw"
This command is reloading my application ,I want to do it by Jenkins.
Has anyone done this before.
When I am trying to run above batch command through jenkins job it is continuously running.
"path\qv.exe" /r "path\myapplication.qvw"
Probably it remains open. You can try to add trigger to run macro which close app after reload:
VBScript Macro to save and close app is:
sub SaveQuit
ActiveDocument.Save
ActiveDocument.GetApplication.Quit
end sub
If you are using QlikView server/publisher better use reload from QMC there.
One option may be to have VBS for opening, reloading, saving and closing, like OpenSaveClose.vbs provided below.
Then you can use it in CMD files: wscript OpenSaveClose.vbs QvDoc.qvw
REM OpenSaveClose.vbs
Dim MyApp, MyDoc
Set MyApp = CreateObject("QlikTech.QlikView")
Set MyDoc = MyApp.OpenDocEx(Wscript.Arguments.Item(0),0,False)
MyDoc.GetApplication.WaitforIdle
REM MyDoc.Reload or whatever
MyDoc.SaveAs(Wscript.Arguments.Item(0))
MyDoc.GetApplication.WaitforIdle
MyDoc.CloseDoc
MyApp.Sleep 2000
MyApp.Quit
Set MyDoc = Nothing
Set MyApp = Nothing

Can't open a .chm file from a batch file

I am trying to open a .chm file from a batch file.
The batch file has only this text in it :
echo off
start "S:\G.T.T\GTT-Vandemecum\Help Danny\GTT.chm"
If I run the batch file, the commandline opens but nothing further happens.
If I copy paste S:\G.T.T\GTT-Vandemecum\Help Danny\GTT.chm in start menu/run then it does works.
If I make a shortcut with target "S:\G.T.T\GTT-Vandemecum\Help Danny\GTT.chm" then it also works.
So the command works everywhere, except from a batch file.
What am I doing wrong here ?
It might also be important to know that when I start it from the shortcut, or start menu/runI always get a dialog
We can't verify who created this file. Are you sure you want to open this file ?
I am using Windows 7
EDIT
My problem is not the dialog, my problem is that nothing happens when I open the chm file from a batch file
The Start command is probably seeing your doublequoted string as a title, enter Start /? at the command prompt for its usage information.
Try adding an empty title first:
#Echo Off
Start "" "S:\G.T.T\GTT-Vandemecum\Help Danny\GTT.chm"

Is it possible to make a batch file launch a separate batch file

I have a elevated batch file and I want it to execute a different batch file in a separate window I need to know if it is possible and how to do it. Can any one help.
Yes, if you want to launch a file, say sample.bat, you can use
start "Title" cmd /c sample.bat
Title is the title text I want to display for the new window.
You can see the details in Documentation
Enter a START command in an existing command shell, and specify CMD as the command to execute.

How to disable ECHO DIALOGS for Windows Script Host running a vbs file?

Ran into a problem today. I have a Windows Server 2003 with a bunch of .bat files that essentially start .vbs scripts. Every time an ECH is used in the script I get that annoying dialog box that contains content of an echo and requires to click ENTER all the time. How can I just disable the dialogs and keep ECHOs in the command prompt window only?
Force it to run under cscript instead of wscript
If you are running the script manually, just put cscript in front of it.
Otherwise, this might give you an approach:
http://www.robvanderwoude.com/vbstech_engine_force.php
Redirect the output somewhere else, i.e.
scriptname.vbs > textfile.txt

help with windows batch scripting basics - execution and calling a separate executable within the script

Newbie to windows scripting. I need help running the .bat file on the command line so I can test it.
I used Text Document as my editor to create the file (opens up also as Notepad).
I performed file "save as" (ALL FILES). If I open up cmd, I can see the file has a .txt extension (myfile.bat.txt). So if I just type in cmd myfile.bat.txt the editor opens. I am not sure how to execute this correctly.
As for the logic in my batch script, I am basically logging into a remote directory (already created the net mount) and now I want to:
run an executeable file
rename some files.
With some research, I written this so far. I have saved it as a .bat file
# echo off
echo This is a batch file to run an executable and rename some files
pause
--run executable file here, just don't know how to do it
x:
cd x:
rename fileA fileB
Any help, good tips/practice would be great. Thanks.
Type in this command in cmd window:
rename myfile.bat.txt myfile.bat
Now you can run the script by simply invoking:
myfile.bat
or
myfile
(provided there's no myfile.exe or myfile.com in the same directory).
If you need to edit the script further, you can either right click it in Explorer and choose Edit or call the editor from the command window:
notepad myfile.bat
To call a program from the script, simply add its name, if it's in the current directory:
someprogram.exe
or the name with the path, if it's somewhere else:
directory\program.exe
or
d:\directory\program.exe
If the name or the path contain spaces, be sure to enclose the entire name & path string in double quotes:
"d:\directory\program name.exe"
you can just type the full name of the program
eg
"c:\program dir\program.exe"
or you can add the program directory to your path environment variable
set PATH=%PATH%;"c:\program dir"
and just type the program name
program
you can also edit your PATH variable in windows http://support.microsoft.com/kb/310519
NOTE: When you save the file in notepad, you want to save it as filename.BAT and select All Files from the second dropdown. If you don't it still gets saved as a .TXT.
A couple of command to consider:
CSCRIPT cscript /? in CMD
START http://ss64.com/nt/start.html
If you're doing say a VBSCRIPT use CSCRIPT to start it. If you're trying to execute another BATCH script or an EXE, use START

Resources