5.1 anomaly: Run As User logged into console
I am very thankful for the new "Run As User" option on scripts; I don't know what I would do without it. I have Kscripts when this setting is working, but I also have a Kscript where it's not working, and I don't know why.
This Kscript has two tasks: run a VBscript that makes a change under HKEY_CURRENT_USER (I picked up this script from the Internet, but it's very simple), then create a different registry value under HKEY_CURRENT_USER to indicate the script was run once. The second task is working (on error is set to continue), but the first task, the VBscript, is not working.
If any of you have any thoughts on requirements for, or complications with, the new Run As User setting, I'd love to hear about it.
When I run the VBscript interactively, it works correctly, so I don't think there's anything wrong with the VBscript itself. But I include it here for the curious: Sande
[font="courier new"]'Set Compact Check Count to 0 -- per user
'© Kelly's Korner - 4/05
Dim myShell, OE_ID, OE_ID2, OE_SA_Key, p, p1, t, p2, p3, n, itemtype
Set myShell = CreateObject("WScript.Shell")
On Error Resume Next
t = "5.0\"
OE_ID = "HKEY_CURRENT_USER\Identities\Default User ID"
OE_ID2 = myShell.RegRead(OE_ID)
OE_SA_Key = "HKEY_CURRENT_USER\Identities\" & OE_ID2 & "\Software\Microsoft\Outlook Express\" & t & "Compact Check Count"
p = "HKCU\Identities\" & OE_ID2 & "\Software\Microsoft\Outlook Express\" & t
p = p & "Compact Check Count"
itemtype = "REG_DWORD"
n = "0"
myshell.RegWrite p, n, itemtype
p3 = "HKCU\Identities\" & OE_ID2 & "\Software\Microsoft\Outlook Express\" & t & "Dont Show Dialogs\"
p3 = p3 & "Compact Do not Ask Again"
itemtype = "REG_DWORD"
n = "1"
myshell.RegWrite p3, n, itemtype
This Kscript has two tasks: run a VBscript that makes a change under HKEY_CURRENT_USER (I picked up this script from the Internet, but it's very simple), then create a different registry value under HKEY_CURRENT_USER to indicate the script was run once. The second task is working (on error is set to continue), but the first task, the VBscript, is not working.
If any of you have any thoughts on requirements for, or complications with, the new Run As User setting, I'd love to hear about it.
When I run the VBscript interactively, it works correctly, so I don't think there's anything wrong with the VBscript itself. But I include it here for the curious: Sande
[font="courier new"]
'© Kelly's Korner - 4/05
Dim myShell, OE_ID, OE_ID2, OE_SA_Key, p, p1, t, p2, p3, n, itemtype
Set myShell = CreateObject("WScript.Shell")
On Error Resume Next
t = "5.0\"
OE_ID = "HKEY_CURRENT_USER\Identities\Default User ID"
OE_ID2 = myShell.RegRead(OE_ID)
OE_SA_Key = "HKEY_CURRENT_USER\Identities\" & OE_ID2 & "\Software\Microsoft\Outlook Express\" & t & "Compact Check Count"
p = "HKCU\Identities\" & OE_ID2 & "\Software\Microsoft\Outlook Express\" & t
p = p & "Compact Check Count"
itemtype = "REG_DWORD"
n = "0"
myshell.RegWrite p, n, itemtype
p3 = "HKCU\Identities\" & OE_ID2 & "\Software\Microsoft\Outlook Express\" & t & "Dont Show Dialogs\"
p3 = p3 & "Compact Do not Ask Again"
itemtype = "REG_DWORD"
n = "1"
myshell.RegWrite p3, n, itemtype
0 Comments
[ + ] Show comments
Answers (9)
Please log in to answer
Posted by:
GillySpy
14 years ago
Posted by:
airwolf
14 years ago
Posted by:
snissen
14 years ago
Posted by:
airwolf
14 years ago
Posted by:
snissen
14 years ago
Posted by:
snissen
14 years ago
Now I'm really confused. I have another Online Kscript whose only purpose is to display some standard Windows environment variables. I have it set to "Run as User logged into console", leaving "Allow Run While Logged Off" disabled.
I use two ways to display the %APPDATA% and %USERPROFILE% environment variables:
1. Launch "$(KBOX_SYS_DIR)\cmd.exe" with params "/c echo USERPROFILE is: %USERPROFILE%".
2. Run a batch file with the equivalent command: echo USERPROFILE is: %USERPROFILE%.
So why do these results agree that USERPROFILE is C:\Documents and Settings\LocalService, and that APPDATA is undefined? In other words, why is this running in the LocalService context, instead of the user context? Do Kscripts never run in the user context, only Online shell scripts do?
I use two ways to display the %APPDATA% and %USERPROFILE% environment variables:
1. Launch "$(KBOX_SYS_DIR)\cmd.exe" with params "/c echo USERPROFILE is: %USERPROFILE%".
2. Run a batch file with the equivalent command: echo USERPROFILE is: %USERPROFILE%.
So why do these results agree that USERPROFILE is C:\Documents and Settings\LocalService, and that APPDATA is undefined? In other words, why is this running in the LocalService context, instead of the user context? Do Kscripts never run in the user context, only Online shell scripts do?
Posted by:
snissen
14 years ago
It looks like I can get into this LocalService state several different ways, depending on a combination of conditions:
1. Having just uninstalled/reinstalled any version of the KBOX Agent and not having rebooted yet. -or-
2. Using the 5.0 agent, logged in with any account that was not initiated from a shutdown or restart (i.e., one user logs in then logs out, the second user logs in and sees LocalService; Fast User Switching is disabled).
With the 5.1 agent, I can still get into this LocalService context (I'm not sure how), but it seems to happen much less often. So I think I'm going to have to check the context in scripts before I make any changes that depend on HKEY_CURRENT_USER or %APPDATA% being defined. What a pain. Sande
1. Having just uninstalled/reinstalled any version of the KBOX Agent and not having rebooted yet. -or-
2. Using the 5.0 agent, logged in with any account that was not initiated from a shutdown or restart (i.e., one user logs in then logs out, the second user logs in and sees LocalService; Fast User Switching is disabled).
With the 5.1 agent, I can still get into this LocalService context (I'm not sure how), but it seems to happen much less often. So I think I'm going to have to check the context in scripts before I make any changes that depend on HKEY_CURRENT_USER or %APPDATA% being defined. What a pain. Sande
Posted by:
GillySpy
14 years ago
Posted by:
snissen
14 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.