Cannot send arguments to batch file converted to application via IExpress - batch-file

I have made a batch file which contains personal data, so to hide it from other people and to post it, I decided to "encrypt" it converting it to exe via IExpress.
My batch file is named prime.bat and it is located in %userprofile%.
Here are the steps I ran with iexpress.exe:
Runned iexpress.exe.
Selected Create new Self Extraction Directive file
Selected Extract files and run an installation command.
Entered package title (Prime finder).
Selected No prompt..
Selected Do not display a license..
Selected prime.bat located in %userprofile% (C:\Users\%username%).
Entered cmd /c prime.bat in Install Program and left Post Install Command as is (<None>).
Selected Default (recommended).
Selected No message.
Entered C:\Users\username\prime.exe and did not check any of boxes below.
Selected No restart.
Selected to save SED file.
Package created successfully!
As the batch file works with arguments, it must be run from the cmd. When I clicked the file single from explorer it opened correctly. Because I had put an error message if there are no arguments, it threw expected error and exited with 1. If I type just prime.exe in cmd, the above happens, and same output is produced.
But, if I run file from cmd again, but specify arguments, I get an error message in a new window. As I don't use English language and do not have the permissions to change language, I will try to translate the output:
Syntax error appeared in command line's selections.
Type /? after the command for help.
So, I typed prime.exe /?, and a new window with help appeared. I think I am missing something in iexpress.exe options.

I solved my problem using:
prime.exe /c:"cmd /c prime.bat numeric_arguments"
Which should be used when you want to send arguments to an IExpress 'compiled' file as /c option specifies a new install command.

Related

How do I remove an Error.error file being created and cannot be deleted?

How do I delete/remove the "Error.error" file when the system says it is not there but it is?
The Error.error file was created somehow and I do not know why or how. However, the issue is the system has created this 0 byte file called "Error.error" and it cannot be deleted, even if I try a "permanent" delete command. It also will not allow me to delete any of the folder directory hierarchy in which is resides. When I do try create it, rename it, or create a physical file with the same name and extension, or try to delete this file directly or indirectly I receive the following error message:
"Could not find this item: This is no longer located in C:\maps\test. Verify the items location and try again." Then it list "Error.error" and its information. However, it is there visually.
Any thoughts or suggestions on how to remove or correct?
Thanks!
I had a very similar issue not too long ago where I had a file that was created by another program and whenever I tried to access or delete it, windows would give an error message like "...This is no longer located in...".
If you're having the same problem I was, here's how I got rid of the file. Start a command prompt. In the command prompt, enter a command like del "\\?\<full path to file>". So if your file name is "Error.error" and it is located in the folder "C:\maps\test", the command you would enter is
del "\\?\C:\maps\test\Error.error"
You can delete a folder that windows won't let you access in a similar way by changing the command from "del" to "rd /S".
If you don't know how to start a command prompt, simply click the start button and type "command". The start menu should offer an option named something like "Command Prompt - Desktop app". That's what you need to start.
I found a good explanation of what the "\\?\" means here.

Command runs in commandline but not through BAT file

I am running the following command in cmd for which I am able to get the log successfully.
cd C:\Users\sriram\AppData\Local\Temp\license1.1.4
C:\Users\sriram\AppData\Local\Temp\license1.1.4>lsmon.exe testprovilic.muc.company> C:\Users\sriram\AppData\Local\Temp\license1.1.4\usage.log
Above command will generate the logs in the usage log file. But I created a batch file as below for which it is giving me an error testprovilic.muc.company not found
#ECHO off
SET variable=C:\Users\s.d.vaidyanathan\AppData\Local\Temp\usage.log
START "C:\Users\s.d.vaidyanathan\AppData\Local\Temp\license1.1.4"lsmon.exe testprovilic.muc.company> "%variable%"
Could you please help me solve this issue.
Thanks and Regards,
Sriram
You need to add the "cd C:\Users\sriram\AppData\Local\Temp\license1.1.4" to the batch file. Or use the full path to the file like:
C:\Users\sriram\AppData\Local\Temp\license1.1.4\testprovilic.muc.company
So you would have ..
#ECHO off
cd C:\Users\sriram\AppData\Local\Temp\license1.1.4
SET variable=C:\Users\s.d.vaidyanathan\AppData\Local\Temp\usage.log
START "C:\Users\s.d.vaidyanathan\AppData\Local\Temp\license1.1.4"lsmon.exe testprovilic.muc.company> "%variable%"
or you could
#ECHO off
SET variable=C:\Users\s.d.vaidyanathan\AppData\Local\Temp\usage.log
START "C:\Users\s.d.vaidyanathan\AppData\Local\Temp\license1.1.4"lsmon.exe C:\Users\sriram\AppData\Local\Temp\license1.1.4\testprovilic.muc.company> "%variable%"
This doesn't work:
"C:\Users\s.d.vaidyanathan\AppData\Local\Temp\license1.1.4"lsmon.exe
The whole path needs to be in quotes and there needs to be a backslash after the last folder name.
Change it to this:
"C:\Users\s.d.vaidyanathan\AppData\Local\Temp\license1.1.4\lsmon.exe"
Open a command prompt window, type set and press key RETURN or ENTER to run this command. You get displayed all predefined environment variables with their current values. You can see TEMP, USERPROFILE and USERNAME.
Windows command line has a help. The command to get help is help, yes really. Try it out! You need help on command CD, enter in command prompt window help cd or alternatively cd /?. You need help on command SET and START, run help set or set /? and help start or start /?. All internal commands of cmd.exe and nearly all console applications support the parameter /? and output 1 or more help pages on running the command with this parameter.
You need a better overview of standard Windows commands? See Microsoft's command-line reference and SS64's command line reference.
I assume that sriram is your user account and s.d.vaidyanathan is the user account of someone else. By default a standard user has no permissions to access folders and files in a different user's profile than the own profile since Windows Vista. That means, you logged in as sriram can't access the files and folders of C:\Users\s.d.vaidyanathan because of missing permissions to do so. It would be necessary to use command Runas to run the batch file with account s.d.vaidyanathan.
#echo off
rem Execute lsmon.exe from license1.1.4 in my folder for temporary
rem files and folders and write the log file also into this folder.
"%TEMP%\license1.1.4\lsmon.exe" testprovilic.muc.company >"%TEMP%\license1.1.4\usage.log"
Note: Double quotes must be used around path AND file name. Just double quoting parts of a file name with path may or may not work depending on error correction and how the application is written. For details see answer on set environment variables with spaces.
See also the Microsoft article Using command redirection operators.
And regarding right usage of command START not really needed here see for example answer on How to call a batch file in the parent folder of current batch file?

