Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - bat to vbs

Reply
 
Old 06-29-2009   #1 (permalink)
ronald


 
 

bat to vbs

I have a bat file that works great. The problem is my company wants
only VBS so when the user logs on it will not open a command prompt.
I need to convert it so it will run silently with no box popping up.
I relay need to learn VBS.
It copies the users NK2 file to a network share at log on. It works
with Vista and XP as we use both.
Below is my bat file.
Can anyone convert this to a VBS so it runs silently?

Thanks
REM -----------------------Start of bat file

if exist \\servername\nk2$\%username% del /q \\servername\nk2$\
%username%

MD \\servername\nk2$\%username%

IF EXIST C:\Users\%username%\AppData\Roaming\Microsoft\Outlook\*.nk2
copy C:\Users\%username%\AppData\Roaming\Microsoft\Outlook\*.nk2 \
\servername\nk2$\%username%\*.nk2

if exist "C:\Documents and Settings\%username%\Application Data
\Microsoft\Outlook\*.nk2" copy "C:\Documents and Settings\%username%
\Application Data\Microsoft\Outlook\*.nk2" \\servername\nk2$\%username%
\*.nk2

REM ---------------------End of bat file


Thanks again

My System SpecsSystem Spec
Old 07-10-2009   #2 (permalink)
mr_unreliable


 
 

Re: bat to vbs



ronald wrote:
Quote:

> Can anyone convert this to a VBS so it runs silently?
>
hi Ronald,

The FileSystemObject has a FileExists function and a
CreateFolder method (comparable with makeDirectory).

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but, no guarantee
the answers will be applicable to the questions)

My System SpecsSystem Spec
Old 07-10-2009   #3 (permalink)
Todd Vargo


 
 

Re: bat to vbs

ronald wrote:
Quote:

> I have a bat file that works great. The problem is my company wants
> only VBS so when the user logs on it will not open a command prompt.
> I need to convert it so it will run silently with no box popping up.
> I relay need to learn VBS.
> It copies the users NK2 file to a network share at log on. It works
> with Vista and XP as we use both.
> Below is my bat file.
> Can anyone convert this to a VBS so it runs silently?
>
> Thanks
> REM -----------------------Start of bat file
>
> if exist \\servername\nk2$\%username% del /q \\servername\nk2$\
> %username%
>
> MD \\servername\nk2$\%username%
>
> IF EXIST C:\Users\%username%\AppData\Roaming\Microsoft\Outlook\*.nk2
> copy C:\Users\%username%\AppData\Roaming\Microsoft\Outlook\*.nk2 \
> \servername\nk2$\%username%\*.nk2
>
> if exist "C:\Documents and Settings\%username%\Application Data
> \Microsoft\Outlook\*.nk2" copy "C:\Documents and Settings\%username%
> \Application Data\Microsoft\Outlook\*.nk2" \\servername\nk2$\%username%
> \*.nk2
>
> REM ---------------------End of bat file
Although you can create a vbs to replace your batch, I would just put a
shortcut to the batch in the startup folder (instead of the batch) and set
it to run minimized? This feature has been around since Windows 3 but nobody
seems to use it. Personally, I would reduce the batch rather then create a
vbs.

REM -----------------------Start of bat file

del /q \\servername\nk2$\%username%\*nk2

copy "C:\Users\%username%\AppData\Roaming\Microsoft\Outlook\*.nk2"
\\servername\nk2$\%username%*.nk2

copy "C:\Documents and Settings\%username%\Application
Data\Microsoft\Outlook\*.nk2" \\servername\nk2$\%username%\*.nk2

REM ---------------------End of bat file


--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

My System SpecsSystem Spec
Old 07-12-2009   #4 (permalink)


32 Bit Vista Ultimate
 
 

Re: bat to vbs

How do you make the batch file run minimised?
My System SpecsSystem Spec
Old 07-12-2009   #5 (permalink)
Todd Vargo


 
 

Re: bat to vbs

jammmie999" wrote:
Quote:

>
> How do you make the batch file run minimised?
First you create a shortcut to the batch (use Windows Help system). Once
shortcut is created, you right click it and select properties. Now explore
it's tabbed properties dialog for an option called "Run" and set it to
minimized and press "OK".

My System SpecsSystem Spec
Old 07-12-2009   #6 (permalink)


32 Bit Vista Ultimate
 
 

Re: bat to vbs

Quote  Quote: Originally Posted by Todd Vargo View Post
jammmie999" wrote:
Quote:

>
> How do you make the batch file run minimised?
First you create a shortcut to the batch (use Windows Help system). Once
shortcut is created, you right click it and select properties. Now explore
it's tabbed properties dialog for an option called "Run" and set it to
minimized and press "OK".
Thank you. I have found that you could also use

