Convert Batch file to VB or Registry for Context Menu Access
#1
Posted 05 February 2013 - 07:33 AM
I would like to add this functionality to the context menu for Win 7. I'm not sure how to go about doing this. I've seen another thread that leads a user through a similar process, but I have no idea how to convert my code to registry entries. Here is the code:
@ECHO OFF
:BEGIN
CLS
SET AGPath=X:\01 PC WIP\
SET /P Cust=Customer Name:
SET /P InvNo=Invoice Number (Last 5 digits only):
SET /P Job=Type of job:
SET SERIES=%InvNo:~0,3%00 PC\
CLS
echo Is this correct?
echo %AGPath%%SERIES%
echo %Cust%\
echo %InvNo% %Job%
SET /P Appr=Y(yes) N(no) C(cancel):
if '%Appr%' == 'y' goto Appr
if '%Appr%' == 'n' goto BEGIN
if '%Appr%' == 'c' goto Cancel
:Appr
mkdir "%AGPath%%SERIES%%Cust%\%InvNo% %Job%\materials\yyyy.mm.dd Files Received"
mkdir "%AGPath%%SERIES%%Cust%\%InvNo% %Job%\HSD"
mkdir "%AGPath%%SERIES%%Cust%\%InvNo% %Job%\Design"
mkdir "%AGPath%%SERIES%%Cust%\%InvNo% %Job%\LFC"
mkdir "%AGPath%%SERIES%%Cust%\%InvNo% %Job%\PROOF"
CLS
echo Process Complete
Pause
goto end
:Cancel
CLS
echo Process canceled by user.
Pause
goto end
:END
I know my code is probably junk, but hey. Thanks for any help!
#2
Posted 05 February 2013 - 08:44 AM
13ruce, on 05 February 2013 - 07:33 AM, said:
Provide a pointer to it, maybe it can be adapted.
13ruce, on 05 February 2013 - 07:33 AM, said:
Rest assured, it is
Besides some "style" for which everyone has it's preferences (as an example you need not an :END label in NT batch, since the re is the implied :EOF label), this snippet:
Quote
if '%Appr%' == 'y' goto Appr
if '%Appr%' == 'n' goto BEGIN
if '%Appr%' == 'c' goto Cancel
is WRONG
it doesn't take into account small and CAPITAL letters and will "continue" execution if *anything* but y, n or c is input
This approach is safer/better:
Quote
SET /P Appr=Y(yes) N(no) C(cancel):
if /i '%Appr%' == 'y' goto :Appr
if '/i %Appr%' == 'n' goto :BEGIN
GOTO :Cancel
The yyyy.mm.dd values are not "initialized/set" anywhere, is this really the wanted result, litterally yyyy.mm.dd?
jaclaz
#3
Posted 05 February 2013 - 02:12 PM
make something like this to present to the end user.
UserInputDemo.png (135.49K)
Number of downloads: 8
<!--
February-05-13
Hta And Script By Gunsmokingman Aka Jake1Eye
-->
<TITLE>Demo User Input</TITLE>
<HTA:APPLICATION ID="UserIn"
SCROLL="No"
SCROLLFLAT ="No"
SingleInstance="Yes"
ShowInTaskbar="No"
SysMenu="No"
MaximizeButton="No"
MinimizeButton="No"
Border="Thin"
BORDERSTYLE ="complex"
INNERBORDER ="No"
Caption="Yes"
WindowState="Normal"
APPLICATIONNAME="DmUserIn"
Icon="%SystemRoot%\explorer.exe">
<STYLE type="text/css">
Body
{
Font-Size:9.25pt;
Font-Weight:Bold;
Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS;
Color:Black;
BackGround-Color:#EFE9E3;
Text-Align:Center;
Vertical-Align:Top;
}
TD
{
Font-Size:8.25pt;
Font-Weight:Bold;
Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS;
Color:Black;
}
.Tbx
{
Font-Size:8.25pt;
Font-Weight:Bold;
Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS;
Color:Black;
}
BUTTON
{
Height:15pt;
width:60pt;
Cursor:Hand;
Font:8.05pt;
Font-weight:bold;
Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS;
Color:#404040;
Text-Align:Center;
Vertical-Align:Middle;
filter:progid:DXImageTransform.Microsoft.Gradient
(StartColorStr='#E5E5E5',EndColorStr='#7D7D7D');
Margin:1;
Margin-Top:15pt;
Padding:2;
Border-Left: 1px Transparent;
Border-Right: 2px Transparent;
Border-Top: 1px Transparent;
Border-Bottom: 2px Transparent;
}
</STYLE>
<script LANGUAGE='VBScript'>
'-> Resize And Place In Approx Center Of Screen
Dim Wth, Hht :Wth = int(475) :Hht = int(255)
window.ResizeTo Wth, Hht
MoveTo ((Screen.Width / 2) - (Wth / 2)),((Screen.Height / 2) - (Hht / 2))
'-> Function To Process The Submit Button
Function MySubmit()
If Len(In1.value) = 0 And Len(In2.value) = 0 And Len(In3.value) = 0 Then
alert("No Textboxes Have Any Information")
ElseIf Len(In1.value) >= 1 And Len(In2.value) = 0 And Len(In3.value) = 0 Then
alert("Only TextBox 1 Information : " & In1.value & vbCrlf & _
"Please Fill In Textboxes 2 And 3 Then Press Submit")
ElseIf Len(In1.value) >= 1 And Len(In2.value) >= 1 And Len(In3.value) = 0 Then
alert("TextBox 1 Information : " & In1.value & vbCrlf & _
"TextBox 2 Information : " & In2.value & vbCrlf & _
"Please Fill In Textboxes 3 Then Press Submit")
ElseIf Len(In1.value) >= 1 And Len(In2.value) >= 1 And Len(In3.value) >= 1 Then
If Len(In2.value) = 5 Then
alert("Sucess All 3 Textboxes Filled In" & vbCrlf & _
"TextBox 1 Information : " & In1.value & vbCrlf & _
"TextBox 2 Information : " & In2.value & vbCrlf & _
"TextBox 3 Information : " & In3.value)
Else
alert("Error Needs The Last Five Digits From Invoice Number : " & In2.value)
End If
End If
End Function
</SCRIPT>
<BODY>
<!-- Customer Name Area -->
<TABLE><TD Style='width:101;'>Customer Name</TD><TD>
<INPUT Type='TextBox' ID='In1' Class='Tbx' Size='40' MAXLENGTH='128'>
<TD></TABLE>
<!-- Two Textboxes Start -->
<TABLE>
<!-- Invoice Number Area -->
<TD Style='width:101;'>Invoice Number</TD>
<TD><INPUT Type='TextBox' ID='In2' Class='Tbx' Size='5' MAXLENGTH='5'
Style='Margin-Right:15;' Title="Use Only The Last Five Digits
Of The Invoice Number"></TD>
<!-- Type Of Job Area -->
<TD Style='width:101;'>Type Of Job</TD>
<TD><INPUT Type='TextBox' ID='In3' Class='Tbx' Size='10' MAXLENGTH='15'><TD>
</TABLE>
<!-- Buttons Start -->
<BUTTON ID='Bn1' OnClick='MySubmit()'>Submit</BUTTON>
<BUTTON ID='Bn2' OnClick='window.close()'>Close</BUTTON>
<BODY>
#4
Posted 06 February 2013 - 07:14 AM
Gunskokingman,
Wow, that's very nice, and looks like a much nicer way to present it. Unfortunately you lost me at HTA. I couldn't even find that on wikipedia. (I don't think you fully appreciate the breadth of my ignorance.
#5
Posted 06 February 2013 - 07:46 AM
13ruce, on 06 February 2013 - 07:14 AM, said:
And - AGAIN - can you post a link to THAT thread (so that possibly we can see if THAT sollution may be adapted to your issue?
Generic "context shell" advice:
http://wstudios.home...iate/index.html
BTW "conttext" of WHAT
I.e. are you looking to add it to right click when WHAT is selected/in focus?
Example for Desktop:
http://www.howtogeek...-menu-in-vista/
JFYI
http://en.wikipedia.org/wiki/HTA
http://en.wikipedia....TML_Application
jaclaz
This post has been edited by jaclaz: 06 February 2013 - 07:48 AM
#6
Posted 06 February 2013 - 08:59 AM
I would like to add this app to the right-click context menu of Windows Explorer in Win 7 (32 and 64). I suppose I shouldn't have assumed the batch file's function would have made that obvious.
Here's the post I Googled that lead me here: http://www.msfn.org/...ght-click-menu/
Thanks. You've given me a lot of good info to look into. I really like the VB interface, so I will try to develop what Gunsmokingman has provided as well.
#7
Posted 06 February 2013 - 09:36 AM
The reg file posted here:
http://www.msfn.org/...post__p__905087
will do that alright (to add to a folder context menu)
AGAIN, to WHICH context menu do you want to add the .hta?
Context means "contextual to something" (or "linked" to something), usually an object that is selected, (like as said examples, folder, file, desktop, etc.) to WHICH of these objects do you want to "link" the right click menu entry?
jaclaz
#8
Posted 06 February 2013 - 11:50 AM
#9
Posted 06 February 2013 - 01:18 PM
I've worked up a flowchart to help me think through the logic of what needs to happen. Thoughts/suggestions welcome:
This post has been edited by 13ruce: 06 February 2013 - 01:23 PM
#10
Posted 06 February 2013 - 01:46 PM
1:\ Collect all information needed
2a:\ Confirm information
2b:\ redo if wrong,
2c:\ then offer to exit and do nothing
3:\ Process information to the various varibles
4:\ Check for folder,
5:\ Process all information
6:\ Finish dialog if needed
#11
Posted 06 February 2013 - 02:17 PM
#12
Posted 06 February 2013 - 02:22 PM
#13
Posted 06 February 2013 - 02:27 PM
If all information is correct then ask yes to go on or no to quit
Then process all the varibles, run them threw the script, option finish
I dont like having a window open to some folder for no reason.
#14
Posted 06 February 2013 - 02:47 PM
gunsmokingman, on 06 February 2013 - 02:27 PM, said:
In our workflow, if the user gets that far, they have work to do in that folder. It can be inferred that the user isn't already viewing that folder (else they would not have invoked the app), so it makes sense to open that location as a convenience. Does that makes sense?
#15
Posted 06 February 2013 - 03:05 PM
If Len(In2.value) = 5 Then
Dim A :A=MsgBox("Is All The Information Correct" & vbCrlf & _
"TextBox 1 Information : " & In1.value & vbCrlf & _
"TextBox 2 Information : " & In2.value & vbCrlf & _
"TextBox 3 Information : " & In3.value & vbCrlf & vbCrlf & _
"Ok To Continue" & vbCrlf & "No Redo The Information" & vbCrlf & _
"Cancel To Close And Exit",4131)
If A = 6 Then
alert("Script Place Holder For Yes Actions")
ElseIf A = 7 Then
In1.value="" :In2.value="" :In3.value="" :
ElseIf A = 2 Then
window.close()
End If
Else
alert("Error Needs The Last Five Digits From Invoice Number : " & In2.value)
End If
#16
Posted 06 February 2013 - 03:21 PM
#17
Posted 06 February 2013 - 03:33 PM
<!--
February-05-13
Hta And Script By Gunsmokingman Aka Jake1Eye
-->
My first order of business was to update that to:
<!--
February-05-13
Hta And Script By Gunsmokingman Aka Jake1Eye
Any horrible abberations herein are the fault of 13ruce
and are in no way to be attributed to the excellent
script stylings of Gunsmokingman Aka Jake1Eye
-->
You're welcome.
This post has been edited by 13ruce: 06 February 2013 - 03:33 PM
#18
Posted 06 February 2013 - 03:48 PM
What you do change or I may help with you can place
what you feel is needed.
#19
Posted 06 February 2013 - 03:53 PM
If I get it right what you need is a shell extension (and not a contextual menu entry).
If this is correct, I doubt you can have it.
Do the following:
- get http://www.nirsoft.n...s/shexview.html
- check which shell extensions you have on your system
- post info about one that is present on your right click menu (where/when you would like to see this script entry)
Before the above, try actually reading the initially given:
http://www.howtogeek...-menu-in-vista/
AND test it
jaclaz
This post has been edited by jaclaz: 06 February 2013 - 03:58 PM
#20
Posted 06 February 2013 - 04:34 PM
jaclaz, on 06 February 2013 - 03:53 PM, said:
http://www.howtogeek...-menu-in-vista/
AND test it
jaclaz
As soon as I have a working app, I definitely will. Thanks again!
- ← How to execute .exe INDIRECTLY trough another .exe, .bat etc...
- Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
- strip names →



Help

Back to top









