Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Noob needs help!!!

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,23723
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Noob needs help!!!
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Noob needs help!!! - 7/18/2005 7:54:31 PM   
  warriorbax

 

Posts: 3
Score: 0
Joined: 7/18/2005
Status: offline
I need help with a small scripting issue. I am totally new to scripting, have a little bit of C++ knowledge. I am trying to ultimatly display the contents of a folder in one message box. the code i have right now displays it in many message boxes and i dont really want this. here is the code: (sorry to who i stole it from but it was up on the internet)

Function FnListfiles (Directory)
Dim Fso,f,file

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(Directory)

 For Each file In f.Files
 wscript.echo File.Name
Next
End Function
 
FnListfiles "C:\Winamp\Playlists"

WScript.Quit(0)

Like i said before, this ultimatly needs to go into this script (in the text box):

Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
Dim Message
Message = InputBox("Name of play list:","Load Play list")
FileSource="C:\winamp\Playlists\" & Message & ".m3u"
FileDest="c:\winamp\winamp.m3u"
Set WshShell = CreateObject( "WScript.Shell" )
dim oShell
set oShell= Wscript.CreateObject("WScript.Shell")
oShell.Run "runas /user:jukebox ""c:\winamp\StopWinamp.bat"""
WScript.Sleep 100
oShell.Sendkeys "*****"
WScript.Sleep 500
oFso.CopyFile FileSource,FileDest
WScript.Sleep 300
set oShell= Wscript.CreateObject("WScript.Shell")
oShell.Run "runas /user:jukebox ""c:\winamp\StartWinamp.bat"""
WScript.Sleep 100
oShell.Sendkeys "****"
WScript.Sleep 3000
WScript.echo "Play list has been changed to: " & Message
Set oFSO=Nothing


Any help would be greatly appreciated!!!
 
 
Post #: 1
 
 RE: Noob needs help!!! - 7/18/2005 9:55:43 PM   
  Whitestar

 

Posts: 8
Score: 0
Joined: 7/18/2005
Status: offline
What you need to to is place the echo statement outside the loop. There are several ways of showing all the contents in one box. The simplest is just to add each filename to a string.

Function FnListfiles (Directory)
Dim Fso,f,file,fList

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(Directory)
fList = ""
For Each file In f.Files
    fList=fList & File.Name & chr(10)
Next
wscript.echo fList
End Function

< Message edited by Whitestar -- 7/18/2005 9:59:14 PM >

(in reply to warriorbax)
 
 
Post #: 2
 
 RE: Noob needs help!!! - 7/18/2005 10:37:28 PM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
quote:

set oShell= Wscript.CreateObject("WScript.Shell")
If you set the following line at the top of your Script, that would be much neeter and won't use any extra memory

_____________________________

For more information, please see the "Read me First" topic.

http://www.visualbasicscript.com

(in reply to warriorbax)
 
 
Post #: 3
 
 RE: Noob needs help!!! - 7/19/2005 6:22:56 AM   
  warriorbax

 

Posts: 3
Score: 0
Joined: 7/18/2005
Status: offline
No how would I put that into a web page (HTML) so that you could push a button and it would start? This is what i have but doesnt quite do the trick:

<input type="BUTTON" name="Exec1" value="Run me" language="vbs" onclick="version">
<script language="vbs">
Sub version

Insert script coding here.....

End sub
</script>

(in reply to Whitestar)
 
 
Post #: 4
 
 RE: Noob needs help!!! - 7/19/2005 9:23:34 AM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
you would start off of creating a HTA file, mostly b/c of the FSO part ....

just copy / paste your code.... that's it :)

<input type="button" ID="Exec1" value="Run me">

...

Sub Exec1_onClick()

' your code comes here

End Sub

_____________________________

For more information, please see the "Read me First" topic.

http://www.visualbasicscript.com

(in reply to warriorbax)
 
 
Post #: 5
 
 RE: Noob needs help!!! - 7/19/2005 7:26:32 PM   
  warriorbax

 

Posts: 3
Score: 0
Joined: 7/18/2005
Status: offline
that doesnt make much sence to me. do i put my code into the webpage or make an hta then link to it? This is the code that i have:

Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
Function FnListfiles (Directory)
Dim Fso,f,file,fList,Message
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(Directory)
fList = ""
For Each file In f.Files
  fList=fList & File.Name & chr(10)