how to open unregistered file in not installed program via batch?

Firstly, I've seen this.
Now, I would like to open a file which has unregistered extension in the program which is not installed in windows, all via batch.
START "%~dp0\arch\file.nesta" "%~dp0\Virtua.exe"
rem this will open only program
pause
START "" "%~dp0\arch\file.nesta" "%~dp0\Virtua.exe"
rem and this will summon "Open in program" win window
Point is to drop a file into program with one (double) click.
(exe file and bat file ar in same folder while file is in "arch" subfolder)
Syntax for command START
Squashman has given already the (nearly) right answer which I explain here in more details.
Running in a command prompt window start /? displays help for this command also described by Microsoft on page about command start with entire command line reference in menu on left side.
After command START there should be specified the "title for command window" in double quotes. This can be also an empty string specified with "" if the application to start is a GUI application and not a command or console application. The title of the GUI window is always defined by the GUI application and not by command processor. So a meaningful title string instead of an empty title string makes sense only for console applications and commands of Windows command processor executed in a new console window.
A title string in double quotes is not necessary if there is no string on entire line enclosed in double quotes because no parameter string contains a space or a character from this list: &()[]{}^=;!'+,`~ This character list is displayed at end of last output help page on running in a command prompt window cmd /?
Then one or more of the optional parameters of START itself must be specified on the line if one of those parameters is required for the task at all.
The next parameter must be the command or application to run as new process. START can be also used to just start a new command process with a new console window and therefore a command or application must not be specified. But START is used in in batch file usually to run an application in a separate process and not for just opening a new command prompt window.
And last are specified the parameters of the command or application to start.
What does this mean in practice?
Command START with one parameter in quotes
START "%~dp0\arch\file.nesta"
Command START creates in this case a new command process with Drive and path of batch file\arch\file.nesta as title for the new console window displayed in title bar of the window. So the single string in double quotes is interpreted by command START always as title string for a new command window.
Command START with two parameters in quotes in wrong order
START "%~dp0\arch\file.nesta" "%~dp0\Virtua.exe"
This results in starting Virtua.exe in directory of batch file with Drive and path of batch file\arch\file.nesta as title for the new console window in case of Virtua.exe is a console application.
But even if Virtua.exe is a GUI application, the string %~dp0\arch\file.nesta is already taken by command START as window title not being displayed anywhere and therefore Virtua.exe is always started with no parameter using this command line.
Command START with two parameters in quotes in right order with missing required title string
START "%~dp0\Virtua.exe" "%~dp0\arch\file.nesta"
This results (most likely) in an error message as Drive and path of batch file\Virtua.exe is interpreted as title and command processor can't find in directory Drive and path of batch file\arch a file with name file.nesta.* with a file extension listed in environment variable PATHEXT.
Command START with two parameters in quotes in right order and with required title string
START "" %~dp0Virtua.exe" "%~dp0arch\file.nesta"
This is the right command to start Virtua.exe in directory of batch file with file.nesta in subfolder arch of batch file folder as parameter for Virtua.exe and given the console window no title if Virtua.exe is a console application.
There is no backslash after %~dp0 as this string is expanded by command processor always to drive and path of batch file ending already with a backslash before command START processes the parameters.
Using %~dp0\ would result in \\ between path of batch file folder and for example Virtua.exe which is not 100% correct. However, Windows automatically cleans up file and folder strings with \\ inside and therefore this small mistake would have no effect on execution.
Summary
On specifying ALWAYS first a title string in double quotes after START makes your batch coding life easier.
Using "" for a GUI application and "Something meaningful" for a command or console application as title string makes it easier for the users of the batch file to identify what the opened console window is for in list of running applications displayed on using Alt+Tab, in Windows task bar depending on the used task bar options (just symbol displayed or symbol with begin of window title) and in Task Manager of Windows.
Note:
There are combinations of not quoted parameters and quoted parameters which do not require a quoted title string. But it is really much easier to specify always a title string instead of finding out when a title string in quotes must be specified and when it is possible to omit it if any parameter is enclosed in quotes.

