Create a complex shortcut.

B

Brian W

I would like to create a shortcut that will do the following:

Copy a file (pre determined) to a compressed (zipped) folder, and have it
request a location for the compressed file to be placed.

Ideally, it would go like this:
-user double clicks on the shortcut,
-a destination folder dialog appears, and user selects a folder (maybe
creates a new folder),
-a predetermined file is copied to the location as a zip file (Compressed
folder)

The file to be copied will be the same every time that the shortcut is
clicked, but the destination folder will be different. Also, it would be
nice, but not necessary to allow the user to name the zipped file at the
same time..

Does anyone know a how to create a shortcut to do this? Any help would be
greatly appreciated.

Brian W.
 
K

Keith Miller

You don't need a shortcut, you need a script...I'll reply later with an example...don't have time
right now.
 
B

Brian W

Ok, thanks I appreciate it.

BW


Keith Miller said:
You don't need a shortcut, you need a script...I'll reply later with an example...don't have time
right now.

--
Good Luck,

Keith
Microsoft MVP [Windows XP Shell/User]


I would like to create a shortcut that will do the following:

Copy a file (pre determined) to a compressed (zipped) folder, and have it
request a location for the compressed file to be placed.

Ideally, it would go like this:
-user double clicks on the shortcut,
-a destination folder dialog appears, and user selects a folder (maybe
creates a new folder),
-a predetermined file is copied to the location as a zip file (Compressed
folder)

The file to be copied will be the same every time that the shortcut is
clicked, but the destination folder will be different. Also, it would be
nice, but not necessary to allow the user to name the zipped file at the
same time..

Does anyone know a how to create a shortcut to do this? Any help would be
greatly appreciated.

Brian W.
 
K

Keith Miller MVP

Well, turns out script doesn't handle creation of zip folders that well (it can be done, just not
built in to the object model). But if your "predetermined" file can be zipped ahead of time, that
would make the process very straight forward -- the bare bones would be this (copy to notepad & save
as .vbs file):

-------------------------------
dim oWshShell, oFolder
dim sZipPath, sZipFile, sPrompt, sTitle

Set oXpShell = CreateObject("Shell.Application")
sZipPath = "c:\"
sZipFile = "Master.zip"

set oFolder = oXpShell.BrowseForFolder(0, "Choose a Folder",0 ,0)

oFolder.CopyHere(sZipPath & sZipFile)

sPrompt = "If you wish to rename the compressed folder, please type the new name below:"
sTitle = "Rename Folder"

NewZipName = InputBox(sPrompt, sTitle, sZipFile)

If (NewZipName <> sZipFile ) and (NewZipName <> "") Then
set oItem = oFolder.ParseName(sZipFile)
oItem.Name = NewZipName
End If

MsgBox "Done"
--------------------------------

That will do the job, but needs error checking added. You would want to make sure that the folder
selected is part of the file system ( not a namespace item like Control Panel), that would be done
by checking 'oFolder.Self.IsFileSystem' You need to check that the user has not selected a folder
that already has a compressed folder by the same name. You need to check if the name typed by the
user is a valid filename. Etc.

If you have scripting-specific questions, you'll have better luck asking in:

microsoft.public.scripting.vbscript

You'd probably also want to check out the Script Center:

http://www.microsoft.com/technet/scriptcenter/default.mspx

--
Good Luck,

Keith
Microsoft MVP [Windows XP Shell/User]


Brian W said:
Ok, thanks I appreciate it.

BW


Keith Miller said:
You don't need a shortcut, you need a script...I'll reply later with an example...don't have time
right now.

--
Good Luck,

Keith
Microsoft MVP [Windows XP Shell/User]


I would like to create a shortcut that will do the following:

Copy a file (pre determined) to a compressed (zipped) folder, and have it
request a location for the compressed file to be placed.

Ideally, it would go like this:
-user double clicks on the shortcut,
-a destination folder dialog appears, and user selects a folder (maybe
creates a new folder),
-a predetermined file is copied to the location as a zip file (Compressed
folder)

The file to be copied will be the same every time that the shortcut is
clicked, but the destination folder will be different. Also, it would be
nice, but not necessary to allow the user to name the zipped file at the
same time..

Does anyone know a how to create a shortcut to do this? Any help would be
greatly appreciated.

Brian W.
 
D

David Candy

Set objShell = CreateObject("Shell.Application")
Set Ag=Wscript.Arguments
set WshShell = WScript.CreateObject("WScript.Shell")

Set DestFldr=objShell.NameSpace(Ag(1))
Set SrcFldr=objShell.NameSpace(Ag(0))
Set FldrItems=SrcFldr.Items
DestFldr.CopyHere FldrItems, &H214
Msgbox "Finished"

This zips/unzips. But you need a dialog when zipping (it may be asynchrous and going out of scope before it is finished). As you are prompting twice that may suffice.
--
--------------------------------------------------------------------------------------------------
Goodbye Web Diary
http://margokingston.typepad.com/harry_version_2/2005/12/thank_you_and_g.html#comments
=================================================
Keith Miller MVP said:
Well, turns out script doesn't handle creation of zip folders that well (it can be done, just not
built in to the object model). But if your "predetermined" file can be zipped ahead of time, that
would make the process very straight forward -- the bare bones would be this (copy to notepad & save
as .vbs file):

-------------------------------
dim oWshShell, oFolder
dim sZipPath, sZipFile, sPrompt, sTitle

Set oXpShell = CreateObject("Shell.Application")
sZipPath = "c:\"
sZipFile = "Master.zip"

set oFolder = oXpShell.BrowseForFolder(0, "Choose a Folder",0 ,0)

oFolder.CopyHere(sZipPath & sZipFile)

sPrompt = "If you wish to rename the compressed folder, please type the new name below:"
sTitle = "Rename Folder"

NewZipName = InputBox(sPrompt, sTitle, sZipFile)

If (NewZipName <> sZipFile ) and (NewZipName <> "") Then
set oItem = oFolder.ParseName(sZipFile)
oItem.Name = NewZipName
End If

MsgBox "Done"
--------------------------------

That will do the job, but needs error checking added. You would want to make sure that the folder
selected is part of the file system ( not a namespace item like Control Panel), that would be done
by checking 'oFolder.Self.IsFileSystem' You need to check that the user has not selected a folder
that already has a compressed folder by the same name. You need to check if the name typed by the
user is a valid filename. Etc.

If you have scripting-specific questions, you'll have better luck asking in:

microsoft.public.scripting.vbscript

You'd probably also want to check out the Script Center:

http://www.microsoft.com/technet/scriptcenter/default.mspx

--
Good Luck,

Keith
Microsoft MVP [Windows XP Shell/User]


Brian W said:
Ok, thanks I appreciate it.

BW


Keith Miller said:
You don't need a shortcut, you need a script...I'll reply later with an example...don't have time
right now.

--
Good Luck,

Keith
Microsoft MVP [Windows XP Shell/User]


I would like to create a shortcut that will do the following:

Copy a file (pre determined) to a compressed (zipped) folder, and have it
request a location for the compressed file to be placed.

Ideally, it would go like this:
-user double clicks on the shortcut,
-a destination folder dialog appears, and user selects a folder (maybe
creates a new folder),
-a predetermined file is copied to the location as a zip file (Compressed
folder)

The file to be copied will be the same every time that the shortcut is
clicked, but the destination folder will be different. Also, it would be
nice, but not necessary to allow the user to name the zipped file at the
same time..

Does anyone know a how to create a shortcut to do this? Any help would be
greatly appreciated.

Brian W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top