I'm having problems trying to run a bunch of old 16-bit applications in Windows 2008 Server.
The applications ran fine up to Windows 2003 Server, but when I try to print from any of
them, all show printing errors (Unable to create printer driver / TERM error / etc)
The LPT1 port is redirected to a shared printer via NET USE LPT1 \ServerName\SharedPrinter
DIR > LPT1 (or any shell redirection to the printer) is working fine.
I'm using an Administrator account, so it shouldn't be a permissions problem, right?
To reproduce the behavior, I made a small test program in C (TCC 1.01 for DOS). It runs fine
in XP / 2003 Server, but on 2008 Server it shows the handle opening (5) but when is trying
to write in that handle, issues an error (Write fault error writing device LPT1, Abort, Retry,
Ignore, Fail)
#include <io.h>
#include <fcntl.h>
#include <sys\stat.h>
int main(void)
{
int handle, status;
char* sbuff;
handle = open("LPT1", O_WRONLY, S_IFBLK);
printf("%d\n", handle);
if (!handle)
{
printf("open failed\n");
exit(1);
}
sbuff = "[print test]\n";
write(handle, sbuff, strlen(sbuff));
close(handle);
getch();
return 0;
}
Any clues?
TIA,
Pablo
Mike A - I have discovered that syntax 'print /d:{lpt?} {filename}' is not working on Win2008, not from within a 16bit app OR from the command line. This syntax has been supported for years and we run it in 10 Win2003 servers. Might there be a configuration setting in Win2008 that would make it syntax compatible with previous versions of Windows? BTW, here is Microsoft Tech Bulletin that was updated April 2012 that list the syntax as being compatible with Win2008... http://technet.microsoft.com/en-us/library/cc731623.
Related
I wrote this C code
#include <stdio.h>
int main()
{
int a;
scanf("%d", &a);
printf("%d\n", a);
getchar();
return 10;
}
However I am getting this error shown in image.
What is the problem here ?
EDIT1:
I have windows 7 x64 and running VS 15.
Seems there has been similar problem before this might be helpfull.
Visual Studio debugger error: Unable to start program Specified file cannot be found
Go to the specific file location from the error open the program from there. Build it first then try to debug it again.
Problem
I have some half-year old c-programs I was working on and had hoped that I could continue working on them now. I did installed windows 10 (64-bit) right after that, so I thought could be a problem but the programs have run on windows 10 since then.
About 2 months ago, I could build with the make-file and run the executables but when I tried again today, it seems to me like the executables are not running. I have now also tried updating cygwin and (I think) all relevant packages.
I have googled if there are any important changes to cygwin but I didn't really find anything.
Details
When I try running any program nothing happens for a long while at the ./executeables/helloworld.exe line and then eventually producing the error:
$ make 1
gcc 1-helloworld.c -o ./executeables/helloworld.exe -lncurses
./executeables/helloworld.exe
0 [sig] make 7332 get_proc_lock: Couldn't acquire sync_proc_subproc for(5, 1), last 7, Win32 error 0
1324 [sig] make 7332 proc_subproc: couldn't get proc lock. what 5, val 1
After this, nothing happens and I cannot even stop the process with ctrl+C so I have to end "make.exe" (which oddly enough consists of 2 processes) with task manager. The terminal then says nothing more than
makefile:2: recipe for target '1' failed
make: *** [1] Error 1
So I'm guessing there is a problem with getting a mutex or a lock from windows for creating a process, but I have no clue why this would happen.
Code
The example in this try uses this code for a hello world program, but it's the same for the more complex programs as well.
#include <ncurses.h>
#include <string.h>
int main() {
char *message="Hello World";
int row,col;
int len = strlen(message);
initscr();
getmaxyx(stdscr, row, col); //screensize
mvprintw(row/2, (col-len)/2, "%s", message); //center of screen
getch();
refresh();
endwin();
return 0;
}
Have anyone seen this problem before?
Avast antivirus was preventing the program from running correctly. Disabling it made everything run perfectly. I finally found the answer in this thread:
Netbeans 8.1 IDE compiles and builds C programs but does not show their output
note:
Since it is not marked as an answer to the question in that thread and because that question is not explicitly focusing the same error (although presents the same error), I will keep my question instead of marking it as a duplicate.
Thank you, Sheshadri Iyengar for providing the solution.
I am in a HUGE depression now! I spend 2 days trying to use boost.python . PLEASE guide me! I will explain what I did.
I have Winows 7 64 bit.
The Python is 64 bit 2.7.3 installed at C:\Python27_amd64.
Now, I take boost_1_54_0.zip and unzip in F: directory.
The I use cmd.
bootstrap
this creates project-config.jam. I edit it and insert
using msvc : 9.0 ;
using python : 2.7 : C:\Python27_amd64\python : C:\Python27_amd64\include : C:\Python27_amd64\libs ;
Now i do
.\b2
This process runs for 20 something minutes and I am told that boost has successfully been build.
After that I install boost binaries from http://sourceforge.net/projects/boost/files/boost-binaries/
The binaries get installed in C:\local\boost_1_54_0.
Now I want to create a General project.
Now, I use the code given for embedding python in C++ here
#include <boost/python.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <iostream>
namespace py = boost::python;
using namespace std;
int main()
{
// Initialize the interpreter
Py_Initialize();
py::object main_module = py::import("__main__");
py::object main_namespace = main_module.attr("__dict__");
py::exec("print 'Hello, world'", main_namespace);
py::exec("print 'Hello, world'[3:5]", main_namespace);
py::exec("print '.'.join(['1','2','3'])", main_namespace);
}
I setup the header files and library in VC++ directories to F:\boost_1_54_0\boost_1_54_0 and F:\boost_1_54_0\boost_1_54_0\stage\lib respectively.
I also setup project-->properties-->configuration properties-->C/C++-->General-->Additional Include directories to C:\Python27_amd64\include
Likewise, I also setup project-->properties-->configuration properties--> Linker--> General to C:\Python27_amd64\libs;"C:\local\boost_1_54_0\lib64-msvc-9.0" .
Now when I compile using x64 debugger. It gives me an error
Unhandled exception at 0x00000000 in test8.exe: 0xC0000005: Access violation at location 0x0000000000000000.
I am struck since last 2 days...but thats the closest I have been since then. please help me!
So you mean a runtime error, right?
I think you should first ensure, that there is no exception thrown by boost::python itself.
First try to set the try block around you python calls with a catch(...)
If exception is caught it is most probably the boost::python::error_already_set exception.
So, you then should decode it like here
I have installed, apparently successfully, com0com v2.2.2.0 on a 64bit Windows 7 machine.
I run the command utility, like this:
command> install PortName=COM9 PortName=COM8
CNCA0 PortName=COM9
CNCB0 PortName=COM8
ComDB: COM8 - logged as "in use"
ComDB: COM9 - logged as "in use"
command> busynames COM?*
COM3
COM4
COM5
COM6
COM8
COM9
COMPOSITEBATTERY
Note: logged as "in use" is NOT an error message?
Then I try to open COM8 like this
m_hIDComDev = CreateFileA( szCodedPort, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL );
if( m_hIDComDev == NULL || m_hIDComDev == INVALID_HANDLE_VALUE ) {
wchar_t * lpMsgBuf;
DWORD dw = ::GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
myErrorMsg = (char*)malloc( 200 );
sprintf(myErrorMsg,"Error creating connection %s ( %s ) %S",
szPort,szCodedPort,lpMsgBuf);
This fails with
Error creating connection COM8 ( COM8 ) The system cannot find the file specified.
I have tried both "COM8" and "\\.\COM8".
Note that the exact same call to CreateFileA works perfectly on a 'real' COM port.
Q: Can someone tell me what the problem is?
A: On windows 7 64 bit you have to enable testing of unsigned drivers.
Run a command prompt as administrator. ( It is not enough just to run from an account with admin privileges. See here for details of how to do this. )
Type in the command bcdedit -set TESTSIGNING ON
reboot. ( Windows will place a "test Mode" note on the bottom right of the desktop )
For Windows 8 this method does not work satisfactorily or easily. Here is some discussion of the issues and workarounds.
Alternatively you might want to try a signed version - I have NOT tried this myself.
In case anyone is referencing this, and interested in this topic, the 2.2.2.0 version of com0com is signed for 64-bit Windows. This removes the need to jump through the hoops of putting Windows in "test" mode.
Here are my points:
Microsoft requires 64-bit drivers to be signed.
com0com.sys (64bit) is a mere unsigned kernel-mode driver.
SoftWx has written an interesting tutorial on installing it on a 64 bit Windows 7 machine. You can fetch it here.
This is a very old post, but just to add some help if somebody stumbles across it like I did.
After Windows 10 Version 2004 you may need to disable Secure Boot in your BIOS.
I got a signed version 3.0 of the app from SourceForge, this worked perfectly on my one PC (Windows 10 Pro Version 2004). I just installed the app and two pairs of linked ports were immediately created.
On my laptop (Windows 10 Pro Version 20H2), I did not get the same results. No COM ports were created and in the device manager the devices could not be configured. After changing the BIOS setting, I reinstalled and all went smoothly.
Links for reference:
https://sourceforge.net/projects/com0com/
https://sourceforge.net/projects/signed-drivers/files/com0com/v3.0/
To answer #DaAwesomeP above (I do not have the rep to put it in the comments), there is a repo on GitHub https://github.com/paulakg4/com0com where I can see a changes.txt. If I compare the dates, it looks like the same version 3.0 in there.
When installing a signed driver (i.e. with a properly signed .CAB) on Windows 7 through DpInst, unless it's a WHQL-signed driver, you cannot install it silently. If you run DpInst in the non-silent mode, it'll prompt you to trust the "publisher". If you run DpInst in silent mode, it would fail with a signing-related error code (something like 0x800b0109 -- check your setupapi.app.log).
While ilya's answer is good, the solution on Windows 7 is even easier. The command below deploys the certificate to both the current user and the system trusted publisher certificate stores. It requires administrative privileges and is provided by Microsoft.
For Windows 7
certutil.exe -addstore TrustedPublisher cert.cer
I verified that this works on Windows 7 64-bit to deploy signed, but not WHQL-certified, drivers - without prompting the user.
Windows XP
WHQL Certification
It appears that on XP you still need to have the drivers WHQL-certified in order to avoid prompts on install.
Pre-Installing SPC on Windows XP
For Windows XP you'll need to download the Windows Server 2003 Admin Tools Pack from Microsoft and extract certutil.exe and certadm.dll. Then the command above will work on XP as well.
Admin Tools Pack: http://www.microsoft.com/download/en/details.aspx?DisplayLang=en&id=16770
Note that the extracted msi file can be inspected by 7-zip, so you don't need to install it to obtain the exe and dll you need.
The straightforward way to do it is to add the signing certificate to the TrustedPublishers. You can do it programatically (the implementation of win32exception is left as an exercise to the reader):
#include <windows.h>
#include <wincrypt.h>
#include "win32exception.h"
void InstallTrustedPublisherCertificate(LPCTSTR CertificateFilePath)
{
DWORD dwContentType;
PCCERT_CONTEXT pCertContext = NULL;
if (!CryptQueryObject(
CERT_QUERY_OBJECT_FILE,
CertificateFilePath,
CERT_QUERY_CONTENT_FLAG_ALL,
CERT_QUERY_FORMAT_FLAG_ALL,
0,
NULL,
&dwContentType,
NULL,
NULL,
NULL,
(const void **)&pCertContext))
throw win32exception("CryptQueryObject");
if (dwContentType != CERT_QUERY_CONTENT_CERT)
throw exception("Incorrect content type of crypto object.");
__try
{
HCERTSTORE hCertStore = CertOpenStore(
CERT_STORE_PROV_SYSTEM,
0,
0,
CERT_STORE_OPEN_EXISTING_FLAG |
CERT_SYSTEM_STORE_CURRENT_USER,
_T("TrustedPublisher"));
if (hCertStore == NULL)
throw win32exception("CertOpenStore");
__try
{
if (CertAddCertificateContextToStore(hCertStore, pCertContext, CERT_STORE_ADD_NEWER, NULL))
{
// Added certificate to TrustedPublisher store.
}
else
{
DWORD err = GetLastError();
if (err == CRYPT_E_EXISTS)
{
// Certificate already exists in TrustedPublisher store.
}
else
throw win32exception("CertAddCertificateContextToStore", err);
}
}
__finally
{
CertCloseStore (hCertStore, 0);
}
}
__finally
{
CertFreeCertificateContext(pCertContext);
}
}
And the question is? If the driver is not WHQL-certified, it can't be installed silently. This is a security measure of Windows.
The Drivers have to go through WHQL Certification to avoid any kind of un-signed pop-ups.
If you are looking for any third-party WHQLTesting Service providers let us know, we would be happy to help you in this regards.