| 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" '...minimizeWindows 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 SP3How 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 ----------------------------------------------- |