|
|
Subject:
Ultra-simple Windows Scripting VBS script needed
Category: Computers > Programming Asked by: donphiltrodt-ga List Price: $35.00 |
Posted:
09 Dec 2005 23:12 PST
Expires: 08 Jan 2006 23:12 PST Question ID: 603967 |
I need a very simple Windows Scripting script written. I found a command line tool (mp3splt) that will make an excellent Shell Extension, provided I can do one thing: edit the pathname argument it receives from Windows via the "%1" variable. A vbs script can act as a liason between a) the shell extension command issued by Windows and b) the command line arguments/switches that mp3splt wants. ___Synopsis___ Script receives a pathname as a Windows-ShellEx-intiated command line argument via %1. Script strips pathname down to the raw filename (sans driveletter, parent dirs). Script presents filename to user for confirmation or editing, via a prepopulated Msgbox. Script executes the mp3splt command, sending the stripped and user-confirmed (and possibly modified) filename as a commandline argument. ___Detailed version___ The script (called Prompt.vbs) will be run from right-click in Windows Explorer via a Shell Extension registry entry. (I will create this registry entry. But I'll gladly accept pointers or resources. :-) The script will be called with this command... prompt.vbs %1 ...where %1 is the full path name of the file I selected before right-clicking and choosing the shell extension. The script's job is very simple... --) Present a msgbox _prepopulated_ with the FILEname that was passed to the vbs script via the %1 argument. CRITICAL: Msgbox is prepopulated with the FILEname, NOT the "path", which includes the drive letter and parent directories. Msgbox options should be OK and Cancel. --) Validate the Msgbox input by replacing all filename-invalid characters (/\.*? etc) with underscores. (Get a complete list from MS knowledge base.) --) Execute the following command... foobaz.exe -h higgle -i shiggle -o "@n-<<msgbox>>" ...where <<msgbox>> is replaced by the validated input from the message box. |
|
There is no answer at this time. |
|
Subject:
Re: Ultra-simple Windows Scripting VBS script needed
From: ljbuesch-ga on 10 Dec 2005 00:51 PST |
I can do this if you don't care if it's an actual application and not a script. I have .net and it'll be a .net application, so instead of doing prompt.vbs %i, you can do prompt.exe %i (unless you know how to create vbs's in .net). Let me know: Agolna@gmail.com |
Subject:
Re: Ultra-simple Windows Scripting VBS script needed
From: donphiltrodt-ga on 10 Dec 2005 01:17 PST |
It needs to be a script. Thank you, though. |
Subject:
Re: Ultra-simple Windows Scripting VBS script needed
From: b_cummins-ga on 10 Dec 2005 08:52 PST |
Try this: '############################################################################### '# Author: Ben Cummins '# Date: 10 December 2005 16:54 '# '# Script to parse command line parameter, validate filename and pass '# off to third party application. '############################################################################### '# Make sure here is exactly one argument. If WScript.Arguments.Count <> 1 Then MsgBox "Invalid Parameters" & vbCrlF & "Please use test.vbs <filename>" Else '# temporary variables Dim filename, newfilename, strFileName, strFilePath, indexOfLastSlash '# Get filename from the command line filename = WScript.Arguments.Item(0) '# find the last \ in the filename indexOfLastSlash = InstrRev(filename, "\") '# get the path of the file strFilePath = Mid(filename, 1, indexOfLastSlash) '# get the filename of the file strFileName = Mid(filename, indexOfLastSlash+1) '# get new filename from the user newfilename = InputBox("Please enter new filename", "Input Required", strFileName) '# make sure the user has entered something If newfilename <> "" Then '# validate the filename If ValidateFilename(newfilename) Then '# execute the command ' RunCommand "foobaz.exe -h higgle -i shiggle -o ""@n-" & newfilename & """" RunCommand "notepad """ & newfilename & """" End If Else '# User entered no details. MsgBox "No input specified." End If End If '# Run a command line application Function RunCommand(strCommand) Set objShell = CreateObject("WScript.Shell") Set objScriptExec = objShell.Exec(strCommand) Set objShell = Nothing Set objScriptExec = Nothing End Function '# based on characters from http://support.microsoft.com/kb/q177506/ Function ValidateFilename(strFilename) Dim strValidChars '# Enter all valid characters here. The current list was taken from the above url. strValidChars = "^&'@{}[],$=!-#()%.+~_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" Dim strInvalid Dim i,char For i = 1 To Len(strFilename) char = UCase(Mid(strFilename, i, 1)) If InStr(strValidChars, char) = 0 Then strInvalid = strInvalid & ", " & char End If Next If strInvalid <> "" Then MsgBox "The following characters were invalid in your filename:" & vbCrlf & vbCrLf & strInvalid ValidateFilename = False Else ValidateFilename = True End If End Function |
Subject:
Re: Ultra-simple Windows Scripting VBS script needed
From: b_cummins-ga on 10 Dec 2005 08:53 PST |
Sorry, forgot to uncomment the RunCommand line, pelase see ameneded version below '############################################################################### '# Author: Ben Cummins '# Date: 10 December 2005 16:54 '# '# Script to parse command line parameter, validate filename and pass '# off to third party application. '############################################################################### '# Make sure here is exactly one argument. If WScript.Arguments.Count <> 1 Then MsgBox "Invalid Parameters" & vbCrlF & "Please use test.vbs <filename>" Else '# temporary variables Dim filename, newfilename, strFileName, strFilePath, indexOfLastSlash '# Get filename from the command line filename = WScript.Arguments.Item(0) '# find the last \ in the filename indexOfLastSlash = InstrRev(filename, "\") '# get the path of the file strFilePath = Mid(filename, 1, indexOfLastSlash) '# get the filename of the file strFileName = Mid(filename, indexOfLastSlash+1) '# get new filename from the user newfilename = InputBox("Please enter new filename", "Input Required", strFileName) '# make sure the user has entered something If newfilename <> "" Then '# validate the filename If ValidateFilename(newfilename) Then '# execute the command RunCommand "foobaz.exe -h higgle -i shiggle -o ""@n-" & newfilename & """" End If Else '# User entered no details. MsgBox "No input specified." End If End If '# Run a command line application Function RunCommand(strCommand) Set objShell = CreateObject("WScript.Shell") Set objScriptExec = objShell.Exec(strCommand) Set objShell = Nothing Set objScriptExec = Nothing End Function '# based on characters from http://support.microsoft.com/kb/q177506/ Function ValidateFilename(strFilename) Dim strValidChars '# Enter all valid characters here. The current list was taken from the above url. strValidChars = "^&'@{}[],$=!-#()%.+~_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" Dim strInvalid Dim i,char For i = 1 To Len(strFilename) char = UCase(Mid(strFilename, i, 1)) If InStr(strValidChars, char) = 0 Then strInvalid = strInvalid & ", " & char End If Next If strInvalid <> "" Then MsgBox "The following characters were invalid in your filename:" & vbCrlf & vbCrLf & strInvalid ValidateFilename = False Else ValidateFilename = True End If End Function |
Subject:
Re: Ultra-simple Windows Scripting VBS script needed
From: donphiltrodt-ga on 14 Dec 2005 22:23 PST |
Many thanks. Works great! Tried to find a contact for you on the web. No luck. You've removed a multi-year headache! |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |