Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,783 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,438 people online right now. Registration is fast and FREE... Join Now!




vbs file?

 
Reply to this topicStart new topic

vbs file?

StunnaBeats
15 Aug, 2008 - 03:04 PM
Post #1

New D.I.C Head
*

Joined: 15 Aug, 2008
Posts: 3

Ok, I don't know much about doing vbs files. I'm trying to make a vbs that moves a file to the computer's startup folder, and then open's up another file (IN THAT ORDER). Help please?
User is offlineProfile CardPM
+Quote Post

dineeshd
RE: Vbs File?
16 Aug, 2008 - 01:40 AM
Post #2

D.I.C Addict
Group Icon

Joined: 30 Jun, 2008
Posts: 578



Thanked: 16 times
Dream Kudos: 575
My Contributions
Moving File...

vb
dim fso

Set ws = WScript.CreateObject("WScript.Shell")

fso.MoveFile "c:\file.txt", "C:\Documents and Settings\All Users\Start

Menu\Programs\Startup\"

set fso = Nothing


Opening an exe file...

vb
dim objShell
dim strCommand

set objShell = WScript.CreateObject("Wscript.Shell")
strCommand = CHR(34) & "C:\FILE.exe" & CHR(34)
objShell.run strCommand ,6 ,"FALSE"

set objShell = Nothing


Opening other files....

vb
dim objShell, file_path, PROGRAME_PATH 

Set objShell = WScript.CreateObject("WScript.Shell")

PROGRAME_PATH = "C:\Program Files\Microsoft Office\Office"

file_path = CHR(34) & "C:\file.doc" & CHR(34)

objShell.Run CHR(34) & PROGRAME_PATH & "\winword.exe" & CHR(34) & file_path, 0, "FALSE"


Here you need to specify the path(PROGRAME_PATH) and exe file name bases on the file association.

Hope this helps...... biggrin.gif

User is offlineProfile CardPM
+Quote Post

StunnaBeats
RE: Vbs File?
18 Aug, 2008 - 12:35 PM
Post #3

New D.I.C Head
*

Joined: 15 Aug, 2008
Posts: 3

QUOTE(dineeshd @ 16 Aug, 2008 - 02:40 AM) *

Moving File...

vb
dim fso

Set ws = WScript.CreateObject("WScript.Shell")

fso.MoveFile "c:\file.txt", "C:\Documents and Settings\All Users\Start

Menu\Programs\Startup\"

set fso = Nothing


Opening an exe file...

vb
dim objShell
dim strCommand

set objShell = WScript.CreateObject("Wscript.Shell")
strCommand = CHR(34) & "C:\FILE.exe" & CHR(34)
objShell.run strCommand ,6 ,"FALSE"

set objShell = Nothing


Opening other files....

vb
dim objShell, file_path, PROGRAME_PATH 

Set objShell = WScript.CreateObject("WScript.Shell")

PROGRAME_PATH = "C:\Program Files\Microsoft Office\Office"

file_path = CHR(34) & "C:\file.doc" & CHR(34)

objShell.Run CHR(34) & PROGRAME_PATH & "\winword.exe" & CHR(34) & file_path, 0, "FALSE"


Here you need to specify the path(PROGRAME_PATH) and exe file name bases on the file association.

Hope this helps...... biggrin.gif




I tried the code to move files, but it didnt work. It gave me an error. I save it as a vbs right??

Here's wat i put:

CODE

dim fso  
  
Set ws = WScript.CreateObject("WScript.Shell")  
  
fso.MoveFile "C:\Users\richard\Desktop\file.txt", "C:\Documents and Settings\All Users\Start  
  
Menu\Programs\Startup\"  
  

User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Vbs File?
18 Aug, 2008 - 01:36 PM
Post #4

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,997



Thanked: 125 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Well what error did it give?
User is offlineProfile CardPM
+Quote Post

StunnaBeats
RE: Vbs File?
19 Aug, 2008 - 01:06 PM
Post #5

New D.I.C Head
*

Joined: 15 Aug, 2008
Posts: 3

QUOTE(PsychoCoder @ 18 Aug, 2008 - 02:36 PM) *

Well what error did it give?


it said something like "Expected error" or something, and it said the line number and like character 64
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Vbs File?
19 Aug, 2008 - 01:10 PM
Post #6

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,997



Thanked: 125 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
@StunnaBeats:

We need to know what error before we can even start helping.
User is offlineProfile CardPM
+Quote Post

dineeshd
RE: Vbs File?
20 Aug, 2008 - 12:23 AM
Post #7

D.I.C Addict
Group Icon

Joined: 30 Jun, 2008
Posts: 578



Thanked: 16 times
Dream Kudos: 575
My Contributions
You need to tell the exact error message and the procedure you followed to execute the script.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 12:59PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month