Page 1 of 1 1
Topic Options
#135281 - 2005-03-11 12:50 PM Maximize an application (access)
semprini Offline
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 Offline
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 Offline
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
#135284 - 2005-03-11 02:32 PM Re: Maximize an application (access)
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Lets see all your code for the Kixtart version that almost works.
Top
#135285 - 2005-03-11 03:18 PM Re: Maximize an application (access)
semprini Offline
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
#135286 - 2005-03-11 04:07 PM Re: Maximize an application (access)
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
what about ...

Code:

RUN "%ComSpec% /c start /max C:\Program Files\Microsoft Office\Office\MSACCESS.EXE C:\path\filename.mde /wrkgrp T:\security.mda"



can't test currently .. sorry
_________________________



Top
#135287 - 2005-03-11 04:08 PM Re: Maximize an application (access)
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
How about something like this:

RUN '%COMSPEC% /C START /MAX "c:\program files\microsoft office\office\msaccess.exe" C:\path\filename.mde /WRKGRP T:\security.mda'


Top
#135288 - 2005-03-11 04:14 PM Re: Maximize an application (access)
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
I think me and cappy been working at this board too long.
Top
#135289 - 2005-03-11 04:32 PM Re: Maximize an application (access)
semprini Offline
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 Administrator Offline
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
#135291 - 2005-03-11 05:04 PM Re: Maximize an application (access)
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
Your wshshortcut line may look like this:

Code:
 

$=wshshortcut("%temp%\Access","C:\TMSSql\TMSSQLFEWG.mde",' /wrkgrp "T:\tmssys.mda"',,,3)




Edited by Allen (2005-03-11 05:49 PM)
_________________________
(... better days ahead)

Top
#135292 - 2005-03-11 05:40 PM Re: Maximize an application (access)
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I keep seeing mdE instead of mdB.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#135293 - 2005-03-11 05:54 PM Re: Maximize an application (access)
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
Double Clicking an mdE file will start Access, Right?
_________________________
(... better days ahead)

Top
#135294 - 2005-03-12 11:25 PM Re: Maximize an application (access)
desquinn Offline
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
#135295 - 2005-03-14 08:35 AM Re: Maximize an application (access)
mole Offline
Getting the hang of it

Registered: 2003-01-01
Posts: 81
Loc: Indian Head, Maryland, USA
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:

Code:

shell '%COMSPEC% /c start /max " " "c:\program files\microsoft office\office\msaccess.exe" c:\myfile\whatever.mdb'



I'm not familiar with the other parameters being passed, but you should get the idea from the example above.

mole
_________________________
mole

Who is John Galt?

Top
#135296 - 2005-03-14 01:54 PM Re: Maximize an application (access)
semprini Offline
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
#135297 - 2005-03-14 02:00 PM Re: Maximize an application (access)
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Good one mole man !!!
Top
#135298 - 2005-03-14 02:03 PM Re: Maximize an application (access)
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Code:

Shawn
Moderator


Reged: 17/08/1999
Posts: 6666
Loc: Toronto, Ontario, Canada

_________________________
!

download KiXnet

Top
#135299 - 2005-03-14 02:19 PM Re: Maximize an application (access)
mole Offline
Getting the hang of it

Registered: 2003-01-01
Posts: 81
Loc: Indian Head, Maryland, USA
Glad to help get you going.

mole
_________________________
mole

Who is John Galt?

Top
#135300 - 2005-03-14 02:25 PM Re: Maximize an application (access)
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

Code:

Shawn
Moderator


Reged: 17/08/1999
Posts: 6666
Loc: Toronto, Ontario, Canada





Devil-ish
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2375 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.15 seconds in which 0.068 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org