上传文件至「/」
This commit is contained in:
126
Start-NoMachine.vbs
Normal file
126
Start-NoMachine.vbs
Normal file
@@ -0,0 +1,126 @@
|
||||
Option Explicit
|
||||
|
||||
Const WINDOW_NORMAL = 1
|
||||
|
||||
Dim shell, fileSystem, processEnvironment
|
||||
Dim profileRoot, nxRoot, roamingAppData, localAppData, tempDirectory
|
||||
Dim installDirectory, executablePath, requiredDirectories
|
||||
Dim index, launchResult, errorNumber, errorText
|
||||
Dim arguments, argumentCount, launchCommand, launchMode, launchFile
|
||||
|
||||
Set shell = CreateObject("WScript.Shell")
|
||||
Set fileSystem = CreateObject("Scripting.FileSystemObject")
|
||||
Set arguments = WScript.Arguments
|
||||
|
||||
profileRoot = "C:\Users\Public\Documents\NoMachineProfile"
|
||||
nxRoot = profileRoot & "\.nx"
|
||||
roamingAppData = profileRoot & "\AppData\Roaming"
|
||||
localAppData = profileRoot & "\AppData\Local"
|
||||
tempDirectory = localAppData & "\Temp"
|
||||
installDirectory = "C:\Program Files\NoMachine"
|
||||
executablePath = installDirectory & "\bin\nxplayer.exe"
|
||||
|
||||
requiredDirectories = Array( _
|
||||
profileRoot, _
|
||||
nxRoot, _
|
||||
nxRoot & "\config", _
|
||||
nxRoot & "\cache", _
|
||||
nxRoot & "\temp", _
|
||||
nxRoot & "\devices", _
|
||||
profileRoot & "\AppData", _
|
||||
roamingAppData, _
|
||||
localAppData, _
|
||||
tempDirectory, _
|
||||
profileRoot & "\AppData\LocalLow", _
|
||||
profileRoot & "\Logs", _
|
||||
profileRoot & "\Recordings", _
|
||||
profileRoot & "\Sessions", _
|
||||
profileRoot & "\Transfers" _
|
||||
)
|
||||
|
||||
On Error Resume Next
|
||||
For index = 0 To UBound(requiredDirectories)
|
||||
If Not fileSystem.FolderExists(requiredDirectories(index)) Then
|
||||
fileSystem.CreateFolder requiredDirectories(index)
|
||||
End If
|
||||
|
||||
If Err.Number <> 0 Then
|
||||
errorText = "Cannot create the NoMachine profile directory:" & vbCrLf & _
|
||||
requiredDirectories(index) & vbCrLf & Err.Description
|
||||
Err.Clear
|
||||
On Error GoTo 0
|
||||
MsgBox errorText, vbCritical, "NoMachine Launcher"
|
||||
WScript.Quit 2
|
||||
End If
|
||||
Next
|
||||
On Error GoTo 0
|
||||
|
||||
If Not fileSystem.FileExists(executablePath) Then
|
||||
MsgBox "NoMachine executable not found:" & vbCrLf & executablePath, _
|
||||
vbCritical, "NoMachine Launcher"
|
||||
WScript.Quit 3
|
||||
End If
|
||||
|
||||
If Not fileSystem.FileExists(nxRoot & "\config\player.cfg") Then
|
||||
MsgBox "NoMachine configuration not found:" & vbCrLf & _
|
||||
nxRoot & "\config\player.cfg", vbCritical, "NoMachine Launcher"
|
||||
WScript.Quit 4
|
||||
End If
|
||||
|
||||
argumentCount = arguments.Count
|
||||
launchCommand = Chr(34) & executablePath & Chr(34)
|
||||
|
||||
If argumentCount = 2 Then
|
||||
launchMode = LCase(arguments(0))
|
||||
launchFile = arguments(1)
|
||||
|
||||
If launchMode <> "--session" And launchMode <> "--recording" Then
|
||||
MsgBox "Unsupported NoMachine launch mode: " & launchMode, _
|
||||
vbCritical, "NoMachine Launcher"
|
||||
WScript.Quit 6
|
||||
End If
|
||||
|
||||
If InStr(launchFile, Chr(34)) > 0 Or Not fileSystem.FileExists(launchFile) Then
|
||||
MsgBox "NoMachine input file not found or invalid:" & vbCrLf & launchFile, _
|
||||
vbCritical, "NoMachine Launcher"
|
||||
WScript.Quit 7
|
||||
End If
|
||||
|
||||
launchCommand = launchCommand & " " & launchMode & " " & _
|
||||
Chr(34) & launchFile & Chr(34)
|
||||
ElseIf argumentCount <> 0 Then
|
||||
MsgBox "Unsupported NoMachine launcher arguments.", _
|
||||
vbCritical, "NoMachine Launcher"
|
||||
WScript.Quit 8
|
||||
End If
|
||||
|
||||
Set processEnvironment = shell.Environment("PROCESS")
|
||||
processEnvironment("HOME") = profileRoot
|
||||
processEnvironment("USERPROFILE") = profileRoot
|
||||
processEnvironment("HOMEDRIVE") = "C:"
|
||||
processEnvironment("HOMEPATH") = "\Users\Public\Documents\NoMachineProfile"
|
||||
processEnvironment("APPDATA") = roamingAppData
|
||||
processEnvironment("LOCALAPPDATA") = localAppData
|
||||
processEnvironment("TEMP") = tempDirectory
|
||||
processEnvironment("TMP") = tempDirectory
|
||||
processEnvironment("NX_HOME") = profileRoot
|
||||
processEnvironment("NX_CONFIG") = nxRoot
|
||||
processEnvironment("NX_ROOT") = nxRoot
|
||||
processEnvironment("NX_TEMP") = nxRoot & "\temp"
|
||||
processEnvironment("NX_SYSTEM") = installDirectory
|
||||
|
||||
shell.CurrentDirectory = installDirectory & "\bin"
|
||||
|
||||
On Error Resume Next
|
||||
launchResult = shell.Run(launchCommand, WINDOW_NORMAL, False)
|
||||
errorNumber = Err.Number
|
||||
errorText = Err.Description
|
||||
On Error GoTo 0
|
||||
|
||||
If errorNumber <> 0 Then
|
||||
MsgBox "NoMachine could not be started." & vbCrLf & errorText, _
|
||||
vbCritical, "NoMachine Launcher"
|
||||
WScript.Quit 5
|
||||
End If
|
||||
|
||||
WScript.Quit 0
|
||||
Reference in New Issue
Block a user