Vbscript Error: Illegal Assignment: 'shell' Using Appactivat

December 24, 2011 at 04:48:08
Specs: Windows XP, 2.0 GHz, 512MB
Vbscript Error: Illegal Assignment: 'shell' Using AppactivateMy OS is Windows XP Pro SP3

How can I combine these two VBScripts, StartYahoo.vbs and MinYahoo.vbs into one VBScript,
StartYahooMin.vbs without getting an "Illegal Assignment 'shell " Error from the line below?

set shell = createobject("wscript.shell"

These two scripts when run as separate vbs files work fine .,

StartYahoo.vbs:

'START Yahoo Messenger
	sub shell(cmd)
	dim objShell
	Set objShell = WScript.CreateObject( "WScript.Shell" )
	objShell.Run(cmd)
	Set objShell = Nothing
	end sub
 
shell """C:\Program Files\Yahoo!\Messenger\YahooMessenger.exe"""

MinYahoo.vbs:

Set WshShell = WScript.CreateObject("WScript.Shell")
	WshShell.popup "MINIMIZE Yahoo Messenger", 5
 
'MINIMIZE Yahoo Messenger
set shell = createobject("wscript.shell")
shell.AppActivate "Yahoo! Messenger"
 
wscript.sleep 1000
success = shell.appactivate("Yahoo! Messenger")
if success then shell.sendkeys "% r"  '...restore
 
wscript.sleep 1000
success = shell.appactivate("Yahoo! Messenger")
if success then shell.sendkeys "% n"  '...minimize
 
wscript.sleep 1000
success = shell.appactivate("Yahoo! Messenger")
if success then shell.sendkeys "% n"  '...minimize


But produces an error when combined into one vbs file,

StartYahooMin.vbs :

'START Yahoo Messenger
	sub shell(cmd)
	dim objShell
	Set objShell = WScript.CreateObject( "WScript.Shell" )
	objShell.Run(cmd)
	Set objShell = Nothing
	end sub
 
shell """C:\Program Files\Yahoo!\Messenger\YahooMessenger.exe"""
 
wscript.sleep 25000
 
Set WshShell = WScript.CreateObject("WScript.Shell")
	WshShell.popup "MINIMIZE Yahoo Messenger", 5
 
'MINIMIZE Yahoo Messenger
set shell = createobject("wscript.shell")
shell.AppActivate "Yahoo! Messenger"
 
wscript.sleep 1000
success = shell.appactivate("Yahoo! Messenger")
if success then shell.sendkeys "% r"  '...restore
 
wscript.sleep 1000
success = shell.appactivate("Yahoo! Messenger")
if success then shell.sendkeys "% n"  '...minimize
 
wscript.sleep 1000
success = shell.appactivate("Yahoo! Messenger")
if success then shell.sendkeys "% n"  '...minimize

Windows Script Host Error:
-----------------------------
Script: C:\Program Files\Yahoo!\Messenger\StartYahooMin.vbs
Line: 17
Char: 1
Error: Illegal assignment: 'shell'
Code: 800A01F5
Source: Microsoft VBScript runtime error

Thank you and I will appreciate your help.

NOTE:
I realize I can just call "StartYahoo.vbs" from code added to the beginning of
MinYahoo and that is what I currently do using this:

Set WSHShell = CreateObject("WScript.Shell")
WSHShell.Run """C:\Program Files\Yahoo!\Messenger\Y\StartYahooVBS.vbs""", True




My OS is Windows XP Pro SP3

How can I combine these two VBScripts,

and MinYahoo.vbs into one VBScript, 
StartYahooMin.vbs without getting an "Illegal Assignment 'shell" Error from the line below?

--------------
set shell = createobject("wscript.shell"[/code]

These two scripts when run as separate vbs files work fine.,

StartYahoo.vbs:
--------------
'START Yahoo Messenger
sub shell(cmd)
dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run(cmd)
Set objShell = Nothing
end sub

shell """C:\Program Files\Yahoo!\Messenger\YahooMessenger.exe"""
--------------------------

MinYahoo.vbs:
--------------
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.popup "MINIMIZE Yahoo Messenger", 5

'MINIMIZE Yahoo Messenger
set shell = createobject("wscript.shell")
shell.AppActivate "Yahoo! Messenger"

wscript.sleep 1000
success = shell.appactivate("Yahoo! Messenger")
if success then shell.sendkeys "% r" '...restore

wscript.sleep 1000
success = shell.appactivate("Yahoo! Messenger")
if success then shell.sendkeys "% n" '...minimize

wscript.sleep 1000
success = shell.appactivate("Yahoo! Messenger")
if success then shell.sendkeys "% n" '...minimize
-----------------------------------------------

But produces an error when combined into one vbs file,

StartYahooMin.vbs:
--------------
'START Yahoo Messenger
sub shell(cmd)
dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run(cmd)
Set objShell = Nothing
end sub

shell """C:\Program Files\Yahoo!\Messenger\YahooMessenger.exe"""

wscript.sleep 25000

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.popup "MINIMIZE Yahoo Messenger", 5

'MINIMIZE Yahoo Messenger
set shell = createobject("wscript.shell")
shell.AppActivate "Yahoo! Messenger"

wscript.sleep 1000
success = shell.appactivate("Yahoo! Messenger")
if success then shell.sendkeys "% r" '...restore

wscript.sleep 1000
success = shell.appactivate("Yahoo! Messenger")
if success then shell.sendkeys "% n" '...minimize

wscript.sleep 1000
success = shell.appactivate("Yahoo! Messenger")
if success then shell.sendkeys "% n" '...minimize
-----------------------------------------------

Windows Script Host Error:
-----------------------------
Script: C:\Program Files\Yahoo!\Messenger\StartYahooMin.vbs
Line: 17
Char: 1
Error: Illegal assignment: 'shell'
Code: 800A01F5
Source: Microsoft VBScript runtime error

Thank you and I will appreciate your help.

NOTE:
I realize I can just call "StartYahoo.vbs" from code added to the beginning of
MinYahoo and that is what I currently do using this:

-----------------------------------------------
Set WSHShell = CreateObject("WScript.Shell")
WSHShell.Run """C:\Program Files\Yahoo!\Messenger\Y\StartYahooVBS.vbs""", True
-----------------------------------------------


See More: Vbscript Error: Illegal Assignment: shell Using Appactivat

Report •


#1
December 24, 2011 at 06:57:10
I was given this working code by "PHV" who posted the complete
code with his modifications here:
http://www.tek-tips.com/viewthread....

'START Yahoo Messenger
sub shell(cmd)
dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run(cmd)
Set objShell = Nothing
end sub

shell """C:\Program Files\Yahoo!\Messenger\YahooMessenger.exe"""

wscript.sleep 25000

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.popup "MINIMIZE Yahoo Messenger", 5

'MINIMIZE Yahoo Messenger
'''''set shell = createobject("wscript.shell")
WshShell.AppActivate "Yahoo! Messenger"

wscript.sleep 1000
success = WshShell.appactivate("Yahoo! Messenger")
if success then WshShell.sendkeys "% r" '...restore

wscript.sleep 1000
success = WshShell.appactivate("Yahoo! Messenger")
if success then WshShell.sendkeys "% n" '...minimize

wscript.sleep 1000
success = WshShell.appactivate("Yahoo! Messenger")
if success then WshShell.sendkeys "% n" '...minimize


Report •

#2
December 31, 2011 at 06:11:36
The answer I posted above is the BEST ANSWER I don't see a "Select as Best Answer" icon anywhere.

Report •

Related Solutions


Ask Question