Greeting
A.Gallus
--
Regards
Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk
Keeping it FREE!
"Axel Gallus" <uh...@rz.uni-karlsruhe.de> wrote in message
news:ee0slr$ktb$1...@news2.rz.uni-karlsruhe.de...
You mean like this?
WshShell.Run "%windir%\System32\RUNDLL32.EXE
USER32.DLL,UpdatePerUserSystemParameters", 1, False
A.Gallus
"Steven Burn" <some...@in-time.invalid> schrieb im Newsbeitrag
news:uNf4wtR1...@TK2MSFTNGP04.phx.gbl...
That function is to reset the local portion of the registry. Sounds
like you may be trying to update something or force someones desktop to
be what you want it to be remotely. he he. It is possible, but not
easy. A native way that I've found is to have your script create a
script with the code you want run, copy it to the remote computer, then
use the scheduler service to have it run interactively with the remote
user's computer. This way it runs under system, but has access to the
user's desktop.
I use something similar to this to ensure that the script runs a minute
in the future on the remote machine.
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM
Win32_UTCTime", "WQL", _
wbemFlagReturnImmediately +
wbemFlagForwardOnly)
For Each objItem In colItems
strHour = objItem.Hour
if strHour < 10 Then
strHour = "0" & strHour
End If
Wscript.echo objItem.Minute & ":" & objItem.Second
strMinute = objItem.Minute
strMinute = strMinute + 1
if strMinute < 10 Then
strMinute = "0" & strMinute
End If
strSecond = objItem.Second
if strSecond < 10 Then
strSecond = "0" & strSecond
End If
strDayOfWeek objItem.DayOfWeek
strUTCDate = "********" & strHour & strMinute & strSecond & "." &
"000000-000"
Next
Wscript.echo strUTCDate
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
errJobCreated = objNewJob.Create _
("wscript.exe C:\temp\test.vbs", strUTCDate, _
False, strDayOfWeek, , True, JobID)
I have a script that changes remote desktops backgrounds using this
method. It is a lot of fun to use on co-workers, but use with caution
if this is your intent.
Enjoy.
Michael Reese
When I am referring to "call api's" below, that means calling the
system functions embedded in the system dll's -- such as user32.
If you are courageous enough, or foolhardy enough, to call api's
from script, then you have two options.
Option 1: use a third-party control (such as DynaWrap), or one that
you write yourself.
This code will "find" the window you want, and return a handle,
using dynawrap:
-- <snip> --
Function FindWindow(sClass, sCaption)
Set oDW = nothing ' clear any previous instance
Set oDW = CreateObject("DynamicWrapper") ' start over...
' register (declare) this flavor of api call...
oDW.Register "USER32.DLL", "FindWindowA", "i=ss", "f=s", "r=h"
FindWindow = oDW.FindWindowA(CStr(sClass), CStr(sCaption))
End Function
-- </snip> --
Option 2: use "autoitX", another third-party control. AutoitX
does not permit calling api's directly but it will do what you want.
That's because certain commonly used api's are built into the
autoitX control as methods. For example, to get back the handle
of a specified window. See the "WinGetHandle" function.
http://www.autoitscript.com/autoit3/
cheers, jw
____________________________________________________________
You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)
--- <DynaWrap Boilerplate> ---
It is possible to declare-and-call an api from script,
but you must use a third-party control to do so,
or else write one yourself.
It has already been correctly pointed out that there
is no api-capability in "pure" script.
If you are willing to use a third-party control, then
one such control, called "DynaWrap", can be found on
Guenter Born's website (note: Guenter refers to it as
"DynaCall"). Here is the link to it:
http://people.freenet.de/gborn/WSHBazaar/WSHDynaCall.htm
On that page you will find a download for the control,
plus some code samples.
Note: you may find additional sample code by searching
the archives of the wsh and vbscript ng's.
Note also: DynaWrap does have its limitations. There are
certain things it can't do. For example, you can't call
api's which take typedefs as parameters, and you can't call
api's "by ordinal". But it will work for most of the
"usual suspects".
And finally, DynaWrap doesn't work entirely as advertised.
For example, it is supposed to allow for the declaration of
several api definitions in one instance of itself. I could
never get that to work (in win9x). You will need a new
instance of DynaWrap for every api, or else re-instantiate
the object for every api. Someday I'm going to learn enough
c++ to fix that...
--- </DynaWrap Boilerplate> ---