Is there any simple command to write the ip-address into a file?
I know how to write in a file, but is there a sysvar or something!?
ipconfig | find "IP Address" > out.txt
You still need to extract the IP Address from "IP Address.............: 0.0.0.0" and trim any whitespace.
Simplest i can think of:
ipconfig > file
Is this what you're looking for?
#echo on
for /f "tokens=1-2 delims=:" %%a in ('ipconfig^|find "IP Address"') do set ip=%%b
set ip=%ip:~1%
echo %ip%
For Windows 7 machines:
ipconfig | findstr /b /c:" IPv4" > output.txt
There are three whitespace characters between the opening quotation mark and IPv4 since that line technically begins with whitespace. I am unaware of a way to strip that prior to the findstr command.
Remember that, even though it's technically regular expressions, the Windows command line doesn't parse them the same way as, say, C# or whatever. There's a list of the acceptable sequences/wildcards (marked for XP, but it worked for me in a Win7 environment) here.
Took me a little trial and error, but this gets you ONLY the lines for assigned IPv4 addresses, and not the "Autoconfigured" stuff that clutters the results of other findstr iterations.
here is a vbs script that will do the job. Note that this is for the external IP address. Just look above for an internal/local ip address.
here is the code. just create a text document, paste this, and rename it to something.vbs
Const ForReading = 1
Const ForAppending = 8
Dim ipLog, objHTTP, strHTML, varStart
Dim varStop, strIP, strCurrIP, objFSO
Dim txtFile, strLine, objShell
' Log for tracking external IP addresses
ipLog = "ExternalIP.txt"
' Get current external IP address from web
Set objHTTP = CreateObject("MSXML2.XMLHTTP")
Call objHTTP.Open("GET", "http://checkip.dyndns.org", False)
objHTTP.Send()
strHTML = objHTTP.ResponseText
' Extarct IP from HTML if HTML was recieved
If strHTML <> "" Then
varStart = InStr(1, strHTML, "Current IP Address:", vbTextCompare) + 19
If varStart Then varStop = InStr(varStart, strHTML, "</body>", vbTextCompare)
If varStart And varStop Then strIP = Mid(strHTML, varStart, varStop - varStart)
Else
strIP = "Unavailable"
End If
' Remove preceeding or trailing spaces
strCurrIP = Trim(strIP)
' Check for log file and last log entry
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not (objFSO.FileExists(ipLog)) Then
' If log file doesn't exist create it
Set txtFile = objFSO.CreateTextFile(ipLog, True)
strIP = ""
Else
' Get last external IP address entry from log file
Set txtFile = objFSO.OpenTextFile(ipLog, ForReading)
Do Until txtFile.AtEndOfStream
strLine = txtFile.ReadLine
If Len(strLine) > 0 Then
strIP = strLine
End If
Loop
End If
txtFile.Close
' Extarct last external IP from log file entry
If strIP <> "" Then
varStart = 1
varStop = InStr(varStart, strIP, ",", vbTextCompare) - 1
If varStop Then strIP = Mid(strIP, varStart, varStop - varStart)
' Remove preceeding or trailing spaces
Trim(strIP)
Else
strIP = "Unavailable"
End If
' Copy IP to clipboard
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run "CMD /C ECHO " & strCurrIP & " | CLIP", 2
' Check if external IP has changed
If strCurrIP = strIP Then
' If unchanged display IP
MsgBox "External IP: " & strCurrIP & " is unchanged"
Else
' If changed log to file and display IP
Set txtFile = objFSO.OpenTextFile(ipLog, ForAppending)
txtFile.Write(strCurrIP & vbTab & vbCrLf)
txtFile.Close
MsgBox "External IP: " & strCurrIP & vbCrLf & "This IP address has been logged"
End If
' Clear variables
Set ipLog = Nothing
Set objHTTP = Nothing
Set strHTML = Nothing
Set varStart = Nothing
Set varStop = Nothing
Set strIP = Nothing
Set strCurrIP = Nothing
Set objFSO = Nothing
Set txtFile = Nothing
Set strLine = Nothing
Set objShell = Nothing
I do not take credit for this script, I just found it in a folder on my computer that I hadn't touched in a long time.
Just added a little to also display the gateway (your router) and ping to see if your DNS is working:
#echo off
:ipaddress
::Get IP address and save it to ip
for /f "tokens=1-2 delims=:" %%a in ('ipconfig^|find "IP Address"') do set ip=%%b
set ip=%ip:~1%
:gateway
::Get Gateway address and save it to gateway
for /f "tokens=1-2 delims=:" %%a in ('ipconfig^|find "Gateway"') do set gateway=%%b
set gateway=%gateway:~1%
echo IP address is %ip%
echo You router address is %gateway%
pause
cls
ping %gateway% -a
pause
:end
#echo off
PowerShell.exe -Command "(Invoke-WebRequest ifconfig.me/ip).Content.Trim()" >> ipToFile.txt
Related
I wanted to write a program in batch, which recognizes if you put in a USB stick and then automatically copies a folder. The copying was easy, but I'm struggling with recognizing the USB stick.
I've done this one but what if the USB stick has another letter and there's a hard drive on the letter "E". Also it checks only every 2 minutes. It would be nice if the program could instantly recognize the USB stick.
The code I have tried:
#echo off
goto search
:search
IF EXIST E: GOTO E
timeout /T 120 /nobreak
goto search
:F
xcopy /s F:\test\*.* C:\Users\sebas\Desktop\copied\*.*
exit
USB drives are removable disks, and can be found as follows:
Prompt>wmic logicaldisk get DeviceID, Description
Description DeviceID
Local Fixed Disk C:
Removable Disk D:
CD-ROM Disc E:
Removable Disk F:
You can get exactly the removable disks using this:
wmic logicaldisk get deviceid, description | find "Removable"
Using the link mark provided, this is How you would store the driveletter into a text file, then launch your batch program.
Include a bit of code in your Batch to recover the drive Letter and apply it to a Variable:
<StoreDriveLeterFilepath.txt (
Set /p Drive_Letter=
)
Adjust your XCOPY line to make use of the variable.
xcopy /s %Drive_Letter%\test\*.* C:\Users\sebas\Desktop\copied\*.*
The vbs code modified to store the drive into .txt and launch your Batch program.
Insert your Batch's Filepath where indicated
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set evtDevice = objWMIService.ExecNotificationQuery ("SELECT * FROM Win32_VolumeChangeEvent")
Wscript.Echo "Waiting for events ..."
Do
Set objReceivedEvent = evtDevice.NextEvent
'report an event
Wscript.Echo " Win32_Device Changed event occurred" & VBNewLine
If objReceivedEvent.EventType = 1 Then
Wscript.Echo "Type = Config Changed"
ElseIf objReceivedEvent.EventType = 2 Then
Wscript.Echo "Type = Device Arrived"
Set colItems = objWMIService.ExecQuery("Select * From Win32_Volume")
For Each objItem in colItems
If objitem.DriveType = 2 then
Wscript.Echo objItem.DriveType & " " & objItem.Name & " " & objItem.driveletter
Dim objFSO 'File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objTS 'Text Stream Object
Const ForWriting = 2
Set objTS = objFSO.OpenTextFile("StoreDriveLeterFilepath.txt", ForWriting, True)
objTS.Write ("objItem.driveletter")
objTS.Close()
Set bjFSO = Nothing 'Destroy the object.
Set objTS = Nothing 'Destroy the object.
set WshShell=createobject("wscript.shell")
WshShell.run "Your Batch Filepath Here.bat", 1, true
End If
Next
ElseIf objReceivedEvent.EventType = 3 Then
Wscript.Echo "Type = Device Left"
ElseIf objReceivedEvent.EventType = 4 Then
Wscript.Echo "Type = Computer Docked"
End If
Loop
I have a text file with a youtube link,
text file = url.txt , which consist,
https://www.youtube.com/watch?v=Videocode
my need is, by running a batch file how to get only that Videocode as output in another text file.
For example, if am running url.bat which need to convert "https://www.youtube.com/watch?v=Videocode" into "Videocode"
I hope you understand my need. Please gave me some solutions. Thanks in advance.
Taking the question as asked literally, a text file named url.txt containing a link in the format https://www.youtube.com/watch?v=Videocode, url.bat could just contain this:
#For /F "UseBackQ Tokens=2 Delims==&" %%A In ("C:\Users\niranja\Desktop\url.txt") Do #(Echo %%A)>"output.txt"
Change the path to your url.txt, C:\Users\niranja\Desktop\, to suit; or if it is in the same location as url.bat remove that path completely. The video ID you were looking for should be written to a file named output.txt in the same directory as url.bat.
Note: If question as written does not match your real intent, take a look at the link provided by Hackoo and start putting something together yourself!
Here is an idea with a vbscript using a Regex to extract the "Videocode"
Data = "https://www.youtube.com/watch?v=Videocode" & vbCrlf &_
"http://www.youtube.com/watch?v=iwGFalTRHDA" & vbCrlf &_
"http://www.youtube.com/watch?v=iwGFalTRHDA&feature=related" & vbCrlf &_
"http://youtu.be/iwGFalTRHDA" & vbCrlf &_
"http://youtu.be/n17B_uFF4cA" & vbCrlf &_
"http://www.youtube.com/embed/watch?feature=player_embedded&v=r5nB9u4jjy4" & vbCrlf &_
"http://www.youtube.com/watch?v=t-ZRX8984sc" & vbCrlf &_
"http://youtu.be/t-ZRX8984sc"
Data_Extracted = Extract(Data,"http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)(&(amp;)?[\w\?=]*)?")
WScript.echo Data_Extracted
'************************************************
Function Extract(Data,Pattern)
Dim oRE,oMatches,Match,Line
set oRE = New RegExp
oRE.IgnoreCase = True
oRE.Global = True
oRE.Pattern = Pattern
set oMatches = oRE.Execute(Data)
If not isEmpty(oMatches) then
For Each Match in oMatches
Line = Line & Match.SubMatches(0) & vbcrlf
Next
Extract = Line
End if
End Function
'************************************************
EDIT : Using an hybrid code batch with a vbscript
#echo off
Title Extract Videocode from Youtube links
Set "Tmpvbs=%temp%\Tmpvbs.vbs"
Set "InputFile=URL.txt"
Set "OutPutFile=OutPutCode.txt"
Call :Extract "%InputFile%" "%OutPutFile%"
Start "" "%OutPutFile%" & exit
::****************************************************
:Extract <InputData> <OutPutData>
(
echo Data = WScript.StdIn.ReadAll
echo Data = Extract(Data,"http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/^)([\w\-\_]*)(&(amp;)?[\w\?=]*)?"^)
echo WScript.StdOut.WriteLine Data
echo '************************************************
echo Function Extract(Data,Pattern^)
echo Dim oRE,oMatches,Match,Line
echo set oRE = New RegExp
echo oRE.IgnoreCase = True
echo oRE.Global = True
echo oRE.Pattern = Pattern
echo set oMatches = oRE.Execute(Data^)
echo If not isEmpty(oMatches^) then
echo For Each Match in oMatches
echo Line = Line ^& Match.SubMatches(0^) ^& vbcrlf
echo Next
echo Extract = Line
echo End if
echo End Function
echo '************************************************
)>"%Tmpvbs%"
cscript /nologo "%Tmpvbs%" < "%~1" > "%~2"
If Exist "%Tmpvbs%" Del "%Tmpvbs%"
exit /b
::**********************************************************************************
this is my problem:
on a Windows 2003 server I've a folder (c:\test), and every day an application put 3 new files on it.
1° file:
31201610181207000100000000630001
31201610181213000100000000440001
31201610181227000100000000630001
....
2° file:
31201610181214000100000000380002
31201610181234000100000009830002
31201610181344000100000000380002
...
3° file:
31201610181826000100000000580003
31201610190722000100000000580003
31201610191801000100000000580003
...
My goal is to replace ONLY the last 4 characters on each file with a .bat or .vbs script (0001 --> 0031) (0002 --> 0032) (0003 --> 0033).
I've done a .vbs file who works, but it search on all string and not on the last 4 characters.
Option Explicit
Dim objFSO, strFolder, objFolder, objFile
Dim strOldValue1, strNewValue1, strNewValue2, strOldValue2, strNewValue3,
strOldValue3, objRead, strContents, objWrite
Const ForReading = 1
Const ForWriting = 2
strFolder = "c:\test"
strOldValue1 = "0001"
strNewValue1 = "0031"
strOldValue2 = "0002"
strNewValue2 = "0032"
strOldValue3 = "0003"
strNewValue3 = "0033"
' I take the folder
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strFolder)
' I count the file on the folder
For Each objFile In objFolder.Files
' Read file with textstream object.
Set objRead = objFSO.OpenTextFile(objFile.Path, ForReading)
' Trap error if file is empty or cannot read.
On Error Resume Next
strContents = objRead.readall
If (Err.Number <> 0) Then
On Error GoTo 0
Wscript.Echo "Cannot read: " & objFile.Path
strContents = ""
End If
On Error GoTo 0
objRead.Close
' check what's is inside the folder
If (InStr(strContents, strOldValue1) > 0) Then
strContents = Replace(strContents, strOldValue1, strNewValue1)
Set objWrite = objFSO.OpenTextFile(objFile.Path, ForWriting)
objWrite.Write strContents
objWrite.Close
End If
If (InStr(strContents, strOldValue2) > 0) Then
strContents = Replace(strContents, strOldValue2, strNewValue2)
Set objWrite = objFSO.OpenTextFile(objFile.Path, ForWriting)
objWrite.Write strContents
objWrite.Close
End If
If (InStr(strContents, strOldValue3) > 0) Then
strContents = Replace(strContents, strOldValue3, strNewValue3)
Set objWrite = objFSO.OpenTextFile(objFile.Path, ForWriting)
objWrite.Write strContents
objWrite.Close
End If
next
Thanks for any help!!
Here is a short batch script, which immediately modifies all files C:\test\*.* accordingly:
for %%F in ("C:\test\*.*") do (
for /F "delims=" %%L in ('type "%%~F" ^& ^> "%%~F" rem/') do (
set "LINE=%%L"
setlocal EnableDelayedExpansion
set "LEFT=!LINE:~,-4!"
set "RIGHT=!LINE:~-4!"
if "!RIGHT!"=="0001" set "RIGHT=0031"
if "!RIGHT!"=="0002" set "RIGHT=0032"
if "!RIGHT!"=="0003" set "RIGHT=0033"
>> "%%~F" echo(!LEFT!!RIGHT!
endlocal
)
)
Using JREPL.BAT - a regular expression find/replace utility
for %%F in (c:\test\*) do call jrepl "000(?=[123]$)" "003" /f "%%F" /o -
The above looks at the end of each line for "000" before a "1", "2", or "3", and substitutes "003" for the "000".
JREPL is pure script (hybrid batch/JScript) that runs natively on any Windows machine from XP onward - No 3rd party exe file required.
Thank you very much!!!! it works!!
Also, if you're interested I've found how the make my script work:
I've to add the & VBCrlf to the variable, in this way the script will search for the value + the new line.
strOldValue1 = "0001" & VBCrlf
strNewValue1 = "0031" & VBCrlf
strOldValue2 = "0002" & VBCrlf
strNewValue2 = "0032" & VBCrlf
strOldValue3 = "0003" & VBCrlf
strNewValue3 = "0033" & VBCrlf
I have a list of folder paths that I want to loop through and get the files and creation date and then send a email notification that these files have been uploaded to the ftp. I have got everything working but I am having trouble looping through the folders to get the files. I think it loops through the text file but by the time i get to my second loop I think it is only looping through the last path that was in the text doc as the variable was getting overwritten. I tried enclosing the second for statement with parentheses for the first for statement but did not work. Here is my code:
scanFTPCLients.bat
#echo off
setlocal EnableDelayedExpansion
cls
#pushd %~dp0
set i=0
for /F "tokens=*" %%i in (Pathlist.txt) do (
set fp=%%i
set LIST=
for /r "%fp%" %%a in (*.*) do set i=i+1
set LIST=!LIST! ---%deptClient%--- %%~na ----UPLOAD TIME---- %%~ta
)
set LIST=%LIST:~1%
IF %i% NEQ 0 (wscript "%~dp0FTPFilesUploadedNotification.vbs")
popd
Pathlist.txt
\\vavm\CINICO\Incoming
\\vavm\CIS\Incoming
\\vavm\Forcht\Incoming
\\vavm\HPC\Incoming
\\vavm\K\Incoming
\\vavm\MWEmpCC\Incoming
\\vavm\National Labor Benefits\Incoming
\\vavm\PeriSons\Incoming
\\vavm\US\Incoming
\\vavm\K\Incoming
FTPFilesNotification.vbs
dim outputArray
dim inputText
dim message
inputText = CreateObject("WScript.Shell").ExpandEnvironmentStrings("%LIST%")
outputArray = split(inputText, " ")
for each x in outputArray
message = message & x & vbCRLF
next
Set MyEmail=CreateObject("CDO.Message")
MyEmail.Subject="Clients Imported to System"
MyEmail.From="SYSTEMFUNCTION#mrsllc.org"
MyEmail.To="rickg#gmail.com"
MyEmail.TextBody= "The Following Clients have been imported to the system: " & vbCRLF & message
MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="mail.org"
MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")=1
MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername")="username"
MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword")="password"
MyEmail.Configuration.Fields.Update
MyEmail.Send
set MyEmail=nothing
For comparison, in PowerShell, it could be:
$emailSettings = #{
From = "you#example.org"
To = "you#example.org"
Subject = "Upload report"
SmtpServer = "yourmailserver"
}
$report = dir -Path #(gc pathlist.txt) | select FullName, CreationTime
Send-MailMessage #emailSettings -Body "$($report|ConvertTo-Html)" -BodyAsHtml
This shows how to loop through files in vbscript
'On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Dirname = InputBox("Enter Dir name")
'Searchterm = Inputbox("Enter search term")
ProcessFolder DirName
Sub ProcessFolder(FolderPath)
On Error Resume Next
Set fldr = fso.GetFolder(FolderPath)
Set Fls = fldr.files
For Each thing in Fls
' Set contents = thing.OpenAsTextStream
' If err.number = 0 then
' If Instr(contents.readall, searchterm) > 1 then msgbox thing.path
' Else
' err.clear
' End If
msgbox Thing.Name & " " & Thing.DateLastModified
Next
Set fldrs = fldr.subfolders
For Each thing in fldrs
ProcessFolder thing.path
Next
End Sub
To send mail
Set emailObj = CreateObject("CDO.Message")
emailObj.From = "dc#gail.com"
emailObj.To = "dc#gail.com"
emailObj.Subject = "Test CDO"
emailObj.TextBody = "Test CDO"
Set emailConfig = emailObj.Configuration
msgbox emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver")
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "YourUserName"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Password1"
emailConfig.Fields.Update
emailObj.Send
If err.number = 0 then Msgbox "Done"
To read a file line by line
On Error Resume Next
Set Fso = CreateObject("Scripting.FileSystemObject")
Set File = Fso.CreateTextFile("C:\myfile.txt", True)
If err.number <> 0 then
Wscript.Echo "Error: " & err.number & " " & err.description & " from " & err.source
err.clear
wscript.exit
End If
Do Until File.AtEndOfStream
Msgbox File.readline
Loop
Changed. Not sure what you want to do about sending lines (one at a time or send all when done). If one at a time, integrate into this. If all at once at end, then send output to a temp file and send it.
#echo off
pushd %~dp0
set /A Cnt=0
for /F "tokens=*" %%i in (Pathlist.txt) do (
echo i= %%i
for /f "usebackq tokens=*" %%a in (`Dir /s /b %%i\*.*`) do (
echo %%~na - %%~ta
set /A Cnt+=1
)
)
echo(Cnt=%Cnt%
pause
popd
I have a batch file which is used by dragging a folder containing .mp3s into the batch.
#echo off
cd %~dp0
setlocal enabledelayedexpansion enableextensions
set FLDR="%1"
if not defined FLDR ( echo Drag a folder to the batch to play its contents.
pause
goto:EOF )
for %%x in (%FLDR%\*.mp3) do set "MP3=!MP3! "%%x""
mp3player %MP3%
pause
It works fine with actual folders, but when dragging shortcuts, the variable %FLDR% ends up as "c:\link location\folder.lnk" instead of the actual folder location.
I have no idea how to get around this.
Here is a way to get the target using a little hybrid VBS/Batch file function.
#echo off
setlocal
Call :GetTarget "%~1" tgt
echo %tgt%
pause
exit /b
:GetTarget
#echo off & setlocal
set gt=%temp%\_.vbs
echo set WshShell = WScript.CreateObject("WScript.Shell")>%gt%
echo set Lnk = WshShell.CreateShortcut(WScript.Arguments.Unnamed(0))>>%gt%
echo wscript.Echo Lnk.TargetPath>>%gt%
set script=cscript //nologo %gt%
For /f "delims=" %%a in ( '%script% "%~1"' ) do set target=%%a
del %gt%
endlocal & set %~2=%target%
exit /b
HYBRID SCRIPT! No silly little temporary files.
::'<SUB>#echo off
::'<SUB>set shortcut=%~1
::'<SUB>if not defined shortcut goto 'usage
::'<SUB>if not %shortcut:~-4%==.lnk (if not %shortcut:~-4%==.url (set errorlevel=1
::'<SUB>goto 'usage ))
::'<SUB>if not exist %shortcut% (echo Error: Nonexistent shortcut
::'<SUB>set errorlevel=1
::'<SUB>goto:EOF )
::'<SUB>setlocal
::'<SUB>for /f "delims=" %%T in ('cscript //nologo //e:vbs %~nx0 "%shortcut%"') do set thing=%%T
::'<SUB>endlocal & set shortcut=%thing%
::'<SUB>goto:EOF
:'usage
::'<SUB>echo command-line shortcut redirect utility
::'<SUB>echo Usage: shortcut [file.lnk ^| file.url]
::'<SUB>echo The resulting link will be output to the %%shortcut%% variable.
::'<SUB>goto:EOF
set WshShell = WScript.CreateObject("WScript.Shell")
set Lnk = WshShell.CreateShortcut(WScript.Arguments.Unnamed(0))
wscript.Echo Lnk.TargetPath
Where <SUB> indicates the substitute character.
UPDATE: I found a much fully vbscript solution over at Wayne's World of IT, and modified it slightly to suit my needs:
If WScript.Arguments.UnNamed.Count = 1 Then
strShortcut = WScript.Arguments.UnNamed(0)
Else
WScript.Echo "Please supply the name of an lnk file or directory to read, eg c:\test.lnk or c:\shortcuts"
WScript.Quit(1)
End If
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strShortCut) Then
Set objFolder = objFSO.getFolder(strShortcut)
For Each objfile in objFolder.Files
If objfile.type = "Shortcut" Then
Call Readshortcut(objFile.Path, strProperties)
dtmCreationDate = objFile.DateCreated
WScript.Echo dtmCreationDate & "," & strProperties
End If
Next
ElseIf objFSO.FileExists(strShortCut) Then
Call Readshortcut(strShortcut, strProperties)
WScript.Echo strProperties
Else
WScript.Echo "Error: Could not read '" & strShortcut & "'"
WScript.Quit(2)
End If
Set objFSO = Nothing
Function Readshortcut(ByRef strShortcut, ByRef strProperties)
set objWshShell = WScript.CreateObject("WScript.Shell")
set objShellLink = objWshShell.CreateShortcut(strShortcut)
strProperties = objShellLink.TargetPath & " " & objShellLink.Arguments
Set objShellLink = Nothing
Set objWshshell = Nothing
End Function