windows

How do I Shutdown - Restart - Logoff Windows via bat file

I've been using Remote Desktop to get into a workstation but I'm not able to use the shutdown/restart function in the Start menu while doing this. I've put a few really helpful options in the answer below. As I cannot accept this answer, please vote up if you find it appropriate. Note: I wanted to make sure some really good answers ...

Finding the default application for opening a particular file type on Windows

Hi there, I'm developing an application targeting .NET Framework 2.0 using C# for which I need to be able to find the default application that is used for opening a particular file type. I know that, for example, if you just want to open a file using that application you can use something like: System.Diagnostics.Process.Start( "C:\.....

Track started applications in Windows

We're trying to put together kiosk solution where we can charge people by hour for applications they use. As such, we need a way to figure out when an application is started, when it is closed and log this information for billing. I am a reasonably experienced .NET programmer so a managed code solution would be great. I have also dabbled...

What are your favorite tools to backport modifications from branch to trunk in subversion directories ?

On a project I'm working on, we use subversion, with tortoiseSVN as a client, under windows XP. As we enter in production and continue development in parallel, many branches are created. Often, we have to backport modifications made on the branch to the trunk, or to older branches. Backporting is a very delicate task, as many errors ca...

Using PostMessage in Windows Mobile to simulate a menu pick

I'm writing a routine to provide user definable keyboard short-cuts for any menu item in my Windows Mobile 5 application, which is in C++/MFC. To do this I am getting all of the available menu command IDs, and using the CWnd::PostMessage(WM_COMMAND,MyMenuID) to post it to the application. I use this technique to good effect elsewhere f...

The RunInstaller attribute in a WMI provider assembly

Hello - I am creating a decoupled WMI provider in a class library. Everything I have read points towards including something along these lines: [System.ComponentModel.RunInstaller(true)] public class MyApplicationManagementInstaller : DefaultManagementInstaller { } I gather the purpose of this installation is because the Windows WMI i...

Windows VPN connection ports.

I'm trying to connect to my workplace using a VPN connection, however I'm behind a firewall and I need to know what ports the connection will use to ask the network adiministrator to open them. I'm using Windows Vista and the VPN Server runs on a Windows 2003 Server machine. ...

Stop MSVC++ debug errors from blocking the current process?

Any failed ASSERT statements on Windows cause the below debug message to appear and freeze the applications execution. I realise this is expected behaviour but it is running periodically on a headless machine so prevent the unit tests from failing, instead waiting on user input indefinitely. Is there s a registry key or compiler flag I ...

How do I transfer a file using wininet that is readable by a php script?

I would like to transfer a text file to a webserver using wininet as if the file was being transferred using a web form that posts the file to the server. Based on answers I've received I've tried the following code: static TCHAR hdrs[] = "Content-Type: multipart/form-data\nContent-Length: 25"; static TCHAR frmdata[] = "file=filename...

Windows hangs during headless build

We are trying to automate a build of one of our products which includes a step where it packages some things with WISE. At one point WISE pops up a window with a progress bar on it to show how it is doing. If one is connected to the machine with remote desktop the build works fine but if one is not connected the build stalls until you ...

How can I create a thread-safe singleton pattern in Windows?

I've been reading about thread-safe singleton patterns here: http://en.wikipedia.org/wiki/Singleton_pattern#C.2B.2B_.28using_pthreads.29 And it says at the bottom that the only safe way is to use pthread_once - which isn't available on Windows. Is that the only way of guaranteeing thread safe initialisation? I've read this thread on ...

API for creating installers on Windows

There are lots of tools for creating installers on Windows (InstallShield, InnoSetup, NSIS, just to name a few). All tools I've seen fall in one or both of these categories Point-and-click. Nice GUI for creating the installer, but the installer definition/project file can not be manually edited. Textfile: No (official) GUI. The install...

How to avoid flicker while handling WM_ERASEBKGND in Windows dialog

I have a dialog that resizes. It also has a custom background which I paint in response to a WM_ERASEBKGND call (currently a simple call to FillSolidRect). When the dialog is resized, there is tremendous flickering going on. To try and reduce the flickering I enumerate all child windows and add them to the clipping region. That see...

How to forward the TCP/IP traffic of a process in Windows XP?

(The curly lines with dots represent a network route.) Having a process called "foo.exe", is there a way to forward everything it communicates over TCP/IP to a forwarding proxy located elsewhere? This forwarding should not reflect to other processes. Another question: if there are multiple network adapters, is it possible to force a ...

Limitations in running Ruby/Rails on windows

In the installation documentation to RoR it mentions that there are many limitations to running Ruby on Rails on Windows, and in some cases, whole libraries do not work. How bad are these limitations, should I always default to Linux to code / run RoR, and is Iron Ruby expected to fix these limitations or are they core to the OS itself?...

PHP 4 and 5, Ctrl-C, system(), and child processes.

I have a PHP script that uses the system() call to execute other (potentially long-running) programs (for interest: NCBI BLAST, phrap, primer3 and other programs for doing DNA sequence analysis and assembly). I'm running under Windows XP, using the CLI version of PHP from a command prompt, or as a service. (In either case I communicate ...

Detecting Mouse clicks in windows using python

How can I detect mouse clicks regardless of the window the mouse is in? Perferabliy in python, but if someone can explain it in any langauge I might be able to figure it out. I found this on microsoft's site: http://msdn.microsoft.com/en-us/library/ms645533(VS.85).aspx But I don't see how I can detect or pick up the notifications list...

How to tell if text on the windows clipboard is ISO 8859 or UTF-8 in C++ ?

I would like to know if there is an easy way to detect if the text on the clipboard is in ISO 8859 or UTF-8 ? Here is my current code: COleDataObject obj; if (obj.AttachClipboard()) { if (obj.IsDataAvailable(CF_TEXT)) { HGLOBAL hmem = obj.GetGlobalData(CF_TEXT); CMemFile sf((BYTE*) ::GlobalLock(hmem),...

How do you control printer tray selection for printer in Windows

We need to be able to change the default selected print tray of a given printer. Does anyone have VC++/win32 code for doing this? In case it matters, I believe we have to change the default setting for the printer. Our print jobs are executed by an application other than ours, so we can't make these kinds of changes in the context of ...

How can I debug a .BAT script?

Is there a way to step through a .bat script ? The thing is , I have a build script , which calls a lot of other scripts , and I would like to see what is the order in which they are called , so that I may know where exactly I have to go about and add my modifications . ...