| | |
keytool in .bat file not working
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
Hi,
The was my application works is that my C++ .exe will create a .bat file, which will then in turn run the .bat file.
The batch file is created, however does not run this keytool command correctly.
The important thing here is that if I go and manually edit that batch file created by my .exe, it works. If I delete all spaces in the command e.g keytool<del here>-import and re-space, it works??
Is there some sort of "whitespace" that I am not aware of??
Note: Some code removed.
Thanks for your help in advance!
The was my application works is that my C++ .exe will create a .bat file, which will then in turn run the .bat file.
C++ Syntax (Toggle Plain Text)
ofstream myfile ("tmp.bat"); if (myfile.is_open()) { myfile << "keytool –import –alias exe –file cert.cer –key example\n"; myfile.close(); system("tmp");
The batch file is created, however does not run this keytool command correctly.
The important thing here is that if I go and manually edit that batch file created by my .exe, it works. If I delete all spaces in the command e.g keytool<del here>-import and re-space, it works??
Is there some sort of "whitespace" that I am not aware of??
Note: Some code removed.
Thanks for your help in advance!
Last edited by darren2005; Dec 15th, 2008 at 6:35 pm.
The problem could be the difference in environment variables or current working directory. In the system() line try adding the full path to that batch file and see if that works.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
•
•
The problem could be the difference in environment variables or current working directory. In the system() line try adding the full path to that batch file and see if that works.
Do you know if C++ has an issue with ( - ) as it does with ( \ )??

Update - It seems to be an issue with the ( - ) part of the command. If C++ writes this .bat file with the keytool command using for example keytool -import it does not process this command. However, if I delete the ( - ) part and re-enter it, it works.
Last edited by darren2005; Dec 16th, 2008 at 7:07 am.
>>however the .exe does run the .bat file with no problems
Then don't bother with my suggestion.
Sounds like the problem is with the program keytool. Open the batch file with Notepad.exe, copy the line into clipboard, create a command prompt, paste that line into the cmd prompt and then execute it. Does it work?
Then don't bother with my suggestion.
Sounds like the problem is with the program keytool. Open the batch file with Notepad.exe, copy the line into clipboard, create a command prompt, paste that line into the cmd prompt and then execute it. Does it work?
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
•
•
>>however the .exe does run the .bat file with no problems
Then don't bother with my suggestion.
Sounds like the problem is with the program keytool. Open the batch file with Notepad.exe, copy the line into clipboard, create a command prompt, paste that line into the cmd prompt and then execute it. Does it work?
•
•
•
•
Without putting both versions of the .bat file into a hex editor, it's hard to see what could be wrong.
The .bat file looks and acts fine until it comes down to the KEYTOOL command. Just does not like the ( - ) part of the command?
Is there anything I could do in order to gain a better debugging experience with regards to the .bat file? Any application that would show some kind of invalid character or invisible whitespace?
Last edited by darren2005; Dec 16th, 2008 at 1:25 pm.
To be honest, your "symptom" and your "fix" don't make a lot of sense to me. You're doing what I would consider to be the obvious thing to try first (in the C++ code).
might be a more explicit way of running the batch file.
As for editors, try this
http://notepad-plus.sourceforge.net/uk/site.htm
It comes with a "hex" viewer, so you can see exactly what bytes are in the file. It's also a pretty useful text editor as well
system("cmd /c tmp.bat"); might be a more explicit way of running the batch file.
As for editors, try this
http://notepad-plus.sourceforge.net/uk/site.htm
It comes with a "hex" viewer, so you can see exactly what bytes are in the file. It's also a pretty useful text editor as well
•
•
•
•
To be honest, your "symptom" and your "fix" don't make a lot of sense to me. You're doing what I would consider to be the obvious thing to try first (in the C++ code).
system("cmd /c tmp.bat");
might be a more explicit way of running the batch file.
As for editors, try this
http://notepad-plus.sourceforge.net/uk/site.htm
It comes with a "hex" viewer, so you can see exactly what bytes are in the file. It's also a pretty useful text editor as well
![]() |
Other Threads in the C++ Forum
- Previous Thread: Can We Sort Character like Number in c++ ?
- Next Thread: Switch Statement to check dates
| Thread Tools | Search this Thread |
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll download dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph gui homeworkhelp iamthwee ifstream image input int java lib library list loop looping loops map math matrix memory multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






