PDA

View Full Version : how to insert <Enter> in .bat file


JW
June 2nd 04, 08:44 PM
How can I add a line in a .bat file, that will send the <Enter> key ? Hope
this is not a dumb question. I tried pressing Enter on a blank line in the
..bat file, but as I imagined, it behaved like a line with nothing on it.
What I'm trying to do is use the Startup folder to automatically Synchronize
an Active Desktop item, by running a .bat file that runs Mobsync.exe,
followed by sending an <Enter> keystroke.

I also tried and failed to locate any Help for Mobsync, that would show me a
parameter to achieve the same desired effect. I already know an
alternative. I can go out, and download a keystroke recorder program, which
I will eventually do anyway for more complex macros. But if at all
possible, I would like to learn how to do it in a .bat file. Sometimes,
Quick and Dirty is simpler.

JW
June 2nd 04, 09:41 PM
If somebody knows how to send the Alt+S keystroke combination in a .bat
file, that would also work in this particular circumstance. Thanks for any
help.


"JW" > wrote in message
...
How can I add a line in a .bat file, that will send the <Enter> key ? Hope
this is not a dumb question. I tried pressing Enter on a blank line in the
..bat file, but as I imagined, it behaved like a line with nothing on it.
What I'm trying to do is use the Startup folder to automatically Synchronize
an Active Desktop item, by running a .bat file that runs Mobsync.exe,
followed by sending an <Enter> keystroke.

I also tried and failed to locate any Help for Mobsync, that would show me a
parameter to achieve the same desired effect. I already know an
alternative. I can go out, and download a keystroke recorder program, which
I will eventually do anyway for more complex macros. But if at all
possible, I would like to learn how to do it in a .bat file. Sometimes,
Quick and Dirty is simpler.

Carrie Garth
June 2nd 04, 09:41 PM
| "JW" > wrote in message
| ...
| How can I add a line in a .bat file, that will send the <Enter> key ?
| <SNIP> What I'm trying to do is use the Startup folder to automatically
| Synchronize an Active Desktop item, by running a .bat file that runs
| Mobsync.exe, followed by sending an <Enter> keystroke. <SNIP>

You could use a VBS script that uses the SendKeys Method. For example,
copy the following lines of script into notepad, save it with the extension
..vbs, and then put a shortcut to the script in your Startup Folder.


Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\WINDOWS\system32\Mobsync.exe"
WScript.Sleep 400
WshShell.AppActivate "Items to Synchronize"
WScript.Sleep 400
WshShell.SendKeys "{ENTER}"
REM WScript.Sleep 800
REM WshShell.SendKeys "%S"
Set WSHShell = Nothing


BTW, if you want to use the SendKeys command to close the dialog
box, just remove the REM from the script.

And if any of the processes need more or less time to execute before the next
action is executed, increase or decrease the WScript.Sleep = value.

For some information about the WSH SendKeys Method see:
MSDN Home | MSDN Library | Web Development | Scripting | Windows
Script Technologies | Windows Script Host | Reference | Methods
Windows Script Host: SendKeys
http://msdn.microsoft.com/library/en-us/script56/html/wsMthSendKeys.asp

And for an offline version of the MSDN Library | Web Development |
Scripting | Windows Script Technologies Web Site pages visit the
following Microsoft Download Site and download scrdoc56en.exe. Then
double-click scrdoc56en.exe and it will prompt you for a location to
extract the Windows Script Technologies Help file (Script56.CHM)

Microsoft Windows Script 5.6 Documentation (scrdoc56en.exe)
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en

And if you need any help with scripting try posting in the following
newsgroup: microsoft.public.scripting.vbs

If you read the newsgroups using the Microsoft Communities Web Page:
http://communities2.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.scripting.vbscrip t

If you read newsgroups using a NNTP newsreader, such as Outlook
Express, and use the msnews.microsoft.com news server, here is a link:
news://msnews.microsoft.com/microsoft.public.scripting.vbs

Or if you insist on trying doing it with a bat I suggest that you post in the
following newsgroup: microsoft.public.win2000.cmdprompt.admin

If you read the newsgroups using the Microsoft Communities Web Page:
http://communities2.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.win2000.cmdprompt .admin

If you read newsgroups using a NNTP newsreader, such as Outlook
Express, and use the msnews.microsoft.com news server:
news://msnews.microsoft.com/microsoft.public.microsoft.public.win2000.cmdpromp t.admin

