.exe with parameter in registry key

0

0

I have a touch button in my laptop which I can configure what app it will open after touching it.

I edit a path to program in registry. When there is some .exe file (i.e. notepad.exe) everything works fine. But when I'm trying to put "rundll32.exe" with parameters to sleep windows it doesn't want to work. I put the following line:

rundll32.exe powrprof.dll,SetSuspendState Sleep

I checked another exe file with parameter"

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --incognito

And it is working. But how to run rundll32.exe with these parameters? In Command Prompt I put the above command after executing computer goes to standby mode so I assume the parameters are correct. The problem is how to execute this command from registry (by touching button). Maybe there's a special syntax for registry commands that I'm not aware of

Koboos

Posted 2013-12-10T13:13:04.620

Reputation: 5

it may be that it only supports POSIX compliant parameters like your chrome one, but my guess is that you need to adjust your quoting to account for parameters for your dll vs parameters for rundll32. – Frank Thomas – 2013-12-10T15:10:26.427

@FrankThomas Can you explain it with more details? I don't know what's your point. – Koboos – 2013-12-10T17:14:21.147

@Koboos - You should update your question with that information so my comment can be deleted. The next step is to create a working shortcut. Once you have that working we can go to the next step in trying to determine whats wrong with what you have currently. – Ramhound – 2013-12-10T17:53:41.553

@Ramhound I created shourtcut on desktop. On double-clicking, computer goes to stanby mode. I know there is a way to create batch file and point to this file in registry, but I want to know how to make this working without additional files. – Koboos – 2013-12-10T18:10:29.113

@Koboos - At this point you have a working shortcut. You also know the command works by running the shortcut. Create yourself a .bat file and instead of running Chrome run the .bat file. Since you don't want to do that, provide the full path to rundll32.exe, this should allow it to work. – Ramhound – 2013-12-10T18:56:30.280

Your tablet’s program requires a full path. Use c:\windows\system32\rundll32.exe powrprof.dll,SetSuspendState Sleep – Synetech – 2013-12-15T15:11:16.107

@Synetech already tried giving the full path, but it is also not working. – Koboos – 2013-12-16T10:22:31.677

Did you try putting the command in quotes? That seems to be the only other obvious difference between the command that works and the one that doesn’t. Other than that, the only difference left is that rundll32 is in the system directory but Chrome is not. Perhaps it’s a permissions issue… – Synetech – 2013-12-16T18:32:59.280

@Synetech Yeah I tried every combination of quoting this command/path. None worked. Is there anything I can do with permissions? Giving access for Everyone for rundll32? – Koboos – 2013-12-17T14:48:50.580

You could, but first check if that’s even the problem. When you tried it manually from the command-prompt, was it an elevated prompt? If not, then you’ll need to find out what account the program that controls the button is running in; it may be a low-privilege account. Do you know what the process is? It will probably be something specific to your laptop’s make and/or model. – Synetech – 2013-12-17T15:00:05.520

Answers

0

Try this from your tablet's button key.

"cmd /c start /wait /b rundll32.exe powrprof.dll,SetSuspendState Sleep"

Tested and working from Registry based command interpreter by yours truly. (on 2012-R2 server).

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\SLEEPYTIME]
"MUIVerb"="SLEEPYTIME"
"icon"="regedit.exe"
"Position"="Top"
"HasLUAShield"="1"

[HKEY_CLASSES_ROOT\Directory\Background\shell\SLEEPYTIME\command]
@="cmd /c start /wait /b rundll32.exe powrprof.dll,SetSuspendState Sleep"

Knuckle-Dragger

Posted 2013-12-10T13:13:04.620

Reputation: 1 817

sorry for the regedit icon, re-used another shell extension I had written previously to save time. – Knuckle-Dragger – 2013-12-15T14:49:37.837

if editing the registry directly do not include the quotes as they were created by the export to .reg file. – Knuckle-Dragger – 2013-12-15T14:54:03.963

Still not working. I've put your command without quotes into REG_SZ named QAction, but it doesn't sleep laptop on touching button. – Koboos – 2013-12-16T10:26:20.477

I don't know how the hardware button software is implementing it's command, does it work when you create a batch file ? – Knuckle-Dragger – 2013-12-17T07:32:22.313

When I put a path to bat or vbs file (with a proper command in it) everything works fine. Probably I'll stick with this solution because it does the job, but I still don't understand why some commands works in registry and some not. – Koboos – 2013-12-17T14:47:11.213