| 1. |
Solve : Single line code? |
|
Answer» Hello, It works fine for me. And me. And I have Win7 Home Premium 64-bit. Do you (the OP) have User Account Control turned on or off, and what WARNING level is it at?I tried it on my wife's machine (also 64bit win7 home premium) and also works. Both machines have the User Account control setting to minimum (never notify). So, there must be something in my machine's setting? ThanksFWIW, the only thing it does is change the titlebar to say NONADMIN, the color is actually the same as the defaults. What does bcdedit do when you execute it as non-admin?Also, saying it "doesn't work" is a bit vague- what actually happens?The color could be changed in the line to (color 07 && title NONADMIN) so that a non admin command prompt should change the background color to blue and the title to NOADMIN. On my machine this does not happen. The background color and title does not change (for a non admin command prompt). My wife's computer works fine. Try typing color 07 in cmd and see what happens... you must have meant color 17 if you WANTED blue. Change that and see what happens then.I did that and posted my previous post. My machine does not go that part of the code. If you run 'bcdedit' in a non admin command prompt you get a message: "'bcdedit' is not recognized as an internal or external command. Made some other test and in this case cames up with an errorlevel of 9009 on my machine. On an andmin command processor the errorlevel is 0. Now, for some reason my machine started to work. Ok, for the next step. In the registry, \HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor If you create a REG_SZ key, name it 'AutoRun' and the line bcdedit /enum >nul 2>nul && (color FC && title ADMIN) || (color 17 && title NONADMIN) as the value, the colours should come up as the white background for an admin command processor and blue for non admin command processor. Both my machines now behave the same. The admin command processor is white but the non admin command processor is black. I thought that if the code worked in a batch then it would work here also. I think I know what causes this latest problem. I LAUNCH the admin command processor from a shorcut to cmd.exe. I launch the non admin command processor using DropMyRights. Being launched by DropMyRights, the command processor probably doesn't go through the registry key. So the line of code is not processed. I think.1. You can use a number of commands that will fail if you are not in an admin prompt, for example reg query "HKU\S-1-5-19" 2. You don't need double ampersands like here (color FC && title ADMIN). A single ampersand is a command separator whereas a double ampersand or double pipe is an errorlevel test. Command1 && Command2 means "execute Command1 and if the errorlevel is zero, execute Command2". Command1 || Command2 means ""execute Command1 and if the errorlevel is not zero, execute Command2". So you can just use (color FC & title ADMIN). Color FC should ALWAYS return an errorlevel of zero, if it doesn't you have some problems to sort out! |
|