Jump to content
Sign in to follow this  
mikethetechguy

Moved/Dont touch - Running exe on limited user account

Recommended Posts

mikethetechguy

Ok so the basics of this are that I'd like to disable visual effects in Win XP for computers with less than 512mb of RAM, it's actually amazingly simple. The problem comes with running in a domain environment where users (kids in a school district) cannot run an ".exe". The settings for xp visuals are on a per user basis (no global settings to change) and cannot be changed via registry. So the script opens up control panel, system, then navigates and clicks. Students are not allowed to get into the control panel.

I have a third party app called scriptlogic desktop authority that allows me to just auto run things as an admin. The script runs wonderfully when you are allowed to run the exe and do so from the account needing the settings. The problem is that when run as a student the changes do not seem to take effect (I could swear it did once, but that's probably me not remembering I've changed it, or some such).

Now changing these settings changes a regkey from 0 or 1 into 2 as a byproduct of the change (not the script). To troubleshoot the problem I made the script write to a text file the key before and after the change, and it ends on a 2. I then look at the key manually and it is still a 0. The script is running (or else no text would show in the text file).

So my assumption is that by running as an administrator, it must be making the changes for the admin account and not the logged on user.

My brain is mush at this point. Any ideas? How do I verify that I'm correct about the "changing different user's visuals" theory? Any other ideas of how to solve the riddle?

Edited by mikethetechguy

Share this post


Link to post
Share on other sites
Jos

You are probably changing something in the HKCU hive?

You could make the change in all User hives by loopibg through the available User hives.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Juvigy

How do you change the visual settings. Please post the script.

Share this post


Link to post
Share on other sites
mikethetechguy

As I said in my initial post, changing the registry will NOT change the XP visuals. It will change the selected options, but oddly enough not apply them.

I've kept my filewriteline stuff to demo my debugging.

$totalmem = MemGetStats()

;RAM in MB to compare to

$memthreshold = 510

$regkey= 2

FileOpen("C:\viztest.txt", 1)

FileWriteLine("C:\viztest.txt", "Script made it to before the IF statements! " & "The time is " & @hour & ":" & @min & ":" & @sec & " and the key is " & $regkey & " memory is " & $totalmem[1]/1024)

;if low mem, go on to read registry

If (($totalmem[1]/1024) < $memthreshold) then $regkey = RegRead("HKEY_Current_User\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects", "VisualFXSetting")

;if low mem and registry was read but not desired(2), go on to Then

If ((($totalmem[1]/1024) < $memthreshold) AND $regkey <> 2) Then

;Opens the System Properties window and chooses the 3rd tab

;same as right click --> properties from My Computer.

Run("control sysdm.cpl,,3")

;click on the Performance Options "Settings" button

WinWaitActive("System Properties")

ControlClick("System Properties","","[CLASS:Button;INSTANCE:2]", "left")

;click on "Adjust for best performance"

WinWaitActive("Performance Options")

ControlClick("Performance Options","","[CLASS:Button;INSTANCE:3]", "left")

;click on "OK" button

WinWaitActive("Performance Options")

ControlClick("","","Button5")

WinWaitNotActive("Performance Options")

;click on "OK" button

WinActivate("System Properties")

WinWaitActive("System Properties")

ControlClick("System Properties","","[CLASS:Button;INSTANCE:9]", "left")

EndIf

;Debug function

FileWriteLine("C:\viztest.txt", "End of Script! " & "The time is " & @hour & ":" & @min & ":" & @sec & " and the key is " & $regkey)

FileClose("C:\viztest.txt")

Edited by mikethetechguy

Share this post


Link to post
Share on other sites
Billr

This is the line I use to update settings:

$ret = DllCall('user32.dll', 'long', 'SendNotifyMessageA', 'long', $HWND_BROADCAST, 'long', $WM_SETTINGCHANGE, 'long', 0, 'long', 0)

Share this post


Link to post
Share on other sites
mikethetechguy

This is the line I use to update settings:

$ret = DllCall('user32.dll', 'long', 'SendNotifyMessageA', 'long', $HWND_BROADCAST, 'long', $WM_SETTINGCHANGE, 'long', 0, 'long', 0)

Hey Bill.

So this is to refresh the settings defined in the registry for xp visuals?

What are the $hwnd_broadcast and $wm_settingchange variables? Is there something I need to import to use these?

I'm a 3 week user of autoIT, so I'm confused on the ins and outs at this point.

Share this post


Link to post
Share on other sites
Billr

This line tells Windows that setting changes were made and it needs to refresh the desktop. I have used this for updating colors, policy changes, and other settings.

I believe that the variables are in the standard includes, but just in case you are not using the includes:

$HWND_BROADCAST = 0xFFFF

$WM_SETTINGCHANGE = 0x1A

Share this post


Link to post
Share on other sites
mikethetechguy

This line tells Windows that setting changes were made and it needs to refresh the desktop. I have used this for updating colors, policy changes, and other settings.

I believe that the variables are in the standard includes, but just in case you are not using the includes:

$HWND_BROADCAST = 0xFFFF

$WM_SETTINGCHANGE = 0x1A

I don't know what includes are, if that gives any indication. This doesn't force that setting to take effect sadly. I do see that things sort of flash for a second though.

I used as a test

"Opt('MustDeclareVars', 0)

Local $ret

$HWND_BROADCAST = 0xFFFF

$WM_SETTINGCHANGE = 0x1A

$ret = DllCall('user32.dll', 'long', 'SendNotifyMessageA', 'long', $HWND_BROADCAST, 'long', $WM_SETTINGCHANGE, 'long', 0, 'long', 0)"

Share this post


Link to post
Share on other sites
mikethetechguy

The key is

HKEY_Current_User\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects", "VisualFXSetting

the "best performance" key is 2. This is the one I'd like to be able to change and then apply.

Share this post


Link to post
Share on other sites
Billr

Another option (and usually the preferred way) if you are on a domain is to use policies to make the changes that you want.

Share this post


Link to post
Share on other sites
mikethetechguy

amen, the problem being that I haven't found a way to, just a bunch of people throwing up their hands and saying it isn't possible. The frustrating part is that I've found a way to do it through the Windows GUI but am unable to implement it due to user restrictions and a weird issue where it seems to be affecting the "run as" user when using "run as" and not the currently logged in user.

Anyone aware of a way in active directory to allow a user to run just a certain exe and not any others?

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×