Next
Message = InputBox(fList,"Load Play list (Type exactly as listed)")
FileSource="C:\winamp\Playlists\" & Message
FileDest="c:\winamp\winamp.m3u"
if Message = "" then
WScript.echo "Playlist has not been changed"
WScript.Quit(0)
else
Set WshShell = CreateObject( "WScript.Shell" )
dim oShell
set oShell= Wscript.CreateObject("WScript.Shell")
oShell.Run "runas /user:jukebox ""c:\winamp\StopWinamp.bat"""
WScript.Sleep 100
oShell.Sendkeys "****~"
WScript.Sleep 500
oFso.CopyFile FileSource,FileDest
WScript.Sleep 300
set oShell= Wscript.CreateObject("WScript.Shell")
oShell.Run "runas /user:jukebox ""c:\winamp\StartWinamp.bat"""
WScript.Sleep 100
oShell.Sendkeys "****~"
WScript.Sleep 3000
WScript.echo "Play list has been changed to: " & Message
Set oFSO=Nothing
End If
End Function
Songs = FnListfiles ("C:\Winamp\Playlists") 

When run, it allows the playlists that are located in the playlists folder to be displayed and a user can type in the name of the play list and it will replace the current winamp one with the one that was requested. currently i am running it as a script from the desktop. what i need is a way to incorperate this into a webpage so that when a user clicks a link or button it will run this script within the webpage. i looked up the hta format but it doesnt seem to be working form me. sorry if i was not clear with what i wanted to do. maybe i just dont understand what your talking about but either way what am i supposed to do with the code?

thanks
-bax

< Message edited by warriorbax -- 7/19/2005 7:47:08 PM >

(in reply to Snipah)
 
 
Post #: 6
 
 RE: Noob needs help!!! - 7/19/2005 9:19:51 PM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
no problem, you mentioned that you do not know alot about VBS....here is the HTA that you will need. Save this for future development:

<HTML>
<HEAD>
<HTA:APPLICATION ID="oWinAmpPL"
APPLICATIONNAME="Winamp_Playlist"
BORDER="dialog"
BORDERSTYLE = "normal"
CAPTION="yes"
CONTEXTMENU = "no"
ICON="library.ico"
INNERBORDER = "yes"
MAXIMIZEBUTTON = "no"
MINIMIZEBUTTON = "yes"
SCROLL = "auto"
SCROLLFLAT = "yes"
SELECTION = "no"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
VERSION="1.0"
WINDOWSTATE="normal" />
<TITLE>Winamp Playlist</TITLE>
<SCRIPT LANGUAGE="VBScript">
<!--
Sub FnListfiles_onClick()
Dim oShell, oFSO, f, FileSource, FileDest, fList, Message
set oShell= CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set f = oFSO.GetFolder("C:\Winamp\Playlists")
fList = ""
For Each file In f.Files
fList=fList & File.Name & chr(10)
Next
datarea.innerhtml = fList
Message = InputBox(fList,"Load Play list (Type exactly as listed)")
FileSource="C:\winamp\Playlists\" & Message & ".m3u"
FileDest="c:\winamp\winamp.m3u"
if Message = "" then
WScript.echo "Playlist has not been changed"
WScript.Quit(0)
else
oShell.Run "runas /user:jukebox ""c:\winamp\StopWinamp.bat"""
WScript.Sleep 100
oShell.Sendkeys "****~"
WScript.Sleep 500
oFso.CopyFile FileSource,FileDest
WScript.Sleep 300
oShell.Run "runas /user:jukebox ""c:\winamp\StartWinamp.bat"""
WScript.Sleep 100
oShell.Sendkeys "****~"
WScript.Sleep 3000
WScript.echo "Play list has been changed to: " & Message

'*** clean up
Set oShell = Nothing
Set oFSO=Nothing
Set f = Nothing
End If
End Sub
-->
</SCRIPT>
</HEAD>
<BODY background="ns-logo.gif"><BASEFONT FACE="Times New Roman","Arial">
<p><br><br><p>
<input type="button" ID="FnListfiles" value="Winamp Playlist editor">
<div ID="DataArea">
</div>
</BODY>
</HTML>

_____________________________

For more information, please see the "Read me First" topic.

http://www.visualbasicscript.com

(in reply to warriorbax)
 
 
Post #: 7
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Noob needs help!!! Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts