Thanks, but this doesn't solve my problem.
I need to add a registry key on loads of 2000/XP machines.
There is not a 'Run As' on the list of options for .reg or .bat files, but even if there was, it wouldn't help because the setting isn't saved for every execution.
Somebody out there must work in an environment where the users do not have admin rights on the PC's they use (Colleges / Universities), where fixes, updates need to be added.
I've thought about using WMI, but this isn't any good because we are running unix and netware servers, not Microsoft, only the clients are microsoft.
The best solution I have found so far is to use the shell and sendkeys command in vbs to automate the process of using the runas at the command prompt, but this is rather messy, crude and prone to failure because if this is done at the login script, the PC may not be initialised fully enough to open a command prompt window and run through the process of running an application.
This is the wacky bit of code that I am using but I can't really implement it because of the above issues.
cmdpath = "\System32\cmd.exe"
adminuser = "administrator"
password = "the-pwd-here"
exefile = "EXE FILE HERE"
CRLF = chr(10) & chr(13)
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("PROCESS")
windir = WshSysEnv("WINDIR")
cmdpath = windir & cmdpath
computer = WshNetwork.ComputerName
'domain = WshNetwork.UserDomain
directory = get_current_directory
fullpath = directory & exefile
account = computer & "\" & adminuser
WshShell.Run cmdpath
WScript.Sleep 150
WshShell.AppActivate cmdpath
WScript.Sleep 150
WshShell.SendKeys "runas /user:" & account & " " & chr(34) & fullpath & chr(34) & CRLF
WScript.Sleep 230
WshShell.SendKeys password & CRLF
WScript.Sleep 70
WshShell.SendKeys "exit" & CRLF
wscript.quit
Function get_current_directory()
directory = WScript.ScriptFullName
pos = instrrev(directory,"\",-1)
final_directory = left(directory,pos)
get_current_directory = final_directory
Set WshShell = Nothing
End Function
.............................
Any help would be a godsend!!
xscript