Re: convert to vbs
- From: "Harvey Colwell" <HarveyColwell@xxxxxxxxxxxxx>
- Date: Fri, 26 Oct 2007 14:53:46 -0500
I need to know how I can convert this batch file to vbs and to make sure that it copies the file to the "All Users" profile on the system... any help would be appreciated...
Copy "\\servername\NETLOGON\URL\propertyinfo.url" "%userprofile%\desktop\"
Copy "\\servername\NETLOGON\URL\afw customer form.url" "%userprofile%\desktop\"
Here's a generic "Push to Desktop" script I wrote a while back. Just pass it the full path of the file you want to push out as the first command line parameter. i.e.
cscript //nologo "Push To Desktop.vbs" "\\servername\NETLOGON\URL\propertyinfo.url"
cscript //nologo "Push To Desktop.vbs" "\\servername\NETLOGON\URL\afw customer form.url"
Line 26 is the vbScript equivalent to the DOS "copy" command.
NOTE: Each line of the script is numbered. If any is not, it was wrapped by your email client. Append any such lines to the line directly above them then remove the line numbers.
[--- Begin: Push to Desktop.VBS ---]
001. ' Windows Script Host - VBScript
002. '---------------------------------------------------------
003. ' Name: Push To Desktop.VBS
004. ' By: Harvey Colwell
005. ' Version: 1.0
006. ' CopyRight: (c) Apr 2002, All Rights Reserved!
007. '
008. '*********************************************************
009. Option Explicit
010.
011. Dim oWS, oFS
012.
013. Set oWS = WScript.CreateObject("WScript.Shell")
014. Set oFS = WScript.CreateObject("Scripting.FileSystemObject")
015.
016. Dim bDebug, sFile, sDest
017.
018. bDebug = FALSE
019.
020. If Not WSCript.Arguments.Count < 1 Then
021. sFile = WSCript.Arguments(0)
022. sDest = oWS.ExpandEnvironmentStrings("%ALLUSERSPROFILE%") & "\Desktop\"
023.
024. If IsFile(sFile) Then
025. If IsFolder(sDest) Then
026. oFS.CopyFile sFile, sDest, True
027. Else
028. ShowMsg "The All User Desktop Could not be found!" & vbCrLf & sFIle
029. End If
030. Else
031. ShowMsg "The specified file does not exist!" & vbCrLf & sFIle
032. End If
033.
034. Else
035. ShowMsg "No file was specified on the command line!"
036. End If
037.
038. Set oWS = Nothing
039. Set oFS = Nothing
040. WScript.Quit
041.
042. '---------------------
043. Sub ShowMsg(sMsg)
044. If bDebug Then MsgBox "ERROR: " & sMsg, vbInformation, "Debug Message"
045. End Sub
046.
047. '---------------------
048. Function IsFolder(fName)
049. If oFS.FolderExists(fName) Then IsFolder = True Else IsFolder = False
050. End Function
051.
052. '---------------------
053. Function IsFile(fName)
054. If oFS.FileExists(fName) Then IsFile = True Else IsFile = False
055. End Function
[--- End: Push to Desktop.VBS ---]
.
- Follow-Ups:
- Re: convert to vbs
- From: Gavin
- Re: convert to vbs
- References:
- convert to vbs
- From: Gavin
- convert to vbs
- Prev by Date: detecting DVD-video
- Next by Date: Re: convert to vbs
- Previous by thread: convert to vbs
- Next by thread: Re: convert to vbs
- Index(es):
Relevant Pages
|