#135281 - 2005-03-11 12:50 PM
Maximize an application (access)
|
semprini
Fresh Scripter
Registered: 2005-03-11
Posts: 7
|
Hi all,
I'm trying to make a simple script to open Microsoft Access and a database file. I had used just a batch file, with the following command:
"C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" C:\path\filename.mdb
This almost worked. It opens the application, but the command window remains open until you close Access, then the batch file carries on and finishes. I didn't want to have a batch file/command window left open the whole time.
So, I thought I would just do a simple Kix script to solve the problem:
RUN "C:\Program Files\Microsoft Office\Office\MSACCESS.EXE C:\path\filename.mdb"
The script almost works fine. It runs through the script and closes itself, which is great. But it always opens Access in a restored size, not maximized. I've tried opening the database manually, maximizing it, then opening it again manually and it stays maximized. But as soon as I run the script, it opens restored again. This is a pain.
I've searched through a number of posts on here to do with maximizing, and found ways to maximize the kix console window and other applications, but there doesn't appear to be an answer.
I've tried using the SHELL command, as suggested in an earlier post:
SHELL "START /MAX MSACCESS.EXE"
Which didn't open access. So I tried:
SHELL "c:\program files\microsoft office\office\msaccess.exe"
Which opened Access, but it didn't recognise the START /MAX command. And, by using the SHELL command, the script acts like a batch file so the console window stays open until Access has been closed.
So, i'm hoping you guys might know a way to force Access to start maximized. Preferably something to stick on the end of this semi-working Kix command:
RUN "C:\Program Files\Microsoft Office\Office\MSACCESS.EXE C:\path\filename.mdb"
Any help would be very much appreciated.
Thanks.
|
|
Top
|
|
|
|
#135282 - 2005-03-11 01:20 PM
Re: Maximize an application (access)
|
desquinn
Fresh Scripter
Registered: 2005-02-23
Posts: 16
|
why not do the batch file method but use start /max
|
|
Top
|
|
|
|
#135283 - 2005-03-11 01:57 PM
Re: Maximize an application (access)
|
semprini
Fresh Scripter
Registered: 2005-03-11
Posts: 7
|
Good suggestion Desquinn, thanks. That ALMOST worked.
It fixes the problem of the batch file remaining open. It runs, opens Access and the file, and closes the console batch window.
However... the full command I need to run looks up an access security file too.
START /MAX "C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" C:\path\filename.mde /WRKGRP T:\security.mda
When I run the kix or batch file without START /MAX, it opens the file fine. But when I add the START /MAX command, it opens access and starts opening the file, then gives me the error: "Your User Type is not setup correctly, Please contact system administrator".
T:\ is a mapped network drive by the way. But thats not an issue I don't think, as the file works fine without START /MAX.
Any ideas?
|
|
Top
|
|
|
|
#135285 - 2005-03-11 03:18 PM
Re: Maximize an application (access)
|
semprini
Fresh Scripter
Registered: 2005-03-11
Posts: 7
|
Quote:
Lets see all your code for the Kixtart version that almost works.
It really is just the one line:
RUN "C:\Program Files\Microsoft Office\Office\MSACCESS.EXE C:\path\filename.mde /wrkgrp T:\security.mda"
It opens the file and security thing fine, it's just the window size that's a bit of a problem.
|
|
Top
|
|
|
|
#135289 - 2005-03-11 04:32 PM
Re: Maximize an application (access)
|
semprini
Fresh Scripter
Registered: 2005-03-11
Posts: 7
|
Thanks for the suggestions guys.
That code gave an error because the path with "Program Files" needs to be contained within inverted commars. But even when adjusted to this:
RUN '%COMSPEC% /C START /MAX "C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" C:\TMSSql\TMSSQLFEWG.mde /wrkgrp T:\tmssys.mda'
It still brings up the error where it has not read the security file correctly.
I've also tried other variations of apostrophies and inverted commars, such as these:
RUN '%COMSPEC% /C START /MAX "C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" C:\TMSSql\TMSSQLFEWG.mde /wrkgrp "T:\tmssys.mda"'
RUN '%COMSPEC% /C START /MAX "C:\Program Files\Microsoft Office\Office\MSACCESS.EXE"' "C:\TMSSql\TMSSQLFEWG.mde" /wrkgrp "T:\tmssys.mda"
RUN '%COMSPEC% /C START /MAX "C:\Program Files\Microsoft Office\Office\MSACCESS.EXE C:\TMSSql\TMSSQLFEWG.mde" /wrkgrp "T:\tmssys.mda"'
All resulted in either the same error message, or stopping at a console window, not even loading up access.
|
|
Top
|
|
|
|
#135290 - 2005-03-11 04:53 PM
Re: Maximize an application (access)
|
Allen
KiX Supporter
   
