WScript.Quit
Wscript.Echo "hello world"
Set Application = CreateObject("Shell.Application")
If WScript.Arguments.Length = 0 Then
Application.ShellExecute "wscript.exe", """" & WScript.ScriptFullName & """ RunAsAdministrator", , "runas", 1
WScript.Quit
End if
Set Shell = CreateObject("Wscript.Shell")
timeout = 15 ' seconds. 0 = no timeout
intReturn = Shell.Popup("Click Yes or No!", timeout, "My Title", vbYesNo + vbQuestion)
If (intReturn = vbYes) Then
Wscript.Echo "Yes was clicked"
End If
If (intReturn = vbNo) Then
Wscript.Echo "No was clicked"
End If
If (intReturn = -1) Then
Wscript.Echo "Popup timed out"
End If
Function FuncName(sText)
Wscript.Echo sText
End Function
FuncName("abc")
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
ROOT = FileSystemObject.GetParentFolderName(Wscript.ScriptFullName)
FileSystemObject.BuildPath("C:/", "/test.txt") ' => C:/test.txt
FileSystemObject.BuildPath("C:/", "test.txt") ' => C:/test.txt
set FileSystemObject = CreateObject("Scripting.FileSystemObject")
ROOT = FileSystemObject.GetAbsolutePathName(".")
Set Shell = CreateObject("WScript.Shell")
windir = Shell.ExpandEnvironmentStrings("%windir%")
Set Shell = CreateObject("WScript.Shell")
profiledir = Shell.ExpandEnvironmentStrings("%userprofile%")
set FileSystemObject = CreateObject("Scripting.FileSystemObject")
ROOT = FileSystemObject.GetAbsolutePathName(".")
Set file = FileSystemObject.CreateTextFile(ROOT + "/test.txt", True)
file.WriteLine("This is a test.")
file.Close
set FileSystemObject = CreateObject("Scripting.FileSystemObject")
ROOT = FileSystemObject.GetAbsolutePathName(".")
STR = FileSystemObject.OpenTextFile(ROOT + "/test.txt").ReadAll
set FileSystemObject = CreateObject("Scripting.FileSystemObject")
ROOT = FileSystemObject.GetAbsolutePathName(".")
Set FILE = FileSystemObject.OpenTextFile(ROOT + "/test/test.txt")
Do Until FILE.AtEndOfStream
WScript.Echo FILE.ReadLine
Loop
FILE.Close
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
ROOT = FileSystemObject.GetAbsolutePathName(".")
FileSystemObject.MoveFile ROOT + "/test.txt", ROOT + "/test_2.txt"
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
ROOT = FileSystemObject.GetAbsolutePathName(".")
FileSystemObject.CopyFile ROOT + "/test.txt", ROOT + "/test_2.txt"
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
ROOT = FileSystemObject.GetAbsolutePathName(".")
FileSystemObject.DeleteFile ROOT + "/test.txt"
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
If FileSystemObject.FileExists("C:/test.txt") Then
WScript.Echo("yes")
Else
WScript.Echo("no")
End If
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
If FileSystemObject.FolderExists("C:/") Then
WScript.Echo("yes")
Else
WScript.Echo("no")
End If
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
ROOT = FileSystemObject.GetAbsolutePathName(".")
For Each file in FileSystemObject.GetFolder(ROOT).files
file_Name = file.Name
file_DateCreated = file.DateCreated
file_DateLastAccessed = file.DateLastAccessed
file_DateLastModified = file.DateLastModified
file_ParentFolder = file.ParentFolder
file_Path = file.Path
file_Size = file.Size
file_Type = file.Type
file_Extension = FileSystemObject.GetExtensionName(file.Name)
Next
set FileSystemObject = CreateObject("Scripting.FileSystemObject")
ROOT = FileSystemObject.GetAbsolutePathName(".")
FileSystemObject.CreateFolder(ROOT + "/test")
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
ROOT = FileSystemObject.GetAbsolutePathName(".")
FileSystemObject.MoveFolder ROOT + "/test", ROOT + "/test_2"
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
ROOT = FileSystemObject.GetAbsolutePathName(".")
FileSystemObject.CopyFolder ROOT + "/test", ROOT + "/test_2"
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
ROOT = FileSystemObject.GetAbsolutePathName(".")
FileSystemObject.DeleteFolder ROOT + "/test"
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
If FileSystemObject.FolderExists("C:/test") Then
WScript.Echo("yes")
Else
WScript.Echo("no")
End If
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
ROOT = FileSystemObject.GetAbsolutePathName(".")
For Each folder in FileSystemObject.GetFolder(ROOT).SubFolders
folder_Name = folder.Name
folder_DateCreated = folder.DateCreated
folder_DateLastAccessed = folder.DateLastAccessed
folder_DateLastModified = folder.DateLastModified
folder_Size = folder.Size
Next
Set Shell = CreateObject("WScript.Shell")
Shell.Run("REG.EXE IMPORT " + Chr(34) + "C:/test.reg" + Chr(34))
Set Shell = CreateObject("WScript.Shell")
Shell.Run("reg delete " + Chr(34) + "HKEY_CURRENT_USER\path\to\key" + Chr(34) + " /f")
Set Shell = WScript.CreateObject ("WScript.Shell")
Shell.run ""
Set Shell = WScript.CreateObject("WScript.Shell")
link_location = Shell.ExpandEnvironmentStrings("%userprofile%") + "\Desktop\notepad.lnk"
link_target = Shell.ExpandEnvironmentStrings("%windir%") + "\System32\notepad.exe"
link_icon = Shell.ExpandEnvironmentStrings("%windir%") + "\system32\notepad.exe, 0"
Set lnk = Shell.CreateShortcut(link_location)
lnk.IconLocation = link_icon
lnk.TargetPath = link_target
lnk.Save
Set lnk = Nothing 'Clean up
Set Shell = WScript.CreateObject("WScript.Shell")
link_location = Shell.ExpandEnvironmentStrings("%userprofile%") + "\Desktop\system32.lnk"
link_target = Shell.ExpandEnvironmentStrings("%windir%") + "\System32"
link_icon = Shell.ExpandEnvironmentStrings("%windir%") + "\explorer.exe, 0"
Set lnk = Shell.CreateShortcut(link_location)
lnk.IconLocation = link_icon
lnk.TargetPath = link_target
lnk.Save
Set lnk = Nothing 'Clean up
That means shortcut acts like folder. Meaning - no folder with links name can be created in the same directory.
Set Shell = CreateObject("WScript.Shell")
link_location = Shell.ExpandEnvironmentStrings("%userprofile%") + "\Desktop"
link_target = Shell.ExpandEnvironmentStrings("%windir%") + "\System32"
Shell.run "cmd.exe /C mklink /J """ + link_location + """ """ + link_target + """ ", 0, False
Removes junction without removing source folder
link_location = Shell.ExpandEnvironmentStrings("%userprofile%") + "\Desktop\System32"
Shell.run "cmd.exe /C rmdir """ + link_location + """ ", 0, False
On Error Resume Next ' rescue from errors from this point on
' code with error
On Error Goto 0 ' stop rescueing errors
Replace("123", "1", "a") ' => "a23"
Len("abc") ' => 3
Ucase("abc") ' => "ABC"
Lcase("ABC") ' => "abc"
Left("abc", 1) ' => "a"
Right("abc", 1) ' => "c"
IsNull(variable)
Set CommandLineArguments = WScript.Arguments
CommandLineArgumentsCount = CommandLineArguments.Count
If CommandLineArgumentsCount = 0 Then
MsgBox "No Arguments"
Else
For Each arg in CommandLineArguments
MsgBox arg
Next
End If
days=Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
days_count = (UBound(days) + 1)
MsgBox days_count