Windows shutdown dialog - windows

Is there a way to bring up the Windows XP shutdown dialog (the one with the three buttons – Suspend, Shutdown, Restart and Hibernate when Shift is pressed) using any language (preferred: C/C++, VB, Haskell, batches)?
I think I can load the msgina.dll in my C++ program, but I dunno what to do next – what function in the dll is used to show the dialog?

Assuming that your language has a way to do basic file I/O and invoke shortcuts on Windows, try this tip from here:
Create a new txt file somewhere on your system, open it and put in this one line:
(new ActiveXObject("Shell.Application")).ShutdownWindows();
Save and close the file. Change the extension to *.js.
You can make a shortcut to that file to make it easy to shut down your system.

I find PowerShell to be more elegant than other Windows scripting options.
(New-Object -Com Shell.Application).ShutdownWindows()

Related

How to include a program on startup?

I would like to have an executable file run at startup, Windows 7.
I was wondering how I may do so directly at the command line or by way of batch file.
Windows provides powershell to automatize this kind of tasks using "command prompt" or scripts.
In the case you are proposing, you can change the registry values that controls startup programs by using the new-item-property cmdlet like this
PS> New-ItemProperty HKM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\ -Name <pretty beautiful name for your app> -Value <executable for your app>
You can also use PowerShell to elliminate or to change keys. But, you know
With big power comes great responsability
On a windows comp
Hit the win + r
A small dialog box appears on bottom left. In the box type
shell:startup
You are automatically redirected to the relevant folder. Just copy past ur program into this folder.
If u have a more malicious intent in mind simply use the copy command to copy the file from its current destination(A USB perhaps) to the location gotten from the aforementioned method.
However there is a slight catch. This only works if ur the admin of the computer. So you would theoretically have to include code to hand your program admin access before copying the file
[Tutorial on how to do it here1

Invoke 'Open' Dialog from Windows Desktop

Is there some way I can programmatically (in VBS) OR by using CMD/RUN open the 'Open' dialog that contains the places bar and a browser but without opening say notepad or MSpaint?
http://i.technet.microsoft.com/dynimg/IC354177.jpg
I'd like to use this on the desktop itself, it would be really cool if there was a DLL I can just use instead of having a VBS file but if not i'm sure its possible in VBS.
I'm busy searching where the actual open dialog box comes from, it should come from some DLL file somewhere.
I might even consider stopping the windows shell from opening all together and just using this open window as the shell on some computers.
Regards, Rocklore
What version of Windows are you on?
"UserAccounts.CommonDialog" was the way to do this in XP. But it no longer exists in Windows 7. You may be able to use some of the flags available for the BrowseForFolder() method to make it look like a file open dialog. See this page for an example.
XP Edit:
Here's an XP example using UserAccounts.CommonDialog.
With CreateObject("UserAccounts.CommonDialog")
.InitialDir = CreateObject("WScript.Shell").SpecialFolders("Desktop")
.Filter = "All Files|*.*"
' Show the dialog. If [Open] is clicked, save the name of the selected file...
If .ShowOpen Then strFile = .FileName
End With

Assign VBS Script to a Keyboard Shortcut

I have a very basic VBS script that I plan on using frequently on my Windows 7 machine. Is there any way I can bind it to a keyboard shortcut so I don't have to navigate to it through Explorer obnoxiously.
I realize this question does not directly pertain to programming, or even scripting for that matter, but I could not find a straight answer online or through my own experimentation. I'm sure that there is a simple solution somewhere...
Thank you for taking the time to read, and hopefully respond to my inquiry.
Evin Ugur.
Windows does have built-in support for shell shortcut keys, where a keypress is used to invoke an *.lnk file that launches your VBScript (using either cscript or wscript).
Create a shortcut file, have it invoke your VBScript file directly or run cscript or wscript with the appropriate arguments, then save it and open its Properties sheet and set a keystroke in the "Shortcut key" field (I suggest something like Ctrl+Alt+K).
Like so:
Then, whenever you press Ctrl+Alt+K, regardless of the active application, your script will be invoked.
A more heavy-duty alternative is AutoHotKey: http://www.autohotkey.com/
Just as an FYI.
I tried this and I was not able to register the hotkey when I had the Icon in a costume folder. Even if I added the hotkey, it failed to work.
Once I moved the icon to the "C:\ProgramData\Microsoft\Windows\Start Menu\Programs", the hotkey started to work.

How to open the Run window programmatically

Everyone knows the Run window that you can open with the shortcut Windows+R or directly in the Windows menu then Run.
I'm wondering how to open this Run window programmatically.
This window seems to be part of explorer.exe.
Does anyone have an idea on it ?
You can use IShellDispatch::FileRun to achieve this.
See Using the Windows RunFile dialog - The documented and undocumented way for details and sample code.
If you mean that it could open say at 8:00 am, then you can use autohotkey and simply write
SendInput {Raw}{Lwin}{R}
and then compile it as an .exe and put it as a cron job

Customizing Windows Right-Click menus with multiple levels

I understand the process needed to customize a right click menu going through the regedit etc. However I need to the ability to go multiple levels such as in applications like WinZip. Here's a picture for clarification of what I need
alt text http://img14.imageshack.us/img14/9658/multiplemenus.jpg
You need to write a Shell Extension; there is a guide for writing one in managed code (C#) here. It will involve doing a bunch of interop and implementing COM interfaces that the windows shell will consume, namely IShellExtInit and IContextMenu.
However, one could argue that writing a Shell Extension in managed code is not advisable; it will force windows explorer to load the CLR, (or any app that uses the standard windows 'Open File' dialog) - native code (C++) would be a better choice for this.

Resources