+ Post New Thread
Results 1 to 9 of 9
Windows 7 Thread, Creating keyboard shortcut to a batch file in Technical; I've looked for a way to lock my computer, although I don't want any password for my user Shutting down ...
  1. #1

    Join Date
    Nov 2011
    Location
    Sweden
    Posts
    8
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Question Creating keyboard shortcut to a batch file

    I've looked for a way to lock my computer, although I don't want any password for my user
    Shutting down the task explorer.exe does give me the effect I want because the computer is kinda hard to use.
    So I've created a batch file with "taskkill /f /im explorer.exe", and here comes the tricky part, you can't create a keyboard shortcut to a batch file.
    So I've created a shortcut to the batch file and added a keyboard shortcut to the shortcut, still with me?
    Pressing my custom keyboard shortcut "ctrl+Alt+L" worked one time and then it didn't work :|
    As it turns out you can only create keyboard shortcuts for .exe files.
    Somebody got an Idea how to solve the problem (in short terms shutting down the explorer.exe task with a keyboard shortcut without needing to download a program)?
    I do got codeblocks so writing a short c++ program might work? Althought don't know how..
    Help appreciated

  2. #2

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,689
    Thank Post
    334
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    Doesn't it kind of defeat the point? Having a "locked" computer, that isn't locked with a password.

    Bearing in mind anyone could just restart explorer, and then have full access. (Or whatever way you're planning to let yourself back in)

    If you're insistent on having it that way, Just doing a 1-line C++ shell execute of the taskkill command would do what you want, if you compile it at an exe though.

    Steve

  3. #3
    TheLibrarian
    Guest
    You might as well just use a wireless keyboard and mouse and lock them away whenever you leave the PC - it's almost as secure.

    Go for the password and lock the PC properly, you won't be sorry you did.


    Or if you *really* want your solution try http://www.copernic.com/winkey/index.html. I doubt it works on anything newer than XP though.
    Last edited by TheLibrarian; 12th December 2011 at 03:27 PM.

  4. #4

    Join Date
    Nov 2011
    Location
    Sweden
    Posts
    8
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Quote Originally Posted by Steve21 View Post
    Doesn't it kind of defeat the point? Having a "locked" computer, that isn't locked with a password.

    Bearing in mind anyone could just restart explorer, and then have full access. (Or whatever way you're planning to let yourself back in)

    If you're insistent on having it that way, Just doing a 1-line C++ shell execute of the taskkill command would do what you want, if you compile it at an exe though.

    Steve
    I don't like having password because when I start the computer it will stop at the login screen, but I do only got one user so when I don't have any password it will automatically login and this is good if I'm for example away on the toilet. And I don't really got any data on my school laptop that I am afraid to lose because I do you windows mesh for my documents and steam for my games.

    So I like this method more than password (maybe just because I kinda found it myself whilst playing around..)

    Haha this is a kinda long reply for which may be a bit unnecessary but english ain't my native language so I'm not perfect at it, but exactly how would you write the c++ line, my knowledge in c++ is a bit below basic

  5. #5

    Join Date
    Nov 2011
    Location
    Sweden
    Posts
    8
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Quote Originally Posted by TheLibrarian View Post
    Or if you *really* want your solution try Copernic Winkey - Redefine your keyboard shortcuts. I doubt it works on anything newer than XP though.
    Thanks for the help I will use that as a plan B

  6. #6


    Join Date
    Feb 2007
    Location
    51.405546, -0.510212
    Posts
    8,774
    Thank Post
    222
    Thanked 2,632 Times in 1,939 Posts
    Rep Power
    779
    Try this. Copy-and-paste the following code into your PowerShell prompt (or ISE), press Enter and you will get an EXE on your desktop which kills Explorer.exe.

    Code:
    Add-Type -OutputType WindowsApplication -OutputAssembly "$Env:UserProfile\Desktop\KillExplorer.exe" @"
    
    using System.Diagnostics;
    class Program
    {
         static void Main() {
    
              try {
    
                   Process[] processesByName = Process.GetProcessesByName("Explorer");
    
                   for (int i = 0; i < processesByName.Length; i++) {
                        Process process = processesByName[i];
                        process.Kill();
                   }
              }
    
              catch {
              }
         }
    
    }
    "@
    N.B. When I tested this in a VM, all Windows Explorer processes do get killed, but Explorer relaunches itself automatically afterwards. Anyone know why? Is it the C# code?

  7. #7

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,689
    Thank Post
    334
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    Quote Originally Posted by Arthur View Post
    Try this. Copy-and-paste the following code into your PowerShell prompt (or ISE), press Enter and you will get an EXE on your desktop which kills Explorer.exe.

    Code:
    Add-Type -OutputType WindowsApplication -OutputAssembly "$Env:UserProfile\Desktop\KillExplorer.exe" @"
    
    using System.Diagnostics;
    class Program
    {
         static void Main() {
    
              try {
    
                   Process[] processesByName = Process.GetProcessesByName("Explorer");
    
                   for (int i = 0; i < processesByName.Length; i++) {
                        Process process = processesByName[i];
                        process.Kill();
                   }
              }
    
              catch {
              }
         }
    
    }
    "@
    N.B. When I tested this in a VM, all Windows Explorer processes do get killed, but Explorer relaunches itself automatically afterwards. Anyone know why? Is it the C# code?
    Process kill will always restart explorer, you need to taskkill it

    Steve

  8. Thanks to Steve21 from:

    Arthur (13th December 2011)

  9. #8

    Join Date
    Nov 2011
    Location
    Sweden
    Posts
    8
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Just for the record I've found another way to solve the problem, on my laptop I've got some kind of Dell thingie installed by default and by using that program (which I found when pressing Windows Key+X) I could add custom fn+any letter shortcut, and it did support .bat extensions
    Now I'm thinking about adding so it not only just shutdowns explorer.exe but also removes the cursor, any ideas?

  10. #9

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,846
    Thank Post
    876
    Thanked 1,680 Times in 1,460 Posts
    Blog Entries
    12
    Rep Power
    444
    I know i way around it

    Where its asks for an .exe do but the following

    "C:\windows\system32\cscript.exe" "C:\folder\batchfile.bat"

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 14
    Last Post: 18th March 2012, 09:14 PM
  2. Batch File to run a shortcut
    By tommccann in forum Scripts
    Replies: 6
    Last Post: 13th September 2010, 02:17 PM
  3. Replies: 4
    Last Post: 6th November 2008, 01:42 PM
  4. Create shortcut to a program that isn't installed on server
    By katem in forum How do you do....it?
    Replies: 10
    Last Post: 26th March 2007, 11:23 AM
  5. prezzie batch file to collect dps logs
    By russdev in forum ICT KS3 SATS Tests
    Replies: 4
    Last Post: 16th May 2006, 12:16 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •