Run exe file in silent mode using command prompt - c#

I am trying to run xxx.exe file using command prompt with silent mode. i saw this link in Google: http://www.powerware.com/Software/lansafe_help/LSHelp424.htm.
when i run this command : C:>"D:\xxx.exe" -r -f1"D:\Test.iss"
am getting error : "xxx.exe" is not recognized as an internal or external command operable program or batch file.
Can any body give the idea where i am doing mistake.

As others said, make sure your path to your exe file is correct. You can change directory where exe is before execution or write out the full path.
By silent mode if you mean to run exe without any output on screen, then simply redirect the output to a file.
E.g. if your exe is in D:\myprog\myprog.exe, then following command will make your program run in "silent" mode:
c:>"D:\myprog\myprog.exe" > "D:\myprog\output.txt"
Above example will dump output into output.txt file.

you have to run your command in which location EXE file is located. can you check whether its residing in d:?

You may switch over to the D:\ drive before running your command, but it shouldn't matter. Double check it actually exists in that location

Related

Windows service not getting uninstalled

I want to uninstall Windows Service from command prompt but that is not working getting below error
'installutil' is not recognized as an internal or external command,
operable program or batch file.
This way I have tried command
D:\backup\WindowsService\WindowsService1\WindowsService1\obj\Debug>installutil -u TestService.exe
D:\backup\WindowsService\WindowsService1\WindowsService1\obj\Debug>installutil -u "TestService.exe"
How can I uninstall service?
After your comment, your issue seems related to %PATH%.
There is no such thing as "installutil" on your Windows. I believe "installutil" has created by you right?
Let's assume that binary resides at C:\Myproject\installutil.exe
There are two ways to execute it.
First:
C:\users\username> cd C:\Myproject
C:\Myproject> .\installutil.exe -u "bla bla bla bla".
Second:
Go to your start menu and search for "environment". Open "Edit the system variables" under "System properties". At the "Advanced" tab, you'll see "Environment Variables". You'll see a variable named "Path". Edit it's value and add your own .exe path at the end.
When you execute "echo %PATH" at command prompt, you should see your binary's folder. Otherwise, command prompt will not be able to find it.
EDIT:
So yeah, there is one such thing called installutil.exe and it can be used by the Developer Command Prompt for Visual Studio.
Command to uninstall service: installutil -u "AirwatchService.exe"
Are you sure you're using the right command prompt? Do you have the absolute path of this binary?
Please check this: https://learn.microsoft.com/en-us/dotnet/framework/tools/installutil-exe-installer-tool

Problem - 'dispatch' is not recognized as an internal or external command

When I tried to create dispatch-Model for my bot., I am getting following error - 'dispatch' is not recognized as an internal or external command, operable program or batch file.Before using dispatch command, I installed botdispatch using npm install -g botdispatch. But still I am getting this error.
Can you check your NPM folder to see if there is anything with dispatch there? Assuming you're on Windows, this is typically in AppData\Roaming\npm.
PowerShell:
dir $home\AppData\Roaming\npm
CMD:
dir %homepath%\AppData\Roaming\npm.
If dispatch (dispatch.cmd) is there, then it might be a pathing issue. Check your path variables to make sure that that path is there:
CMD:
echo %path%
PowerShell:
($env:path).Split(';')
So I was having this same issue, it turns out I needed to add the path of the NPM folder C:\Users\xxxxxx\AppData\Roaming\npm to my path for Powershell7.
$env:Path += ";C:\Users\xxxxxx\AppData\Roaming\npm"
Where xxxxxx is your userid. After adding this command to Powershell the npm modules began to work.
If you do not see this path by running this command below, then you need to add it with the one above.
($env:path).Split(';')
All of these should be ran inside of a PS7 window, I ran them with Administrator rights when I launched the Powershell 7 window.

Program runs as SYSTEM still not able to edit hosts file

I'm trying to edit the hosts file while my program is started as "NT AUTHORITY\SYSTEM" with psexec, and I still get UnauthorizedAccessException. I thought that SYSTEM should be able to edit hosts file that's why I'm started my program with psexec -i -d -s myapp.exe.
So what should I do to be able to edit hosts file?
Make sure that your hosts file is not marked as read-only. If it is, you will get this exception regardless of current user permissions.

Can we run a batch file (.bat) from the shared path

