Showing posts with label windows. Show all posts
Showing posts with label windows. Show all posts

Tuesday, October 28, 2014

C# Creating a windows scheduled task inside a folder

 

Introduction:

Recently I needed to work with windows scheduled task, and noticed that it is possible to consolidate/organize the tasks inside tasks scheduler in folders. Essentially a possibility to consolidate the tasks by topics or vendor.

image

In order to work with task scheduler I’m using the Task Scheduler Managed Wrapper, by David Hall, available from taskscheduler.codeplex.com or as a nuget download.

Sub Folder management:

So it took me a minute to understand that sub folder collection and all the related functions are located under RootFolder and not available as immediate TaskService children.

TaskService taskService = new TaskService();
 if (taskService.RootFolder.SubFolders.FirstOrDefault(x=>x.Name=="MyFolder")==null)
                {
                    taskService.RootFolder.CreateFolder("MyFolder");
                }
...

taskService.RootFolder.SubFolders["MyFolder"].RegisterTaskDefinition("MyTask", taskDefinition);

You need to check for existing folder with the same name, calling CreateFolder with existing name will throw an exception.

Thursday, October 16, 2014

New (for me) Windows shortcuts

 

All tested on Windows 8 and 8.1

 

Ctrl+Shift+ESC – Opens Task Manager

Ctrl+Shift+Right Click on the Taskbar – adds “Exit Explorer” option to the context menu.

image

Win+X – opens a very useful menu with menu shortcuts. (this one is not very new, but some people don’t know about it - I use it every day)

ScreenClip

Saturday, November 10, 2012

Windows context menu – Flag directory

So I’ve been looking for a while an option to flag a directory with “Moved” folder.

Why would I need it? Well, for example, when downloading a torrent files, I would like to move some of the content but in the same time to keep the originals for seeding. So in order to remember what was moved and what wasn’t I would have to:

1. Create a new folder
2. Rename it to some name, like “Moved”

The fastest way to do this is by Ctrl+Shift+N and renaming.

Sounds simple, but when doing it a lot you start thinking about automation.
So here is a simple code which can update your registry to add 2 options:

1. Right click on any folder on the Windows Explorer side bar would have “Mark Moved” entry

ScreenClip
2. In the right click menu inside a folder, New menu would have “Mark Moved” entry

ScreenClip(1)

Copy the following to a text file, rename .txt to .reg and run.

Windows Registry Editor Version 5.00
 
[HKEY_CURRENT_USER\Software\Classes\.MarkMoved]
@="MarkMoved"
 
[HKEY_CURRENT_USER\Software\Classes\.MarkMoved\ShellNew]
"Command"="\"CMD\" /D /E:ON /c for /F \"tokens=*\" %%a IN (\"%1\") do md \"%%~dpa\\Moved\""
"nullfile"=hex:
 
[HKEY_CURRENT_USER\Software\Classes\MarkMoved]
"FriendlyTypeName"="Mark Moved"
 
[HKEY_CURRENT_USER\Software\Classes\MarkMoved\DefaultIcon]
@="shell32.dll,3"
 
[HKEY_CURRENT_USER\Software\Classes\MarkMoved\Shell\open]
"LegacyDisable"=hex:
 
[HKEY_CURRENT_USER\Software\Classes\MarkMoved\Shell\open\command]
@="."
 
 
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\Mark Moved]
 
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\Mark Moved\command]
@="CMD.EXE /C MD \"%1\\Moved\""
 

The information was merged form the following two sources:

http://advsurveying.com/blog/?p=186

http://stackoverflow.com/questions/4872786/adding-a-custom-new-folder-to-windows-explorer-context-menu

Next steps would be to add an icon to the explorer toolbar or ribbon.

Tested on Windows 8.

Monday, September 29, 2008

How to delete a Windows Service

In command line write

sc delete "Some Service Name"

Saturday, May 31, 2008

Detect the Status of a Windows Service

When developing software that relies upon the availability of Windows services, it is important to be able to determine a service's status.  This article explains how to check if a service is running, either on a local computer or on a remote server.

Source

Thursday, April 3, 2008

RunAs tweak

If you selected "Select a program from a list of installed programs", you would get this much more useful dialog instead:

image

The registry hack will show you the second Open With dialog instead of that irritating first one.

Manual Registry Hack

