View Full Version : How to hide command window box
David
December 5th 03, 07:56 PM
Hi
I have a small batch file that I schedule to run weekly
to do some admin and house keeping taks. When the batch
file is run a black command window pops up whilst the
batch file is running. I do not write anything to the
console in the batch file, is it possible to hide this
command window? If not is there a way as a minimum to put
a title on the command window so I know what it is?
Many thanks
David
Robert Moir
December 5th 03, 07:56 PM
David wrote:
> Hi
>
> I have a small batch file that I schedule to run weekly
> to do some admin and house keeping taks. When the batch
> file is run a black command window pops up whilst the
> batch file is running. I do not write anything to the
> console in the batch file, is it possible to hide this
> command window? If not is there a way as a minimum to put
> a title on the command window so I know what it is?
The simplest method of hiding it might be to create a different account from
your normal one that does nothing but run these scheduled jobs.
David
December 5th 03, 07:56 PM
Thanks RObert, sounded like just the ticket. Alas I had a
problem with this. THe batch file needs admin priv to run
and when I tried to run as Administrator it complained
about the lack of a password. I run XP Home Ed and the
Administrator account seems to be only available in
safemode. I don't really fancy having another admin
account for security reasons. Would this other account
need to be logged on at the time? If not how can I get a
scheduled task to run as under the administrator account
on Home Ed? Thanks, David
>-----Original Message-----
>David wrote:
>> Hi
>>
>> I have a small batch file that I schedule to run weekly
>> to do some admin and house keeping taks. When the batch
>> file is run a black command window pops up whilst the
>> batch file is running. I do not write anything to the
>> console in the batch file, is it possible to hide this
>> command window? If not is there a way as a minimum to
put
>> a title on the command window so I know what it is?
>
>The simplest method of hiding it might be to create a
different account from
>your normal one that does nothing but run these
scheduled jobs.
>
>
>.
>
Robert Moir
December 5th 03, 07:57 PM
David wrote:
> Thanks RObert, sounded like just the ticket. Alas I had a
> problem with this. THe batch file needs admin priv to run
> and when I tried to run as Administrator it complained
> about the lack of a password. I run XP Home Ed and the
> Administrator account seems to be only available in
> safemode. I don't really fancy having another admin
> account for security reasons. Would this other account
> need to be logged on at the time? If not how can I get a
> scheduled task to run as under the administrator account
> on Home Ed? Thanks, David
I'm not sure about running stuff using the administrator account in XP Home
because I don't use it, sorry. I mean to say I know about the restriction
about logging on as administrator in safe mode only but I don't know how it
would affect anything else.
The account you run a scheduled task under doesn't need to be "logged on" in
the sense I think you mean, as in a user logged in at the desktop, the task
scheduler simply starts the task running in the background as if it were
that account - using it's rights and settings - which is why in fact you get
the command window on screen when you run your scheduled task as yourself.
So you might well be able to run tasks as administrator in the background
without disturbing your work in your normal account. It's worth a go anyway!
Rob
David
December 5th 03, 07:57 PM
Robert,
Thanks for your contimued help, alas the Administrator
account on home ed is a bit wacky. There is no password
so I can not set a scheduled job to run as administrator.
I enter password as blank in scheduled tasks, but when it
runs it reports error no user account password entered.
Looks like a limitation of home ed.
>-----Original Message-----
>David wrote:
>> Thanks RObert, sounded like just the ticket. Alas I
had a
>> problem with this. THe batch file needs admin priv to
run
>> and when I tried to run as Administrator it complained
>> about the lack of a password. I run XP Home Ed and the
>> Administrator account seems to be only available in
>> safemode. I don't really fancy having another admin
>> account for security reasons. Would this other account
>> need to be logged on at the time? If not how can I get
a
>> scheduled task to run as under the administrator
account
>> on Home Ed? Thanks, David
>
>I'm not sure about running stuff using the administrator
account in XP Home
>because I don't use it, sorry. I mean to say I know
about the restriction
>about logging on as administrator in safe mode only but
I don't know how it
>would affect anything else.
>
>The account you run a scheduled task under doesn't need
to be "logged on" in
>the sense I think you mean, as in a user logged in at
the desktop, the task
>scheduler simply starts the task running in the
background as if it were
>that account - using it's rights and settings - which is
why in fact you get
>the command window on screen when you run your scheduled
task as yourself.
>
>So you might well be able to run tasks as administrator
in the background
>without disturbing your work in your normal account.
It's worth a go anyway!
>
>Rob
>
>
>.
>
David
December 5th 03, 07:57 PM
Just tried creating a shortcut and setting the properites
to run as minimized. This works if you click on it, but
alas this can not be scheduled as the scheduler will not
run the shortcut. At least I have managed to get the cmd
window to have a title now: just use the command "title
sometext" at the top of the batch file.
>-----Original Message-----
>Robert,
>
>Thanks for your contimued help, alas the Administrator
>account on home ed is a bit wacky. There is no password
>so I can not set a scheduled job to run as
administrator.
>I enter password as blank in scheduled tasks, but when
it
>runs it reports error no user account password entered.
>Looks like a limitation of home ed.
>
>>-----Original Message-----
>>David wrote:
>>> Thanks RObert, sounded like just the ticket. Alas I
>had a
>>> problem with this. THe batch file needs admin priv to
>run
>>> and when I tried to run as Administrator it complained
>>> about the lack of a password. I run XP Home Ed and the
>>> Administrator account seems to be only available in
>>> safemode. I don't really fancy having another admin
>>> account for security reasons. Would this other account
>>> need to be logged on at the time? If not how can I
get
>a
>>> scheduled task to run as under the administrator
>account
>>> on Home Ed? Thanks, David
>>
>>I'm not sure about running stuff using the
administrator
>account in XP Home
>>because I don't use it, sorry. I mean to say I know
>about the restriction
>>about logging on as administrator in safe mode only but
>I don't know how it
>>would affect anything else.
>>
>>The account you run a scheduled task under doesn't need
>to be "logged on" in
>>the sense I think you mean, as in a user logged in at
>the desktop, the task
>>scheduler simply starts the task running in the
>background as if it were
>>that account - using it's rights and settings - which
is
>why in fact you get
>>the command window on screen when you run your
scheduled
>task as yourself.
>>
>>So you might well be able to run tasks as administrator
>in the background
>>without disturbing your work in your normal account.
>It's worth a go anyway!
>>
>>Rob
>>
>>
>>.
>>
>.
>
Robert Moir
December 5th 03, 07:57 PM
David wrote:
> Robert,
>
> Thanks for your contimued help, alas the Administrator
> account on home ed is a bit wacky. There is no password
> so I can not set a scheduled job to run as administrator.
> I enter password as blank in scheduled tasks, but when it
> runs it reports error no user account password entered.
> Looks like a limitation of home ed.
Sorry. I knew it installed blank by default but I thought you could change
this afterwards at least while booted up as administrator. To answer two of
your posts in one go, I just tried setting up a scheduled task that run a
batch file shortcut just fine. I just setup the shortcut, pointed it to the
..pif file (batch file shortcut) and it just ran fine.
Torgeir Bakken (MVP)
December 5th 03, 07:57 PM
David wrote:
> I have a small batch file that I schedule to run weekly
> to do some admin and house keeping taks. When the batch
> file is run a black command window pops up whilst the
> batch file is running. I do not write anything to the
> console in the batch file, is it possible to hide this
> command window? If not is there a way as a minimum to put
> a title on the command window so I know what it is?
Hi
You can launch your batch file from a vbscript file to make it "invisible".
Put the code below (and adjust the bat file name/path) into a file called e.g.
runbathidden.vbs, and run it from the scheduler with wscript.exe as the
executable and <path-to-vbs-file> as the parameter.
oShell.Run """c:\my batch\cleanup.bat""", 0, True
--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter
David
December 5th 03, 07:57 PM
Thanks Torgeir,
Hope we can get this to work as I can not run a scheduled
task as administrator in XP Home Ed (even after setting
administrator a password in safe mode) nor can I run a
shortcut as a scheduled task :-(
I created a file called runhidden.vbs and added the line:
Shell.Run """c:\scripts\pfcleanup.bat""", 0, True
and tried to run the command: wscript
c:\scripts\runhidden.vbs but this returns an error:
object required:'Shell' code:800A01A8
I wasn't sure of the o at the start of your example so I
tried both oShell.run.... and Shell.run.... both fail
with the object required message.
Thanks
David
>-----Original Message-----
>David wrote:
>
>> I have a small batch file that I schedule to run weekly
>> to do some admin and house keeping taks. When the batch
>> file is run a black command window pops up whilst the
>> batch file is running. I do not write anything to the
>> console in the batch file, is it possible to hide this
>> command window? If not is there a way as a minimum to
put
>> a title on the command window so I know what it is?
>
>Hi
>
>You can launch your batch file from a vbscript file to
make it "invisible".
>
>Put the code below (and adjust the bat file name/path)
into a file called e.g.
>runbathidden.vbs, and run it from the scheduler with
wscript.exe as the
>executable and <path-to-vbs-file> as the parameter.
>
>
>oShell.Run """c:\my batch\cleanup.bat""", 0, True
>
>
>--
>torgeir
>Microsoft MVP Scripting and WMI, Porsgrunn Norway
>Administration scripting examples and an ONLINE version
of the 1328 page
>Scripting Guide:
http://www.microsoft.com/technet/scriptcenter
>
>
>.
>
Torgeir Bakken (MVP)
December 5th 03, 07:58 PM
David wrote:
> Thanks Torgeir,
>
> Hope we can get this to work as I can not run a scheduled
> task as administrator in XP Home Ed (even after setting
> administrator a password in safe mode) nor can I run a
> shortcut as a scheduled task :-(
>
> I created a file called runhidden.vbs and added the line:
> Shell.Run """c:\scripts\pfcleanup.bat""", 0, True
>
> and tried to run the command: wscript
> c:\scripts\runhidden.vbs but this returns an error:
> object required:'Shell' code:800A01A8
>
> I wasn't sure of the o at the start of your example so I
> tried both oShell.run.... and Shell.run.... both fail
> with the object required message.
Hi
Duh, I forgot to define the WScript.Shell object where the Run method resides
;-)
This should work better:
Set oShell = CreateObject("WScript.Shell")
oShell.Run """c:\scripts\pfcleanup.bat""", 0, True
A side note:
You can also write this
Set Shell = CreateObject("WScript.Shell")
Shell.Run """c:\scripts\pfcleanup.bat""", 0, True
I just like to put an o in front of objects, a s before string variables, an i
before number (integer) variables, and so on.
--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter
vBulletin® v3.6.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.