I want to run specific code with C# windows application on cmd(command prompt) for sign jar file.
I used this code
System.Diagnostics.Process.Start(#"cmd", #"/K ""c:\program Files\Java\jdk1.6.0_23\bin\jarsigner.exe"" -keystore filepath.p12 filepath.jar ""alias_name""");
I encountered this error while I executing this code
Error:
'c:\program' is not recognized as an internal or external command,
operable program or batch file.
How can I solve this problem ?
From the comments above, i understand this solves the issue:
System.Diagnostics.Process.Start(#"c:\program Files\Java\jdk1.6.0_23\bin\jarsigner.exe",
#"-keystore filepath.p12 filepath.jar ""alias_name""");
Happy signing. ;-)
Related
The problem is about sending command to Powershell,
My C# application sends commands one by one in order to get right directory to execute some files but even I downloaded all the necessary packages application throws an error
An exception of type 'System.Management.Automation.CommandNotFoundException' in 'cd C:\\Users\\User1\\Documents\\pathToFileforExecute\\ ' is not recognized as the name of a cmdlet, function, script file, or operable program.
My NuGet Packages ;
My code is like
ps.AddCommand("Set-ExecutionPolicy").AddParameter("ExecutionPolicy", "Unrestricted");
ps.Invoke();
ps.AddCommand("cd C:\\Users\\User1\\Documents\\pathToFileforExecute\\");
ps.AddCommand("./executeTheFile");
ps.AddCommand("pwd");
Collection<System.Management.Automation.PSObject> results = ps.Invoke();
Please help me to solve problem I found this feed but it didn't work for me https://github.com/PowerShell/PowerShell/issues/8119
I tried deleting the System.Management.Automation because I read this package shouldn't use by itself.
You are using AddCommand without the AddParameter option. The path is a parameter.
Try the following code:
ps.AddCommand("Set-Location").AddParameter("Path", C:\\Users\\User1\\Documents\\pathToFileforExecute\\);
Or you may use the AddScript method instead of AddCommand like in this post.
Note that the cd command is an alias for Set-Location in PowerShell.
I would like to run the following powershell commands from my C# application:
Enter-PSSession –ComputerName fedsrv01.domain.local
Start-ADSyncSyncCycle -PolicyType Delta
I found some information on the Powershell Class but struggling to achieve what I want due to my lack of experience.
https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.powershell?redirectedfrom=MSDN&view=pscore-6.2.0
This is what I have so far:
I have added the assembly and referenced system.management.automation
using (var powershell = PowerShell.Create())
{
//powershell.AddCommand("get-process");
powershell.AddCommand("Enter-PSSession -ComputerName fedsrv01.domain.local");
powershell.Invoke();
}
I get an error saying, 'The term 'Enter-PSSession -ComputerName fedsrv01.domain.local' is not recognized as the name of a cmdlet, function, script file, or operable program.
if I use: powershell.AddCommand("get-process") it executes fine.
If I launch Powershell on the same PC and enter, Enter-PSSession -ComputerName fedsrv01.domain.local it works fine.
Any assistance would be much appreciated.
Cheers,
Jono
Try compiling your application as x64. If it is compiled as x86 platform then it will be using the virtualized System32 dir so the function you require may not exist.
Powershell commands from C# 'the term is not recognizes as cmdlet'
Ok, after more research into the PowerShell class I now realise that you have to add the parameters separately using the .addparameter method.
.addcommand is just for the PowerShell commands. It now makes sense why I got the error saying the command could not be found. It was assuming the entire string was a command.
Problem solved!
Jono
I have a free trial account of Azure speech services and I use speech to text services in a program using c#.
The utility of the program is to conevrt file audios to text files, by speech to text API. The problem is taht sometimes an error appears saying:
Status: Canceled. Reason: The recognition service encountered an internal error and could not continue.Respones
text:{"Duration":0,"Offset":0,"RecognitionStatus":"Error"}.
Someone can help me if I have an error in the program or there is a problem of the free account in azure that gives problems?
Thanks!
I found that the type a WAV file I used gave me that error, I converted it be mono using FFMPEG in Docker using the following command line in PowerShell.
mkdir $pwd\original\output\ -Force
docker run -v ${PWD}\original:/tmp/workdir jrottenberg/ffmpeg -i Dummycall.wav -map_channel 0.0.0 DummycallMono.wav
Please be aware that you may need to run this for left and right channels by modifying the arguments using -map_channel 0.0.1
I'm trying to learn some C# and am currently using the internal console for outputs, but when it comes to keyboard inputs, I've read that it can not be done in the internal console on VS 2017 for Mac.
So I try to do it on external console, but all I get is this :
bash -c 'clear; cd "/Users/gb/Projects/reTest/reTest/bin/Debug";
"/Library/Frameworks/Mono.framework/Versions/5.8.1/bin/mono32"
--debug --debugger-agent=transport=dt_socket,address=127.0.0.1:56795 "/Users/gb/Projects/reTest/reTest/bin/Debug/reTest.exe" ; echo $? >
/var/folders/s_/sljf42_d01bdxlb5s_rwgsj80000gn/T/tmp563f24ea.tmp;
echo; read -p "Press any key to continue..." -n1; exit'; exit
I guess the console tries to execute a .exe application which is not possible in this case !
It's a console project by the way... I haven't found any solution for that so far.
Thks.
After further researches I found out that my bash was kind of corrupted somehow so I modified the .bash_profile file which had some extra inconvenient text..
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