Batch file invoked file details

I invoke a batch file from my own extension file type.In batch file i will show the details of invoking file. I know by passing parameters when invokation we will pass it and we will get by "%~sn1" OR "%1" OR "%~nx1". But i need without passing parameters.
Sample Example
My batch file code looks like this(main.bat)
#ECHO on
set modelname=(here i want help)
java -Djava.library.path="C:\Program Files\Internet Explorer" -Xms1024m -Xmx1024m -jar dist/XYZ.jar -models %modelname%
exit
If i click "Kitchen.xyz" then it'll invoke my batch file "main.bat". Now i want set "modelname" as "Kitchen.xyz". If i click "LivingRoom.xyz" ,:modelname" set as "LivingRoom.xyz".
Can anyone help please...
Thanks
You will need to change the Windows Registry associated with the file type of .xyz
[HKEY_CLASSES_ROOT\.xyz\shell]
[HKEY_CLASSES_ROOT\.xyz\shell\Name Of Your Command]
#="&Name Of Your Command"
[HKEY_CLASSES_ROOT\.xyz\shell\Name Of Your Command\command]
#="\"C:\\Path\\To\\Your\\Batch\\File\\main.bat\" \"%1\""
Save that text in a .reg file and execute it to apply the registry changes. Then when you right click .xyz files, "Name Of Your Command" will be one of the options and possibly the default option which would run when double clicked.
Then your main.bat still needs to accept one parameter and assign it to modelname.
You could also do that programatically with the REG command, but regardless of which method you use to set things up, something needs to be run to setup each machine you want to do this on.

Installing exe through batch file

I am trying to install through batch file..
ECHO OFF
ECHO Installing MySoftware . . .
"%~dp0\MySoftware.exe" /S /v/qn"UPGRADEADD=link goes here"
pause
but it fails to install.
Not much info to go on. What you have will not work if executed from a UNC drive and may not work if you 'Run as administrator' because the current directory gets changed. Try this. Of course that may not fix it and further details would be nice.
#ECHO OFF
PUSHD "%~dp0"
ECHO Installing MySoftware . . .
"MySoftware.exe" /S /v/qn"UPGRADEADD=link goes here"
Adding to my answer based on comments provided.
Presumably your bat file is in the same folder as MySoftware.exe. If it takes that long, it sounds like the install is working. Try doing
"MySoftware.exe" /?
That may give you a help screen to tell you more about the arguments beng passed. Also, try what you are now doing without the /S (which probably specifies a "silent" install... which is why you don't see anything.
PART 1 - If you want to create a "Setup" File in batch.
Maybe it works, but this is will be very hard to you for done this program.
Let's call the EXE File "Game1:
I will recommend you to take all the Game1 file's code (Maybe you can use the program Notepad++ for do this) after you taked Game1's code do this like i writing here
Let's say that the code of Game1 is:
ABC
Copy the code, then go to the batch file.
The "Setup" file of Game1 HAVE to come with a empty EXE file.
You can make a empty EXE file with notepad - just save the file as:
Name.exe
Then you doing at the batch file script this thing:
set %something%=ABC
After you done this you adding this to the batch script:
Echo %something% >> Name.exe
Don't forget to name the EXE file at the name of the program / game.
And now, if this message didn't help to you, maybe you need to make a EXE from batch file.
PART 2 - If you want to make an EXE file of batch file.
Open the start menu of Windows and search this:
IExpress
Don't let the computer search for you the full name, its working only if you wtiting the full name.
After you search IExpress, click on "Activate Command".
Click on Next, Don't change the first options.
Click on "Extract files only" and click on Next.
Name the EXE program and click Next.
Stay on "No prompt." and continue.
Now you can display a program License. if you want do a txt file and choose the display option.
Add batch files and click Next.
click on the option you want and click Next.
If you want a finish message, click on display message and write the message.
Here browse where the EXE will be and choose your options, click Next.
click Next.
Wow that's was super-long! Hope I helped you!

Resources