I have a shared path (like //servername/c$/batches/) where all my batch files are located now I am writing an web application in C# to run .bat files from that application. I know way to do it when I have a physical path.
But here I dont have a physical path. Is it possible to do it.
EDIT# 1
I execute my bat files just by double clicking on them or open the cmd progam on the physical server and then navigate to the drive and execute the bat file.
EDIT #2
when I put UNC path the get the following error
I getting an error myprogram.exe is not recognized as an internal or external command operable program or batch file. 9009
Batch files don't support UNC paths as their "current directory". There's a hackish work around of doing:
pushd "%~dp0"
your batch stuff
popd
%~dp0 expands to the current (d)rive/(p)ath/(0)batchfilename
example:
ok. a Simple batch file:
pushd %~dp0
echo "Hello from batch land"
echo %~dp0
popd
put that on a server somewhere, and try to run it via a unc path:
C:\> \\server\share\test.bat
You'll get as output:
C:\>pushd \\server\share\
Z:\>echo Hello from batch land
Hello from batch land
Z:\>echo \\server\share\
\\server\share\
Z:\>popd
C:\>
Weird, but it works.
That's called a UNC path.
You can use it just like any other path.
However, the user that your ASP.Net code is running as must have read access to the network share.
Apparently, you do have a current-directory issue.
The .bat file is trying to run myprogram.exe from the current directory.
You can make a wrapper batch file on your local machine that maps the network share:
pushd \\server\c$\dir
call filename.bat
popd
You can put this wrapper file anywhere, then call it from your code.

Installing C# Windows Service on Windows 7

I have a batch file that I have been using to install my C# Windows Services for awhile now, never had a problem until Windows 7. I have attempted to run the batch file with Administrator privileges. I have attempted to run the command prompt with admin privs, navigate to the windows service EXE and run InstallUtil there. Still doesn't work.
After reading some other suggestions I tried moving my files out of the /bin folder and running them from another location but that also didn't work.
The batch file looks like this
#ECHO OFF
REM The following directory is for .NET 2.0
set DOTNETFX2=%SystemRoot%\Microsoft.NET\Framework\v2.0.50727
set PATH=%PATH%;%DOTNETFX2%
echo Installing IEPPAMS Win Service...
echo ---------------------------------------------------
InstallUtil /i IEPPAMS_WinService1.exe
echo ---------------------------------------------------
echo Done.
and I have a install log file that I dump info to. If I just double click the .bat file I get
Running a transacted installation.
Beginning the Install phase of the
installation. See the contents of the
log file for the
C:\Users\Justin\Desktop\service
test\IEPPAMS_WinService1.exe
assembly's progress. The file is
located at
C:\Users\Justin\Desktop\service
test\IEPPAMS_WinService1.InstallLog.
An exception occurred during the
Install phase.
System.InvalidOperationException:
Cannot open Service Control Manager on
computer '.'. This operation might
require other privileges. The inner
exception
System.ComponentModel.Win32Exception
was thrown with the following error
message: Access is denied.
The Rollback phase of the installation
is beginning. See the contents of the
log file for the
C:\Users\Justin\Desktop\service
test\IEPPAMS_WinService1.exe
assembly's progress. The file is
located at
C:\Users\Justin\Desktop\service
test\IEPPAMS_WinService1.InstallLog.
The Rollback phase completed
successfully.
The transacted install has completed.
When I run the .bat file with admin privileges nothing is written to the log file, and the service is still not installed.
Any thoughts? Is there a new way to install services in Windows 7?
Right click on the batch file and run it as Administrator.
You are most likely running into battle with the new security model (User Account Control) from Windows Vista and Windows 7. Even if you are running as an account that has Admin rights you will still need to elevate to do some (most) administrative activities. (Yes it is possible to disable this feature, but don't)
UAC (MSDN)
UAC (Wikipedia)
InstallUtil (MSDN)
Edit... The correct commandline is InstallUtil YourApp.exe. The /i does not look to be a vaild switch for InstallUtil.
So I was able to fix the problem by typing in the command line the entire path to InstallUtil and it worked. So after navigating to the folder that had my EXE I typed the following:
C:\Windows\Microsoft.NET\Framework\v4.0.21006\installutil.exe
IEPPAMS_WinService1.exe
Not sure why I have to do that in Windows 7 now when I never had to in XP, but oh well. Thanks for all the suggestions!
When I run the .bat file with admin privileges nothing is written to the log file, and the service is still not installed.
First off, you HAVE to run as admin permissions.
Second, when you "Run as Administrator", it actually changes the directory to c:\windows\system32 as the initial directory ( no idea why ), which would probably explain why running as admin causes no log file. Manually change to the path IEPPAMS_WinService1.exe resides in that the start of your script.

Categories

Resources