@echo off
start /min C:\test.bat
exit

for example from another bat file.
My System SpecsSystem Spec
Old 07-18-2009   #7 (permalink)
Al Dunbar


 
 

Re: bat to vbs


"mr_unreliable" <kindlyReplyToNewsgroup@xxxxxx> wrote in message
news:OxL$m7YAKHA.1248@xxxxxx
Quote:

>
>
> ronald wrote:
Quote:

>> Can anyone convert this to a VBS so it runs silently?
>>
>
> hi Ronald,
>
> The FileSystemObject has a FileExists function and a
> CreateFolder method (comparable with makeDirectory).
Alternately, one could write a vbscript that users the .RUN method to launch
the batch file in such a way that no command window is created. See the
intWindowStyle argument here:

http://msdn.microsoft.com/en-us/libr...ky(VS.85).aspx


/Al


My System SpecsSystem Spec
Old 07-18-2009   #8 (permalink)
Al Dunbar


 
 

Re: bat to vbs


"jammmie999" <guest@xxxxxx-email.com> wrote in message
news:756a3bfdce61a8175784727c1d11559f@xxxxxx-gateway.com...
Quote:

>
> Todd Vargo;1087616 Wrote:
Quote:

>> jammmie999" wrote:> > >
Quote:

>> > >
>> > > How do you make the batch file run minimised? > > First you create a
>> > > shortcut to the batch (use Windows Help system).
>> Once
>> shortcut is created, you right click it and select properties. Now
>> explore
>> it's tabbed properties dialog for an option called "Run" and set it
>> to
>> minimized and press "OK".
>
> Thank you
If this is a logon script, I am not sure how you can do it this way...

/Al


My System SpecsSystem Spec
Old 07-18-2009   #9 (permalink)
Todd Vargo


 
 

Re: bat to vbs

Al Dunbar wrote:
Quote:

> "jammmie999" <guest@xxxxxx-email.com> wrote in message
> news:756a3bfdce61a8175784727c1d11559f@xxxxxx-gateway.com...
Quote:

>>
>> Todd Vargo;1087616 Wrote:
Quote:

>>> jammmie999" wrote:> > >
>>>>>
>>>>> How do you make the batch file run minimised? > > First you
>>>>> create a shortcut to the batch (use Windows Help system).
>>> Once
>>> shortcut is created, you right click it and select properties. Now
>>> explore
>>> it's tabbed properties dialog for an option called "Run" and set it
>>> to
>>> minimized and press "OK".
>>
>> Thank you
>
> If this is a logon script, I am not sure how you can do it this way...
jammmie999 asked a seperate question from OP.

Please elucidate on what you are not sure about so we are on the same page.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)
My System SpecsSystem Spec
Old 07-18-2009   #10 (permalink)
Al Dunbar


 
 

Re: bat to vbs


"Todd Vargo" <tlvargo@xxxxxx> wrote in message
news:#VpBKI7BKHA.4792@xxxxxx
Quote:

> Al Dunbar wrote:
Quote:

>> "jammmie999" <guest@xxxxxx-email.com> wrote in message
>> news:756a3bfdce61a8175784727c1d11559f@xxxxxx-gateway.com...
Quote:

>>>
>>> Todd Vargo;1087616 Wrote:
>>>> jammmie999" wrote:> > >
>>>>>>
>>>>>> How do you make the batch file run minimised? > > First you
>>>>>> create a shortcut to the batch (use Windows Help system).
>>>> Once
>>>> shortcut is created, you right click it and select properties. Now
>>>> explore
>>>> it's tabbed properties dialog for an option called "Run" and set it
>>>> to
>>>> minimized and press "OK".
>>>
>>> Thank you
>>
>> If this is a logon script, I am not sure how you can do it this way...
>
> jammmie999 asked a seperate question from OP.
Yes, I realized that.
Quote:

> Please elucidate on what you are not sure about so we are on the same
> page.
I'm not sure how applicable the shortcut trick would be to the OP's original
question which seemed to me to be in the context of a logon script. He said:

"I have a bat file that works great. The problem is my company wants
only VBS so when the user logs on it will not open a command prompt."

In retrospect I suppose it is possible that he is talking about running a
script from the startup folder in the start menu, in which case a shortcut
would work perfectly well. It just hadn't occurred to me that that was the
context (even though you explicitly referred to the possibility), as
domain-based logon scripts are easier to manage. And when they do run, you
are connected to the network, and not logging in locally with cached
credentials.

I think you and I are on the same page now, I'm just not sure about the
OP...


/Al


My System SpecsSystem Spec
Reply

Thread Tools



Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46