OFF TOPIC - CMD Shell help? Anyone know of a sister site to this one?

dapar69

New Member
Joined
Feb 13, 2008
Messages
44
Need to embed a couple of commands in a CMD shell.

I know that by using "cmd.exe /k mycommand" I can create a shortcut and include the /k then my command to start a process. and I know that I can '&&' to do a second command but what I am trying to do is

cmd.exe /k ftp ftp.myserver.com loginID loginpassword

this way when I call this shortcut it automatically logs into my ftp server.

so I'm looking for a sister site to this one to find some help

thanks in advance
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
No Problem

My goal was to be able to click one button (shortcut) and have a specific file (pricelist) uploaded to my website instead of opening the command prompt, typing FTP blah.blahblah.com then enter my account, then my password, then change dir (cd www/mywebsite) then run the "PUT myfile.pdf" command to upload it ect....

Create a shortcut to CMD.exe

%windir%\system32\cmd.exe /c ftp -s:c:\www\ftptest.txt ftp.myftpserver.com

So the /c = runs a command then closes the command prompt when completed you can also use /k instead to keep it open

ftp = the command i wanted to run

the -s:path\filename = -s means you want the command to read from the txt file once invoked to get a list of commands

C:\www\ftptest.txt = my path and filename that contains all the aforementioned commands I wanted to execute in the FTP Shell. The ftptest.txt contains

myaccountid
password
cd www/anotherfolder
put myfile.pdf
quit

that's it, once the quit command is given the FTP shell terminates, then since I ran under /C the cmd shell terminates as well.

BAM! website updated

NOW, I just need a way to invoke the command from the spreadsheet!

1st Step would be to click one button (macro) and create the named PDF file, 2nd step would be to invoke the cmd shell short cut directly from Excel

Anyone know how to do that?
 
Upvote 0
Hi

Thank you for posting your solution! I always appreciate seeing using Shell (DOS) commands to get stuff to work.

To execute via a macro try the following:

Code:
Sub test()
Dim retVal
retVal = Shell(Environ$("COMSPEC") & _
    " /c ftp -s:c:\www\ftptest.txt ftp.myftpserver.com", vbNormalFocus)
End Sub
 
Upvote 0
Try this:

Code:
Sub test()
Dim retVal
retVal = Shell(Environ$("COMSPEC") & _
    " /c ftp -s:c:\www\ftptest.txt ftp.myftpserver.com", 0)
End Sub
 
Upvote 0

Forum statistics

Threads
1,225,363
Messages
6,184,519
Members
453,238
Latest member
visuvisu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top