Running Passworded files from a batch file....

Soldato
Joined
8 Jun 2005
Posts
5,275
I've got the following batch file....

@Echo off
call TechDocs.lnk
call RDPS.lnk
start iexplore https://?????????????????
start outlook
start firefox
start iexplore https://?????????????????
call Swindon.xls.lnk
call Passwords.xls.lnk
exit

(ignore the ????'s they are work related site I've edited out.)

Both of the xls documents have passwords.

Is there a way to add the passwords to this batch file so I don't have to type them every time?

Cheers,

G
 
AFAIK the only way to open a password protected spreadsheet from a batch file is to call a VB script.

Here's how:

Open Notepad

Copy and paste the following code into the Notepad window:

Code:
Option Explicit
Dim objExcel, workbook, password_swin, password_pass
password_swin = "swindon"
password_pass = "passwords"
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set workbook = objExcel.Workbooks.Open("C:\My Documents\Swindon.xls",,,,password_swin)
Set workbook = objExcel.Workbooks.Open("C:\My Documents\Passwords.xls",,,,password_pass)

Now change lines 3 and 4 so the values in double-quotes match the passwords for your respective spreadsheets.

Amend the last two lines (the bit between the double-quotes) to match the filenames and locations of the respective spreadsheets.

Choose "File->Save As" and save the file in the same folder as your batch file, use a name like "openexcel.vbs" (or whatever name floats your boat :))

Finally, change your batch file from

Code:
call Swindon.xls.lnk
call Passwords.xls.lnk

Code:
start openexcel.vbs

Hope this helps. Any probs let me know

K
 
Nice one mate!! Works a treat :D

I still have to clock yes to the read only box, but I'm not THAT lazy yet lol

Thanks man :)
 
Glad to be of help.

If you want to be THAT lazy you can pass Excel the modify password instead of the read-only password

Change lines 3 and 4 to match the values of your "modify" passwords for the respective sheets.

Change the last two lines so that there are 5 commas instead of 4 (basically, the readonly password is the 4th parameter and the modify pasword is the 5th parameter, adding a comma shunts the value along one so we send Excel the modify password)

M
 
Back
Top Bottom