Open regedit.exe through the start menu search or run box, and then browse down to the following key (create the key if it doesn't exist)

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\

Windows\CurrentVersion\Policies\Explorer

image

Create a new 32-bit DWORD value on the right-hand side with the following values:

  • Name: NoInternetOpenWith
  • Value: 1

The change should be immediate, no need to restart anything. To reset back to default, set the value to 0 or delete the key.

 

Source

Friday, February 15, 2008

Add "Copy to" to Windows context menu

To enable a Copy To Folder option in the right-click menu when right-clicking a file or folder you have to add one key to the Registry. Use Windows R to open the run dialog and enter regedit in there. Now navigate to the Registry key HKEY_CLASSES_ROOT \AllFilesystemObjects \shellex \ContextMenuHandlers. You will notice the Send To entry there. Right-click the ContextMenuHandlers entry and select New > Key from the list.

Name that key Copy To and click ok. Now double-click the default entry on the left pane and give it the value {C2FBB630-2971-11D1-A18C-00C04FD75D13}.

 

Source

Saturday, October 6, 2007

What is ctfmon.exe And Why Is It Running?

You are no doubt reading this article because you are frustrated with the ctfmon.exe process that just won't stop opening no matter what you do. You remove it from the startup items and it just magically reappears. So what is it?

Ctfmon is the Microsoft process that controls Alternative User Input and the Office Language bar. It's how you can control the computer via speech or a pen tablet, or using the onscreen keyboard inputs for asian languages.

If you are using any of the above, you should leave it enabled. For everybody else, we'll get to the job of disabling this annoying service.

image

Depending on your system configuration, there are a number of different steps to disable it. I've tried to list all the methods below.

Step 1: Disabling in Microsoft Office 2003

We can remove the alternative text input from Microsoft Office 2003 by just removing that feature in the setup.

Note: I haven't figured out where the equivalent setting is for Office 2007 (if there is one), but we can also disable it a different way below.

Go to Add/Remove programs, choose to Change your installation of Microsoft Office and make sure you check the box for "Choose advanced customization of applications" before you hit next.

image

Find "Alternative User Input" in the list and change the dropdown to "Not available" so it looks like this:

image

Step 2a: Disabling in Windows XP

There's an additional step we can take to make sure it gets turned off in Windows XP, which really seems to be the best answer for XP users.

Open up Control Panel and choose Regional and Language Options.

image

Choose the Languages tab and then click on Details in the top section.

image

Now on the Advanced tab you can choose to "Turn off advanced text services", which should immediately close ctfmon.

image

You'll also want to take a look at the first Settings tab, and make sure that your "Installed Services" box looks similar to this one:

image

If you have more than one Installed service then ctfmon might come back… For instance on my system there was an input for my drawing tablet so I could use it as a text input… which I don't care about, so I clicked Remove on it.

Step 2b: Disabling in Windows Vista

The setting above for completely disabling text services doesn't seem to exist in Windows Vista as far as I can tell, but we can remove the additional input services using a similar method.

Open Control Panel, choose Regional and Language Options and then find "Change keyboards or other input methods".

image

On the Keyboards and Languages tab, you can select Change keyboards.

image

Now you'll finally be at the same screen as in Windows XP. You'll again want to remove the extra installed services in the list other than your default keyboard language.

image

Step 3: Remove From Startup

You won't want to perform this step before doing the others, because it will just be overwritten again. Open up msconfig.exe through the start menu run or search box, and then find the Startup tab.

image

Find ctfmon in the list and disable it by unchecking the box. Just remember that if you haven't disabled ctfmon through one of the other settings this won't help you a lot.

Step 4: If all else fails

You can just completely unregister the dlls that run the alternative input services by running these two commands from the run box (one at a time)

Regsvr32.exe /u msimtf.dll

Regsvr32.exe /u msctf.dll

If you perform this step, you should also use Step 3 to get rid of the startup entries.

Step 5: Reboot

Reboot your computer and then open a Microsoft Office application if you do have that installed. Verify that ctfmon.exe is not running.

For more information you can read the Microsoft article on the subject.

Source

Tuesday, September 25, 2007

SetACL - windows permissions management (GPL)

 

http://setacl.sourceforge.net/index.html

DOS command to delete directory with all sub directories without confirmations

Windows XP DOS command deletes the C:\TEST directory and all subdirectories WITHOUT ANY WARNING:

RD C:\TEST/S /Q

/S = Removes all directories and files in the specified directory in addition to the directory itself. Used to remove a directory tree.
/Q = Quiet mode, do not ask if OK to remove a directory tree with /S.

Friday, September 7, 2007

Tracking Down Svchost Process

In CMD window write:

tasklist /svc

Friday, August 3, 2007

Remove Old Drivers After Upgrading to New Hardware

If you are experiencing weird issues after upgrading your hardware, or you've just upgraded to the latest hardware device and aren't seeing the performance you'd like, you might want to remove the old drivers which are still installed for the old hardware, even though you can't normally see them in device manager.

What you have to do is set a less-known flag to allow you to see non-present devices, and then launch device manager. You'll then see the old devices in the list, and can uninstall the drivers for them.

In Windows Vista, the first thing you'll need to do is open a command prompt in administrator mode. Type cmd into the start menu search box, and then use Ctrl+Shift+Enter to open in administrator mode. (You can also right-click on the command prompt and choose Run as Administrator)

Now paste in the following line:

SET DEVMGR_SHOW_NONPRESENT_DEVICES=1

Then type in devmgmt.msc to start up Device Manager from the administrator command prompt.

Once you are in Device Manager, go to the View menu and choose Show Hidden Devices, which will show all the device drivers including things that aren't currently installed in your computer.

You can right-click on the driver and then choose Uninstall from the menu to remove the drivers for that old hardware.

I've found that this can resolve a lot of weird issues, and even increase performance on some machines where you've upgraded a ton of times. This isn't necessarily going to increase performance, but it's nice to have a tidy computer nonetheless.

This tip also works the same in Windows XP.

Source

Wednesday, June 20, 2007

NirCmd v2.00 - Freeware command-line tool

Windows only: Freeware command-line app NirCmd extends the functionality of the Command Prompt. NirCmd is a small command-line utility that allows you to accomplish tasks using the Command Prompt that would normally require a user interface. NirCmd has no "formal" installation process. All you need to do is copy "NirCmd.exe" to "C:\Windows" and then begin using it with Command Prompt. You can grab a list of the uses of NirCmd at the project homepage. NirCmd is a small command-line utility that allows you to do some useful tasks without displaying any user interface. By running NirCmd with simple command-line options, you can write and delete values and keys in the Registry, write values into INI files, dial to your internet account or connect to a VPN network, restart Windows or shut down the computer, create shortcuts to a file, change the created/modified date of a file, change your display settings, turn off your monitor, open the door of your CD-ROM drive, and more... NirCmd is a small command-line utility that allows you to do some useful tasks without displaying any user interface. By running NirCmd with simple command-line option, you can write and delete values and keys in the Registry, write values into INI file, dial to your internet account or connect to a VPN network, restart windows or shut down the computer, create shortcut to a file, change the created/modified date of a file, change your display settings, turn off your monitor, open the door of your CD-ROM drive, and more... Examples of what you can do with NirCmd Open the door of J: CD-ROM drive nircmd.exe cdrom open j: Close the door of Y: CD-ROM drive nircmd.exe cdrom close y: Increase the system volume by 2000 units (out of 65535) nircmd.exe changesysvolume 2000 Decrease the system volume by 5000 units (out of 65535) nircmd.exe changesysvolume -5000 Set the volume to the highest value nircmd.exe setsysvolume 65535 Mute the system volume nircmd.exe mutesysvolume 1 Unmute the system volume nircmd.exe mutesysvolume 0 Switch the system volume between the mute and normal state. nircmd.exe mutesysvolume 2 Create a shortcut on your desktop that switch the system volume between the mute and normal state. nircmd.exe cmdshortcut "~$folder.desktop$" "Switch Volume" mutesysvolume 2 Turn off the monitor nircmd.exe monitor off Start the default screen saver nircmd.exe screensaver Put your computer in 'standby' mode nircmd.exe standby log off the current user nircmd.exe exitwin logoff Ask if you want to reboot, and if you answer 'Yes', reboot the computer. nircmd.exe qboxcom "Do you want to reboot ?" "question" exitwin reboot Turn off your computer nircmd.exe exitwin poweroff Turn off all computers specified in computers.txt ! multiremote copy "c:\temp\computers.txt" exitwin poweroff force Dial to "My Internet" connection nircmd.exe rasdial "My Internet" Disconnect the "My Internet" connection nircmd.exe rashangup "My Internet" Make your Internet Explorer windows 75% transparent ! (192 / 256) nircmd.exe win trans ititle "internet explorer" 192 Minimize all your Internet Explorer windows nircmd.exe win min class "IEFrame" Close all your Internet Explorer windows nircmd.exe win close class "IEFrame" Close all your Explorer windows (My Computer, folders, and so on) nircmd.exe win close class "CabinetWClass" Hide all your Internet Explorer windows nircmd.exe win hide class "IEFrame" Show all your Internet Explorer windows (after you made them hidden with previous example) nircmd.exe win show class "IEFrame" Center all top-level windows nircmd.exe win center alltop Remove the title bar of My Computer window. nircmd.exe win -style title "my computer" 0x00C00000 Return the title bar of My Computer window that we removed in the previous example. nircmd.exe win +style title "my computer" 0x00C00000 Set the My Computer window to right-to-left order (For hebrew and arabic languages) nircmd win +exstyle title "my computer" 0x00400000 Set all child windows of My Computer window to right-to-left order (For hebrew and arabic languages) nircmd win child title "my computer" +exstyle all 0x00400000 Create a shortcut on your desktop that closes all your Internet Explorer windows nircmd.exe cmdshortcut " "~$folder.desktop$ "Close All IE" win close class "IEFrame" Create a shortcut on your desktop that hides all your Internet Explorer windows nircmd.exe cmdshortcut " "~$folder.desktop$ "Hide All IE" win hide class "IEFrame" Create a shortcut on your desktop that shows back all your Internet Explorer windows nircmd.exe cmdshortcut " "~$folder.desktop$ "Show All IE" win show class "IEFrame" Set the Windows Calculator as top-most window (above all other windows) nircmd.exe win settopmost title "Calculator" 1 Set the Windows Calculator back to regular window (non top-most window) nircmd.exe win settopmost title "Calculator" 0 Create a shortcut to Windows calculator under Start Menu->Programs->Calculators nircmd.exe shortcut "f:\winnt\system32\calc.exe" "~$folder.programs$\Calculators" "Windows Calculator" Hide the desktop window nircmd.exe win hide class progman Show the desktop window (After hiding it in previous example) nircmd.exe win show class progman Hide the start button on the system tray nircmd.exe win child class "Shell_TrayWnd" hide class "button" Show the start button on the system tray nircmd.exe win child class "Shell_TrayWnd" show class "button" Hide the clock on the system tray nircmd.exe win child class "Shell_TrayWnd" hide class "TrayClockWClass" Show the clock on the system tray nircmd.exe win child class "Shell_TrayWnd" show class "TrayClockWClass" Kill (terminate) all instance of Internet Explorer processes nircmd.exe killprocess iexplore.exe Create a shortcut on your desktop that opens the door of K: CDROM drive when you run it. nircmd.exe cmdshortcut "~$folder.desktop$" "Open CDROM" cdrom open k: Create a shortcut to NirSoft Web site on your desktop nircmd.exe urlshortcut "http://www.nirsoft.net" "~$folder.desktop$" "NirSoft" Add NirSoft Web site to your Favorities under Links folder. nircmd.exe urlshortcut "http://www.nirsoft.net" "~$folder.favorites$\Links" "NirSoft" Create a shortcut to NirSoft Web site on the desktop of all computers listed in computers.txt nircmd.exe multiremote copy "c:\temp\computers.txt" urlshortcut "http://www.nirsoft.net" "~$folder.common_desktop$" "NirSoft" Set the display mode to 800x600x24bit colors nircmd.exe setdisplay 800 600 24 Create a shortcut on the desktop that set the display mode to 800x600x24bit colors nircmd.exe cmdshortcut "~$folder.desktop$" "800x600x24" setdisplay 800 600 24 Copy all shortcuts on your desktop to another folder (f:\temp\desktop). nircmd.exe execmd copy "~$folder.desktop$\*.lnk" f:\temp\desktop Restart your Apache server (under Windows NT/2000/XP/2003) nircmd.exe service restart apache Create a shortcut on your desktop that restarts the Apache server nircmd.exe cmdshortcut "~$folder.desktop$" "Restart Apache" service restart apache Restart your IIS nircmd.exe service restart w3svc Restart MySql nircmd.exe service restart MySql Open the desired Registry key/value in RegEdit nircmd.exe regedit "HKLM\Software\Microsoft\Windows\CurrentVersion" "CommonFilesDir" Open the Registry key that you copied to the clipboard in RegEdit. nircmd regedit "~$clipboard$" Disable the screen saver nircmd.exe regsetval sz "HKCU\control panel\desktop" "ScreenSaveActive" 0 Enable the screen saver nircmd.exe regsetval sz "HKCU\control panel\desktop" "ScreenSaveActive" 1 Change the date/time of the specified filename (creation time and modified time) nircmd.exe setfiletime "c:\temp\myfile.txt" "24-06-2003 17:57:11" "22-11-2005 10:21:56" Copy your desktop folder path to the clipboard nircmd.exe clipboard set ~$folder.desktop$ Copy your start menu folder path to the clipboard nircmd.exe clipboard set ~$folder.start_menu$ Copy the content of info1.txt (simple text file) to the clipboard nircmd.exe clipboard readfile "c:\My Files\info1.txt" Add the text content of clipboard to info1.txt nircmd.exe clipboard addfile "c:\My Files\info1.txt" Clear the clipboard nircmd.exe clipboard clear Create all folders specified in "c:\temp\folders.txt". The folder path names are separated by CRLF characters. nircmd.exe paramsfile "c:\temp\folders.txt" "" "" execmd md ~$fparam.1$ Install the specified .NET assembly in the global assembly cache (like gacutil) nircmd.exe gac install "C:\temp\MyAssembly\bin\MyAssembly.dll" Empty the recycle bin in all drives. nircmd.exe emptybin Answer 'Yes' to a standard Windows message-box. nircmd.exe dlg "" "" click yes

Tuesday, May 29, 2007

Disable Caps Lock

http://johnhaller.com/jh/useful_stuff/disable_caps_lock/

Now you can disable your Caps Lock key in Windows... without any special software, and without having to pry the key off with a screwdriver. Read on to find out how. I also have a page on how to disable the Windows key.

Background

Accidentally hitting the Caps Lock key when typing up an email or coding can be maddening. Most people never use it anyway, so why not disable it? In Windows, you can by adding some keyboard scancode mapping information to your Windows registry. The complete details are at annoyances.org. To make it even easier, I decided to add some .REG files so you can disable your shift key yourself without needing to muck around with the registry.

Compatibility

This method of disabling the Caps Lock key works with all modern Windows variants: Windows 2000, Windows XP Pro & Home and Windows 2003. It will not work with older versions.

Warnings

  • These files are provided without warranty. Use them at your own risk.
  • These files will overwrite any keyboard mappings you currently have.
  • .REG files update your Windows registry. Incorrect changes to the registry may damage Windows or other installed software. Be sure you know what a given .REG file contains before merging it into the registry.
  • These files are unsupported, please do not contact me with questions on their use.

Installation / Files

The following files are .reg files. They modify the Windows registry directly. You should download them to your PC and then double-click them to add them to your registry. After saying YES to the message box, reboot your machine and enjoy freedom from Caps Lock annoyances.

Note: You cannot combine this with my method for disabling the Windows key as it will replace those scancode mappings.

Sunday, May 20, 2007

Disable Notification Balloons in XP

HKEY_CURRENT_USER\Software\Microsoft\Windows \CurrentVersion\Explorer\Advanced Source

Tuesday, March 27, 2007

Searching for Files in Linux (or Windows)

Anyone with Windows experience who is new to UNIX/Linux/CygWin pretty quickly figures out that the LS command in UNIX is the equivalent of the DIR command in Windows. At least, it is equivalent up to a point. Issuing the DIR command in Windows (with no arguments) will display the contents of the current folder. Issuing the LS command in UNIX with no arguments will do the same. After that, however, the similarities end. Say, for example, you’re searching for a file called “debug.log” that you know to be in a subfolder, or sub-subfolder, of the current directory. In Windows, the command “DIR /S debug.log” will do the job nicely. The “/S” switch tells the DIR command to recurse through every subdirectory, while the “debug.log” argument tells the DIR command what file(s) to look for.

In UNIX, however, the tool for that job is the FIND command, not the LS command. Specifically, in this case, it would be “find . -name debug.log”. The first argument after the word find — the lone period — tells the FIND command where to start looking. (As with Windows, a single period means the current directory.) The “-name” switch, together with its argument of “debug.log”, establishes a criterion for the name of the files to be found. There are dozens of other criteria available, which can be used separately or in combination. These criteria, or “tests”, include being able to test on the age of the file, the type of file, the size of the file, and attribute flags of the file. Other options available with the FIND command include actions that can be taken against the found files, such as deleting the file(s) found, or executing an arbitrary command and passing it the name of each file found.

Tip #1: Use “MAN FIND” to read all about the find command. Be sure to scroll all the way to the bottom to see a number of examples.

Tip #2: If you have trouble coming up with a combination of criteria to do what you expect, then take advantage of the -D switch to turn on one or more of the debug options. This gets the FIND command to “show its work” so you can see what it’s thinking, and how it’s interpreting the switches.

Tip #3: As you can see, the UNIX FIND command is significantly more powerful than the Windows DIR command. CygWin, the Linux emulator for Windows, allows the FIND command to be used in Windows — to search Windows drives. (See our previous articles for how to get started with CygWin.)

From