Hi Karen,
You can actually accomplish most of this by just passing commands into the
shell.
E.g.:
Dim x As Integer
x = Shell("Control Panel", vbNormalNoFocus)
or
x = Shell("\\server\share\batchfile.bat", vbNormalNoFocus)
Again, there are a few options for the window handling:
vbHide
Invisible new window and does not appear in the task bar - rarely used.
vbMaximizedFocus
The new window is maximised and gets focus.
vbMinimizedFocus
The new window is minimised and gets focus - this is the default.
vbMinimizedNoFocus
The new window is minimised and does not get focus.
vbNormalFocus
The new window starts normally and gets focus.
vbNormalNoFocus
The window starts at normal size but does not get focus.
The shell command is doesn't work with all of them, but you can also point
it to .bat files, which you could script and include on a server - see
above.
I don't know why the cpl applets don't work properly, because they DO work
from a command prompt. You may need to just script it into a batch file and
use
x = Shell("c:\test.bat", vbhide)
This worked fine when I had a batch file that just said "desk.cpl".
Hope this helps - I'll be watching this thread, should you require any
further assistance.
Warm regards
Sunil Jayakumar
Karen27 said:
Hi Sunil,
Thanks for your help.
You're right I'm trying to script this into a vbs or wsh file, so when
the users boot their system it will ask them if they wish to execute
them or not.
Here's a snippet of the code:
Set WshOption = WScript.CreateObject("WScript.Shell")
Response = MsgBox("Do you wish to execute the 'Desktop properties'?",
vbYesNo + vbQuestion)
If Response = vbYes Then
MsgBox "The 'Desktop properties' will now be executed", vbOKOnly +
vbInformation WshOption.Run "desk.cpl", 1
End If
Response = MsgBox("Do you wish to execute the 'Date/Time property
sheet'?", vbYesNo + vbQuestion)
If Response = vbYes Then
MsgBox "The 'Date/Time property sheet' will now be executed",
vbOKOnly + vbInformation
WshOption.Run "timedate.cpl", 1
End If
As you see above, I did try using those files you mentioned for the
desktop and the date/time, but the message I get when I try to execute
the script is: "No application is associated with the specified file".
However, when I located and double-clicked the file - they did run
those dialogs fine then - so they are indeed the correct files, it must
be my coding.
By the way the shutdown file you said works fine in the code - it just
seems to be the cpl files that don't seem to work.
Thanks again for your help Sunil
Regards
Karen
www.ayyoo.com/credit-cards.html