Registered: 2003-04-19
Posts: 4574
Loc: USA
|
I tested this just using an mdb file and it worked. You might give it a shot with your parameters. Details of wshshortcut can be found here.
Code:
break on
$=setoption("WRAPATEOL","ON")
$=wshshortcut("%temp%\Access",@scriptdir + "\DB1.mdb",,,,3)
run '%comspec% /c "%temp%\access.lnk"'
function wshShortCut($shortcutname,$targetpath,optional $arguments, optional $startdir, optional $iconpath, optional $style,optional $description)
dim $shell, $desktop, $shortcut, $index, $iconinfo, $iconindex,$scdir
$wshshortcut=1
$shell = createobject("wscript.shell")
if $shell
if ucase(right($shortcutname,4))=".URL" or ucase(right($shortcutname,4))=".LNK"
;do nothing
else
if ucase(left($targetpath,5))="HTTP:" or ucase(left($targetpath,6))="HTTPS:" or ucase(left($targetpath,4))="FTP:"
$shortcutname=$shortcutname + ".url"
else
$shortcutname=$shortcutname + ".lnk"
endif
endif
if instr($shortcutname,".lnk") and not exist($targetpath)
exit 2
endif
if instr($shortcutname,"\")=0
$Desktop = $shell.SpecialFolders("Desktop")
$shortcutname=$desktop + "\" + $shortcutname
else
$scdir=substr($shortcutname,1,instrrev($shortcutname,"\"))
if not exist($scdir)
md $scdir
if @error
exit @error
endif
endif
endif
$shortcut = $shell.createshortcut($shortcutname)
if $shortcut
$shortcut.targetpath = $targetpath
if $iconpath and instrrev($shortcutname,".lnk")
$shortcut.iconlocation = $iconpath
endif
if $arguments
$shortcut.arguments = $arguments
endif
if $startdir
$shortcut.workingdirectory = $startdir
endif
if $style
$shortcut.windowstyle = $style
endif
If $description and instrrev($shortcutname,".lnk")
$shortcut.description = $description
EndIf
$shortcut.save
if @error
exit @error
endif
if instrrev($shortcutname,".url") and $iconpath
$index=instrrev($iconpath,",")
if $index=0
$iconindex=0
else
$iconindex=split($iconpath,",")[1]
$iconpath=split($iconpath,",")[0]
endif
$=writeprofilestring($shortcutname,"InternetShortcut","IconFile",$iconpath)
$=writeprofilestring($shortcutname,"InternetShortcut","IconIndex",$iconindex)
endif
$shortcut = 0
$wshshortcut=0
else
exit @error
endif
else
exit @error
endif
endfunction
_________________________
(... better days ahead)
|
|
Top
|
|
|
|
#135294 - 2005-03-12 11:25 PM
Re: Maximize an application (access)
|
desquinn
Fresh Scripter
Registered: 2005-02-23
Posts: 16
|
try either of these
Code:
RUN '%COMSPEC% /C START /MAX ""C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" C:\TMSSql\TMSSQLFEWG.mde /wrkgrp T:\tmssys.mda"' RUN '%COMSPEC% /C START /MAX C:\Progra~1\Micros~1\Office\MSACCESS.EXE" C:\TMSSql\TMSSQLFEWG.mde /wrkgrp T:\tmssys.mda'
|
|
Top
|
|
|
|
#135296 - 2005-03-14 01:54 PM
Re: Maximize an application (access)
|
semprini
Fresh Scripter
Registered: 2005-03-11
Posts: 7
|
Quote:
I believe that when you have a string with spaces wrapped in quotes behind the "start" command "start" wants to interpret the first set of quotes as a title for the window. Therefore you need something along these lines: mole
Hats off to you, Mole. Thank you, that worked a treat, even with the extra /wrkgrp parameters on the end.
shell '%COMSPEC% /c start /max " " "c:\program files\microsoft office\office\msaccess.exe" C:\pathname\filename.mde /wrkgrp T:\security.mda'
Thanks for all of the suggestions and support from all of you.
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 2375 anonymous users online.
|
|
|