• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    CMD or Batch snapins are not working! I have no more idea.

    Scheduled Pinned Locked Moved Solved
    General
    6
    24
    14.3k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Wayne WorkmanW
      Wayne Workman
      last edited by

      Take a look at this for examples:
      https://forums.fogproject.org/topic/6414/snapin-questions

      All snapins must run silently. Try your commands manually at one of the computer’s command prompts. Is it absolutely silent?

      If you let me know the UNC path to these files, I can give you commands to copy them. That part is easy.

      Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
      Daily Clean Installation Results:
      https://fogtesting.fogproject.us/
      FOG Reporting:
      https://fog-external-reporting-results.fogproject.us/

      1 Reply Last reply Reply Quote 0
      • ?
        A Former User
        last edited by Joe Schmitt

        Thank you very much!

        the batch file is not running silent. I see cmd in the foreground when I start it. But if I convert it as exe, I always choose the option Silent Mode.

        My batch file contains the following commands:

        BATCHFILE:

        @echo off
        xcopy /E Z:\VM_Classroom\* C:\Users\TEC\Desktop\VM\*
        
        
        IF ERRORLEVEL 1 GOTO failed
        echo VM successfully copied.
        
        goto startvm
        
        
        
        :failed
          echo Error.
        
        goto end
        
        
        pause
        
        :startvm
        
        
        cd "C:\Users\TEC\Desktop\VM"
        
        for /f "delims=" %%a in ('dir /b/s') do if /i "%%~xa"==".vmx" start %%a
        
        
          timeout /t 15
        
        
        
        taskkill /F /IM vmware.exe
        
        
        :end
        
        
        

        and the UNC path is : \172.16.224.177\Public\VM_Classroom\

        Thank you

        Wayne WorkmanW Tom ElliottT 2 Replies Last reply Reply Quote 0
        • Wayne WorkmanW
          Wayne Workman @A Former User
          last edited by

          @Reto
          Get rid of the map drives and just do:

          xcopy "\\172.16.224.177\Public\VM_Classroom\*.*" "%SystemDrive%\Users\TEC\Desktop\VM_Classroom" /y /d /e /c /i /f /h /k /v /s

          Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
          Daily Clean Installation Results:
          https://fogtesting.fogproject.us/
          FOG Reporting:
          https://fog-external-reporting-results.fogproject.us/

          Tom ElliottT 1 Reply Last reply Reply Quote 0
          • ThiagoT
            Thiago
            last edited by

            I always run my .bat files with fog and all works.
            I’ve installed mathematica, matlab, ampl, quartus, salt agent and other config things.
            Try /C argument for cmd.exe

            Snapin Run With C:\Windows\System32\cmd.exe
            Snapin Run With Argument /C

            1 Reply Last reply Reply Quote 1
            • J
              Joe Schmitt Senior Developer
              last edited by Joe Schmitt

              @Reto bewarned: mounting network drives via a SYSTEM executed batch script is next to impossible. The solution @Wayne-Workman provided should work perfectly fine as long as the file share allows anonymous reading.

              Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

              1 Reply Last reply Reply Quote 0
              • ?
                A Former User
                last edited by A Former User

                @Wayne-Workman

                I have tried it with your proposal. When I run the batch file locally it works. The data will be copied and the vm starts. But if I copy the file on to Fog as a snapin, it doesnt work. I tried it, as @Thiago has said with:

                Snapin Run With C:\Windows\System32\cmd.exe
                Snapin Run With Argument /C

                … but does also not work for me…

                When I take a look at the Fog log, I see this:

                14.01.2016 10:01 FOG::SnapinClient Snapin Found:
                14.01.2016 10:01 FOG::SnapinClient ID: 76
                14.01.2016 10:01 FOG::SnapinClient RunWith: C:\Windows\System32\cmd.exe
                14.01.2016 10:01 FOG::SnapinClient RunWithArgs: /C
                14.01.2016 10:01 FOG::SnapinClient Name: W520_VM
                14.01.2016 10:01 FOG::SnapinClient Created: 2016-01-14 08:59:50
                14.01.2016 10:01 FOG::SnapinClient Args:
                14.01.2016 10:01 FOG::SnapinClient Reboot: No
                14.01.2016 10:01 FOG::SnapinClient Starting FOG Snapin Download
                14.01.2016 10:01 FOG::SnapinClient Download complete.
                14.01.2016 10:01 FOG::SnapinClient Starting FOG Snapin Installation.
                14.01.2016 10:01 FOG::SnapinClient FOG Snapin Installtion complete.
                14.01.2016 10:01 FOG::SnapinClient Installation returned with code: 1
                14.01.2016 10:01 FOG::SnapinClient Attempting to connect to fog server…

                But nothing happend. I also tried it without the “run with argument”.
                No success.

                I must mention that the Z: drive must be mounted every time. We have the Public folder there and to this we must be able to access. In the folder are only normal documents and the VM files.

                I have also tried this: I have disconnected the drive and deployed the .bat file as a snapin. Also no success.

                what am I doing wrong?

                Thanks!

                Tom ElliottT Wayne WorkmanW 2 Replies Last reply Reply Quote 0
                • Tom ElliottT
                  Tom Elliott @A Former User
                  last edited by

                  @Reto first thing I noticed wrong with the script, what mounts the z: drive. The script only references the z drive but made no attempt to mount it unless I missed that elsewhere. That being said, as @jbob has said, the system account cannot map drives. For this reason you MUST use the unc path. Essentially, if you replace the Z:\ calls in your script and replace them with what you need to use to make the connection in the first place you aren’t doing anything differently from how it is setup. If the intent is to make the z:\ available to users after the snapin is completed, then you should be using GPO and not a snapin.

                  Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                  Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                  Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                  ? 1 Reply Last reply Reply Quote 0
                  • Tom ElliottT
                    Tom Elliott @A Former User
                    last edited by

                    @Reto said:

                    Thank you very much!

                    the batch file is not running silent. I see cmd in the foreground when I start it. But if I convert it as exe, I always choose the option Silent Mode.

                    My batch file contains the following commands:

                    BATCHFILE:

                    @echo off
                    xcopy /E Z:\VM_Classroom\* C:\Users\TEC\Desktop\VM\*
                    
                    
                    IF ERRORLEVEL 1 GOTO failed
                    echo VM successfully copied.
                    
                    goto startvm
                    
                    
                    
                    :failed
                      echo Error.
                    
                    goto end
                    
                    
                    pause
                    
                    :startvm
                    
                    
                    cd "C:\Users\TEC\Desktop\VM"
                    
                    for /f "delims=" %%a in ('dir /b/s') do if /i "%%~xa"==".vmx" start %%a
                    
                    
                      timeout /t 15
                    
                    
                    
                    taskkill /F /IM vmware.exe
                    
                    
                    :end
                    
                    
                    

                    and the UNC path is : \172.16.224.177\Public\VM_Classroom\

                    Thank you
                    The other part I notice is that you don’t have the script creating the VM_classroom folder on the Windows system, does this folder exist before the script is run once?

                    Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                    Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                    Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                    ? 1 Reply Last reply Reply Quote 0
                    • Tom ElliottT
                      Tom Elliott @Wayne Workman
                      last edited by

                      @Wayne-Workman said:

                      @Reto
                      Get rid of the map drives and just do:

                      xcopy "\\172.16.224.177\Public\VM_Classroom\*.*" "%SystemDrive%\Users\TEC\Desktop\VM_Classroom" /y /d /e /c /i /f /h /k /v /s

                      To step further into this as a question, if this is needed on all systems why not just include it as a part of the image itself?

                      Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                      Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                      Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                      ? 1 Reply Last reply Reply Quote 0
                      • ThiagoT
                        Thiago
                        last edited by

                        Try runas.exe /savecred /user:your-admin-user in your cmd file or in fog snapin config (eg. runas calling cmd)
                        *not tested.

                        1 Reply Last reply Reply Quote 0
                        • ?
                          A Former User @Tom Elliott
                          last edited by A Former User

                          @Tom-Elliott

                          yes, the VM_classroom Folder does already exist. So I don’t have to make the folder with the script.

                          1 Reply Last reply Reply Quote 0
                          • ?
                            A Former User @Tom Elliott
                            last edited by

                            @Tom-Elliott
                            We make different learning course and not everyone needs a VM. For this reason, we want the batch script as snapin. Thats the easiest way for us I think.

                            1 Reply Last reply Reply Quote 0
                            • ?
                              A Former User @Tom Elliott
                              last edited by

                              @Tom-Elliott

                              I have another script in the startup folder, which mounts the Z: drive after a (re-)boot.

                              1 Reply Last reply Reply Quote 0
                              • J
                                jbsclm Developer
                                last edited by jbsclm

                                There are a couple of thing to understand about mapped drives and processes running as the system account.

                                1. A mapped drive only exists in the process which maps it, so mapping it a startup script will not make it available to later processes. You need to always refer to the share by its UNC path.
                                2. You will need to ensure that the share you are trying to access has read and execute permission set for “domain computers” , the client system account belongs to this group.
                                1 Reply Last reply Reply Quote 1
                                • Wayne WorkmanW
                                  Wayne Workman @A Former User
                                  last edited by Wayne Workman

                                  @Reto said:

                                  14.01.2016 10:01 FOG::SnapinClient Installation returned with code: 1

                                  1 means it error’d out.

                                  You need output recording to figure out what’s wrong…

                                  @echo off
                                  xcopy "\\172.16.224.177\Public\VM_Classroom\*.*" "%SystemDrive%\Users\TEC\Desktop\VM_Classroom" /y /d /e /c /i /f /h /k /v /s >> %temp%\vm_copy_output.log
                                  IF ERRORLEVEL 1 GOTO failed
                                  echo VM successfully copied. >> %temp%\vm_copy_output.log
                                  goto startvm
                                  :failed
                                    echo Error. >> %temp%\vm_copy_output.log
                                  goto end
                                  pause
                                  :startvm
                                  cd "C:\Users\TEC\Desktop\VM" >> %temp%\vm_copy_output.log
                                  for /f "delims=" %%a in ('dir /b/s') do if /i "%%~xa"==".vmx" start %%a
                                    timeout /t 15 >> %temp%\vm_copy_output.log
                                  taskkill /F /IM vmware.exe >> %temp%\vm_copy_output.log
                                  :end
                                  
                                  

                                  Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
                                  Daily Clean Installation Results:
                                  https://fogtesting.fogproject.us/
                                  FOG Reporting:
                                  https://fog-external-reporting-results.fogproject.us/

                                  J 1 Reply Last reply Reply Quote 0
                                  • J
                                    jbsclm Developer @Wayne Workman
                                    last edited by

                                    @Wayne-Workman another thing to be aware of is that when you run as the system account, you won’t get the full environment that a normal process would get. It would be better to state a local path in full, rather than rely on environment variables, particularly in the case of %temp%

                                    Wayne WorkmanW 1 Reply Last reply Reply Quote 1
                                    • Wayne WorkmanW
                                      Wayne Workman @jbsclm
                                      last edited by

                                      @jbsclm Noted.

                                      @reto set the output path to whatever you need. I changed it to C:\vm_copy_output.log Here at work, I have my output redirected to hidden read/write network shares, and I name the files with the %computername% variable usually.

                                      @echo off
                                      xcopy "\\172.16.224.177\Public\VM_Classroom\*.*" "%SystemDrive%\Users\TEC\Desktop\VM_Classroom" /y /d /e /c /i /f /h /k /v /s >> c:\vm_copy_output.log
                                      IF ERRORLEVEL 1 GOTO failed
                                      echo VM successfully copied. >> c:\vm_copy_output.log
                                      goto startvm
                                      :failed
                                        echo Error. >> c:\vm_copy_output.log
                                      goto end
                                      pause
                                      :startvm
                                      cd "C:\Users\TEC\Desktop\VM" >> c:\vm_copy_output.log
                                      for /f "delims=" %%a in ('dir /b/s') do if /i "%%~xa"==".vmx" start %%a
                                        timeout /t 15 >> c:\vm_copy_output.log
                                      taskkill /F /IM vmware.exe >> c:\vm_copy_output.log
                                      :end
                                      

                                      Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
                                      Daily Clean Installation Results:
                                      https://fogtesting.fogproject.us/
                                      FOG Reporting:
                                      https://fog-external-reporting-results.fogproject.us/

                                      ? 1 Reply Last reply Reply Quote 0
                                      • ?
                                        A Former User @Wayne Workman
                                        last edited by

                                        @Wayne-Workman Thank you a lot! 👍

                                        I can deploy your batch file successfully. And the log file is also created under 😄 Drive
                                        I used “😄 \ windows \ system32 \ cmd.exe” and argument “C /”.

                                        All files from the public share are now on my desktop in the folder VM_Classroom.

                                        But unfortunately the VM does not start. It only copies the files.

                                        These are the last few lines of the log file:

                                        \172.16.224.177\Public\VM_Classroom\10500_VM1_BIv4_BigData\caches\GuestAppsCache\launchMenu\version -> C:\Users\TEC\Desktop\VM\10500_VM1_BIv4_BigData\caches\GuestAppsCache\launchMenu\version
                                        173 File(s) copied
                                        VM successfully copied.

                                        Waiting for 15 seconds, press a key to continue …14  13  12  11  10  9  8  7  6  5  4  3  2  1  0
                                        SUCCESS: The process “vmware.exe” with PID 4960 has been terminated.

                                        It looks like the script skips the step where it should go to the VM.

                                        hmmm do you see maybe an other mistake?

                                        Wayne WorkmanW 1 Reply Last reply Reply Quote 0
                                        • Wayne WorkmanW
                                          Wayne Workman @A Former User
                                          last edited by

                                          @Reto I’m not sure about that… That’s all specific to your site and I have zero experience doing what you’re doing specifically.

                                          Best I can tell you is to use the output redirection to your advantage, and test your commands manually. Surely it can be done - but past this I can’t really help.

                                          Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
                                          Daily Clean Installation Results:
                                          https://fogtesting.fogproject.us/
                                          FOG Reporting:
                                          https://fog-external-reporting-results.fogproject.us/

                                          ? 1 Reply Last reply Reply Quote 0
                                          • ?
                                            A Former User @Wayne Workman
                                            last edited by

                                            @Wayne-Workman

                                            All right. Thank you very much for the help! 👍
                                            I saw that when I run the file locally, it copies and starts the VM as it should.
                                            I have to find out why that its not work when I’m using snapins.

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • First post
                                              Last post

                                            250

                                            Online

                                            12.0k

                                            Users

                                            17.3k

                                            Topics

                                            155.2k

                                            Posts
                                            Copyright © 2012-2024 FOG Project