JW
June 2nd 04, 11:41 PM
Thanks for your help Carrie. Someday I would like to learn VBscript. That
would help me do other stuff someday, without having to ask somebody to
write me another VBscript program.

In the mean time, I was looking for a Quick and Dirty 2-line .bat file.
Hope you don't mind me asking a dumb question. Realizing I don't understand
VBscript, is the 9-line program you provided better (e.g. more adaptable or
less breakable) than a 2-line .bat file would be ?

"Carrie Garth" > wrote in message
...
| "JW" > wrote in message
| ...
| How can I add a line in a .bat file, that will send the <Enter> key ?
| <SNIP> What I'm trying to do is use the Startup folder to automatically
| Synchronize an Active Desktop item, by running a .bat file that runs
| Mobsync.exe, followed by sending an <Enter> keystroke. <SNIP>

You could use a VBS script that uses the SendKeys Method. For example,
copy the following lines of script into notepad, save it with the extension
..vbs, and then put a shortcut to the script in your Startup Folder.


Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\WINDOWS\system32\Mobsync.exe"
WScript.Sleep 400
WshShell.AppActivate "Items to Synchronize"
WScript.Sleep 400
WshShell.SendKeys "{ENTER}"
REM WScript.Sleep 800
REM WshShell.SendKeys "%S"
Set WSHShell = Nothing


BTW, if you want to use the SendKeys command to close the dialog
box, just remove the REM from the script.

And if any of the processes need more or less time to execute before the
next
action is executed, increase or decrease the WScript.Sleep = value.

For some information about the WSH SendKeys Method see:
MSDN Home | MSDN Library | Web Development | Scripting | Windows
Script Technologies | Windows Script Host | Reference | Methods
Windows Script Host: SendKeys
http://msdn.microsoft.com/library/en-us/script56/html/wsMthSendKeys.asp

And for an offline version of the MSDN Library | Web Development |
Scripting | Windows Script Technologies Web Site pages visit the
following Microsoft Download Site and download scrdoc56en.exe. Then
double-click scrdoc56en.exe and it will prompt you for a location to
extract the Windows Script Technologies Help file (Script56.CHM)

Microsoft Windows Script 5.6 Documentation (scrdoc56en.exe)
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en

And if you need any help with scripting try posting in the following
newsgroup: microsoft.public.scripting.vbs

If you read the newsgroups using the Microsoft Communities Web Page:
http://communities2.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.scripting.vbscrip t

If you read newsgroups using a NNTP newsreader, such as Outlook
Express, and use the msnews.microsoft.com news server, here is a link:
news://msnews.microsoft.com/microsoft.public.scripting.vbs

Or if you insist on trying doing it with a bat I suggest that you post in
the
following newsgroup: microsoft.public.win2000.cmdprompt.admin

If you read the newsgroups using the Microsoft Communities Web Page:
http://communities2.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.win2000.cmdprompt .admin

If you read newsgroups using a NNTP newsreader, such as Outlook
Express, and use the msnews.microsoft.com news server:
news://msnews.microsoft.com/microsoft.public.microsoft.public.win2000.cmdpromp t.admin

Gordo
June 3rd 04, 12:41 AM
JW > wrote:
> How can I add a line in a .bat file, that will send the <Enter> key ?
> Hope this is not a dumb question. I tried pressing Enter on a blank
> line in the .bat file, but as I imagined, it behaved like a line with
> nothing on it. What I'm trying to do is use the Startup folder to
> automatically Synchronize an Active Desktop item, by running a .bat
> file that runs Mobsync.exe, followed by sending an <Enter> keystroke.

Try
echo. | mobsync

Gordo

JW
June 3rd 04, 02:44 AM
Thanks for your response.
It didn't work, but I found that Synchronize can be set up to run
automatically at logon, by clicking the Setup button.

"Gordo" > wrote in message
...
JW > wrote:
> How can I add a line in a .bat file, that will send the <Enter> key ?
> Hope this is not a dumb question. I tried pressing Enter on a blank
> line in the .bat file, but as I imagined, it behaved like a line with
> nothing on it. What I'm trying to do is use the Startup folder to
> automatically Synchronize an Active Desktop item, by running a .bat
> file that runs Mobsync.exe, followed by sending an <Enter> keystroke.

Try
echo. | mobsync

Gordo

Google